+ else if (match_string(line, "comparison", &line)) + { + static const struct + { + const char *string; + D3D12_COMPARISON_FUNC func; + } + funcs[] = + { + {"never", D3D12_COMPARISON_FUNC_NEVER}, + {"less", D3D12_COMPARISON_FUNC_LESS}, + {"equal", D3D12_COMPARISON_FUNC_EQUAL}, + {"less equal", D3D12_COMPARISON_FUNC_LESS_EQUAL}, + {"greater", D3D12_COMPARISON_FUNC_GREATER}, + {"not equal", D3D12_COMPARISON_FUNC_NOT_EQUAL}, + {"greater equal", D3D12_COMPARISON_FUNC_GREATER_EQUAL}, + {"always", D3D12_COMPARISON_FUNC_ALWAYS}, + }; + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(funcs); ++i) + { + if (match_string(line, funcs[i].string, &line)) + { + sampler->filter |= D3D12_FILTER_REDUCTION_TYPE_COMPARISON << D3D12_FILTER_REDUCTION_TYPE_SHIFT; + sampler->func = funcs[i].func; + return; + } + } + + fatal_error("Unknown sampler func '%s'.\n", line); + }
Does that work? I'd expect that to match "comparison less equal" to D3D12_COMPARISON_FUNC_LESS, and "comparison greater equal" to D3D12_COMPARISON_FUNC_GREATER. The comments on the corresponding tests seem highly suspicious in that regard.
+static unsigned int gl_compare_op_from_d3d12(D3D12_COMPARISON_FUNC op) +{ + switch (op) + { + case D3D12_COMPARISON_FUNC_NEVER: + return GL_NEVER; + case D3D12_COMPARISON_FUNC_LESS: + return GL_LESS; + case D3D12_COMPARISON_FUNC_EQUAL: + return GL_EQUAL; + case D3D12_COMPARISON_FUNC_LESS_EQUAL: + return GL_LEQUAL; + case D3D12_COMPARISON_FUNC_GREATER: + return GL_GREATER; + case D3D12_COMPARISON_FUNC_NOT_EQUAL: + return GL_NOTEQUAL; + case D3D12_COMPARISON_FUNC_GREATER_EQUAL: + return GL_GEQUAL; + case D3D12_COMPARISON_FUNC_ALWAYS: + return GL_ALWAYS; + default: + fatal_error("Unhandled compare op %#x.\n", op); + } +}
It's not wrong, but note that the existing similar functions are called get_topology_gl(), get_texture_wrap_gl(), and so on.