Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/tests/hlsl_d3d11.c | 36 +++++++++++++++++--------- 1 file changed, 24 insertions(+), 12 deletions(-)
diff --git a/dlls/d3dcompiler_43/tests/hlsl_d3d11.c b/dlls/d3dcompiler_43/tests/hlsl_d3d11.c index 72b64eb81d7..cdffc806685 100644 --- a/dlls/d3dcompiler_43/tests/hlsl_d3d11.c +++ b/dlls/d3dcompiler_43/tests/hlsl_d3d11.c @@ -564,6 +564,7 @@ static void test_reflection(void) " float b;\n" " float c;\n" " } s;\n" + /* In direct contradiction to the documentation, this does not align. */ " bool g;\n" " float h[2];\n" " int i;\n" @@ -572,6 +573,10 @@ static void test_reflection(void) " row_major float3x1 l;\n" "#pragma pack_matrix(row_major)\n" " float3x1 o;\n" + " float4 p;\n" + " float q;\n" + " struct r_name {float a;} r;\n" + " column_major float3x1 t;\n" "};\n" "\n" "float m;\n" @@ -585,15 +590,21 @@ static void test_reflection(void) { D3D11_SHADER_VARIABLE_DESC var_desc; D3D11_SHADER_TYPE_DESC type_desc; + const D3D11_SHADER_TYPE_DESC *field_types; };
- static const D3D11_SHADER_TYPE_DESC field_types[] = + static const D3D11_SHADER_TYPE_DESC s_field_types[] = { {D3D_SVC_VECTOR, D3D_SVT_FLOAT, 1, 4, 0, 0, 0, "float4"}, {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 1, 0, 0, 16, "float"}, {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 1, 0, 0, 20, "float"}, };
+ static const D3D11_SHADER_TYPE_DESC r_field_types[] = + { + {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 1, 0, 0, 0, "float"}, + }; + static const struct shader_variable globals_vars = {{"m", 0, 4, D3D_SVF_USED}, {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 1, 0, 0, 0, "float"}}; static const struct shader_variable params_vars = @@ -604,7 +615,7 @@ static void test_reflection(void) {{"b", 4, 8}, {D3D_SVC_VECTOR, D3D_SVT_FLOAT, 1, 2, 0, 0, 0, "float2"}}, {{"c", 16, 16}, {D3D_SVC_VECTOR, D3D_SVT_FLOAT, 1, 4, 0, 0, 0, "float4"}}, {{"d", 32, 4}, {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 1, 0, 0, 0, "float"}}, - {{"s", 48, 24}, {D3D_SVC_STRUCT, D3D_SVT_VOID, 1, 6, 0, 3, 0, "<unnamed>"}}, + {{"s", 48, 24}, {D3D_SVC_STRUCT, D3D_SVT_VOID, 1, 6, 0, ARRAY_SIZE(s_field_types), 0, "<unnamed>"}, s_field_types}, {{"g", 72, 4}, {D3D_SVC_SCALAR, D3D_SVT_BOOL, 1, 1, 0, 0, 0, "bool"}}, {{"h", 80, 20}, {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 1, 2, 0, 0, "float"}}, {{"i", 100, 4}, {D3D_SVC_SCALAR, D3D_SVT_INT, 1, 1, 0, 0, 0, "int"}}, @@ -612,6 +623,10 @@ static void test_reflection(void) {{"k", 112, 12}, {D3D_SVC_MATRIX_COLUMNS, D3D_SVT_FLOAT, 3, 1, 0, 0, 0, "float3x1"}}, {{"l", 128, 36}, {D3D_SVC_MATRIX_ROWS, D3D_SVT_FLOAT, 3, 1, 0, 0, 0, "float3x1"}}, {{"o", 176, 36, D3D_SVF_USED}, {D3D_SVC_MATRIX_ROWS, D3D_SVT_FLOAT, 3, 1, 0, 0, 0, "float3x1"}}, + {{"p", 224, 16}, {D3D_SVC_VECTOR, D3D_SVT_FLOAT, 1, 4, 0, 0, 0, "float4"}}, + {{"q", 240, 4}, {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 1, 0, 0, 0, "float"}}, + {{"r", 256, 4}, {D3D_SVC_STRUCT, D3D_SVT_VOID, 1, 1, 0, ARRAY_SIZE(r_field_types), 0, "r_name"}, r_field_types}, + {{"t", 260, 12}, {D3D_SVC_MATRIX_COLUMNS, D3D_SVT_FLOAT, 3, 1, 0, 0, 0, "float3x1"}}, };
static const struct @@ -623,7 +638,7 @@ static void test_reflection(void) { {{"$Globals", D3D_CT_CBUFFER, 1, 16}, &globals_vars}, {{"$Params", D3D_CT_CBUFFER, 1, 16}, ¶ms_vars}, - {{"b1", D3D_CT_CBUFFER, ARRAY_SIZE(buffer_vars), 224}, buffer_vars}, + {{"b1", D3D_CT_CBUFFER, ARRAY_SIZE(buffer_vars), 272}, buffer_vars}, };
todo_wine vs_code = compile_shader(vs_source, "vs_5_0"); @@ -669,16 +684,13 @@ static void test_reflection(void) sprintf(prefix, "Test %u, %u", i, j); check_type_desc(prefix, &type_desc, &expect->type_desc);
- if (!strcmp(type_desc.Name, "<unnamed>")) + for (k = 0; k < type_desc.Members; ++k) { - for (k = 0; k < ARRAY_SIZE(field_types); ++k) - { - field = type->lpVtbl->GetMemberTypeByIndex(type, k); - hr = field->lpVtbl->GetDesc(field, &type_desc); - ok(hr == S_OK, "Test %u, %u, %u: got hr %#x.\n", i, j, k, hr); - sprintf(prefix, "Test %u, %u, %u", i, j, k); - check_type_desc(prefix, &type_desc, &field_types[k]); - } + field = type->lpVtbl->GetMemberTypeByIndex(type, k); + hr = field->lpVtbl->GetDesc(field, &type_desc); + ok(hr == S_OK, "Test %u, %u, %u: got hr %#x.\n", i, j, k, hr); + sprintf(prefix, "Test %u, %u, %u", i, j, k); + check_type_desc(prefix, &type_desc, &vs_buffers[i].vars[j].field_types[k]); } } }
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/tests/hlsl_d3d11.c | 38 ++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-)
diff --git a/dlls/d3dcompiler_43/tests/hlsl_d3d11.c b/dlls/d3dcompiler_43/tests/hlsl_d3d11.c index cdffc806685..63f8f3156b3 100644 --- a/dlls/d3dcompiler_43/tests/hlsl_d3d11.c +++ b/dlls/d3dcompiler_43/tests/hlsl_d3d11.c @@ -552,6 +552,8 @@ static void test_reflection(void)
static const char vs_source[] = "typedef uint uint_t;\n" + "float m;\n" + "\n" "cbuffer b1\n" "{\n" " float a;\n" @@ -579,11 +581,14 @@ static void test_reflection(void) " column_major float3x1 t;\n" "};\n" "\n" - "float m;\n" + "cbuffer b5 : register(b5)\n" + "{\n" + " float4 u;\n" + "}\n" "\n" "float4 main(uniform float4 n) : SV_POSITION\n" "{\n" - " return o._31 + m + n;\n" + " return o._31 + m + n + u;\n" "}";
struct shader_variable @@ -628,6 +633,8 @@ static void test_reflection(void) {{"r", 256, 4}, {D3D_SVC_STRUCT, D3D_SVT_VOID, 1, 1, 0, ARRAY_SIZE(r_field_types), 0, "r_name"}, r_field_types}, {{"t", 260, 12}, {D3D_SVC_MATRIX_COLUMNS, D3D_SVT_FLOAT, 3, 1, 0, 0, 0, "float3x1"}}, }; + static const struct shader_variable b5_vars = + {{"u", 0, 16, D3D_SVF_USED}, {D3D_SVC_VECTOR, D3D_SVT_FLOAT, 1, 4, 0, 0, 0, "float4"}};
static const struct { @@ -639,6 +646,15 @@ static void test_reflection(void) {{"$Globals", D3D_CT_CBUFFER, 1, 16}, &globals_vars}, {{"$Params", D3D_CT_CBUFFER, 1, 16}, ¶ms_vars}, {{"b1", D3D_CT_CBUFFER, ARRAY_SIZE(buffer_vars), 272}, buffer_vars}, + {{"b5", D3D_CT_CBUFFER, 1, 16}, &b5_vars}, + }; + + static const D3D11_SHADER_INPUT_BIND_DESC vs_bindings[] = + { + {"$Globals", D3D_SIT_CBUFFER, 0, 1}, + {"$Params", D3D_SIT_CBUFFER, 1, 1}, + {"b1", D3D_SIT_CBUFFER, 2, 1}, + {"b5", D3D_SIT_CBUFFER, 5, 1, D3D_SIF_USERPACKED}, };
todo_wine vs_code = compile_shader(vs_source, "vs_5_0"); @@ -695,6 +711,24 @@ static void test_reflection(void) } }
+ for (i = 0; i < ARRAY_SIZE(vs_bindings); ++i) + { + D3D11_SHADER_INPUT_BIND_DESC desc; + + hr = reflection->lpVtbl->GetResourceBindingDesc(reflection, i, &desc); + todo_wine ok(hr == S_OK, "Test %u: got hr %#x.\n", i, hr); + if (hr != S_OK) + break; + ok(!strcmp(desc.Name, vs_bindings[i].Name), "Test %u: got name %s.\n", i, debugstr_a(desc.Name)); + ok(desc.Type == vs_bindings[i].Type, "Test %u: got type %#x.\n", i, desc.Type); + ok(desc.BindPoint == vs_bindings[i].BindPoint, "Test %u: got bind point %u.\n", i, desc.BindPoint); + ok(desc.BindCount == vs_bindings[i].BindCount, "Test %u: got bind count %u.\n", i, desc.BindCount); + ok(desc.uFlags == vs_bindings[i].uFlags, "Test %u: got flags %#x.\n", i, desc.uFlags); + ok(desc.ReturnType == vs_bindings[i].ReturnType, "Test %u: got return type %#x.\n", i, desc.ReturnType); + ok(desc.Dimension == vs_bindings[i].Dimension, "Test %u: got dimension %#x.\n", i, desc.Dimension); + ok(desc.NumSamples == vs_bindings[i].NumSamples, "Test %u: got multisample count %u.\n", i, desc.NumSamples); + } + ID3D10Blob_Release(vs_code); refcount = reflection->lpVtbl->Release(reflection); ok(!refcount, "Got unexpected refcount %u.\n", refcount);
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
That is, do not check that the shader is a pixel shader and that the signature is an output signature. These semantic names can only be generated in such conditions; using the name for any other stage is invalid.
The motivation for this patch is that the correct sysval should be reported even if the RDEF chunk is missing. Accordingly I have replaced each test shader with a stripped version.
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/reflection.c | 39 +++---- dlls/d3dcompiler_43/tests/reflection.c | 152 ++++++++----------------- 2 files changed, 59 insertions(+), 132 deletions(-)
diff --git a/dlls/d3dcompiler_43/reflection.c b/dlls/d3dcompiler_43/reflection.c index 729501dbddc..a081b20d68f 100644 --- a/dlls/d3dcompiler_43/reflection.c +++ b/dlls/d3dcompiler_43/reflection.c @@ -1608,7 +1608,7 @@ err_out: return hr; }
-static HRESULT d3dcompiler_parse_signature(struct d3dcompiler_shader_signature *s, struct dxbc_section *section, DWORD target) +static HRESULT d3dcompiler_parse_signature(struct d3dcompiler_shader_signature *s, struct dxbc_section *section) { D3D11_SIGNATURE_PARAMETER_DESC *d; unsigned int string_data_offset; @@ -1690,27 +1690,16 @@ static HRESULT d3dcompiler_parse_signature(struct d3dcompiler_shader_signature * d[i].ReadWriteMask = (mask >> 8) & 0xff; d[i].Mask = mask & 0xff;
- /* pixel shaders have a special handling for SystemValueType in the output signature */ - if (((target & D3DCOMPILER_SHADER_TARGET_SHADERTYPE_MASK) == 0xffff0000) && (section->tag == TAG_OSG5 || section->tag == TAG_OSGN)) - { - TRACE("Pixelshader output signature fixup.\n"); - - if (d[i].Register == 0xffffffff) - { - if (!stricmp(d[i].SemanticName, "sv_depth")) - d[i].SystemValueType = D3D_NAME_DEPTH; - else if (!stricmp(d[i].SemanticName, "sv_coverage")) - d[i].SystemValueType = D3D_NAME_COVERAGE; - else if (!stricmp(d[i].SemanticName, "sv_depthgreaterequal")) - d[i].SystemValueType = D3D_NAME_DEPTH_GREATER_EQUAL; - else if (!stricmp(d[i].SemanticName, "sv_depthlessequal")) - d[i].SystemValueType = D3D_NAME_DEPTH_LESS_EQUAL; - } - else - { - d[i].SystemValueType = D3D_NAME_TARGET; - } - } + if (!stricmp(d[i].SemanticName, "sv_depth")) + d[i].SystemValueType = D3D_NAME_DEPTH; + else if (!stricmp(d[i].SemanticName, "sv_coverage")) + d[i].SystemValueType = D3D_NAME_COVERAGE; + else if (!stricmp(d[i].SemanticName, "sv_depthgreaterequal")) + d[i].SystemValueType = D3D_NAME_DEPTH_GREATER_EQUAL; + else if (!stricmp(d[i].SemanticName, "sv_depthlessequal")) + d[i].SystemValueType = D3D_NAME_DEPTH_LESS_EQUAL; + else if (!stricmp(d[i].SemanticName, "sv_target")) + d[i].SystemValueType = D3D_NAME_TARGET;
TRACE("semantic: %s, semantic idx: %u, sysval_semantic %#x, " "type %u, register idx: %u, use_mask %#x, input_mask %#x, stream %u\n", @@ -1777,7 +1766,7 @@ static HRESULT d3dcompiler_shader_reflection_init(struct d3dcompiler_shader_refl goto err_out; }
- hr = d3dcompiler_parse_signature(reflection->isgn, section, reflection->target); + hr = d3dcompiler_parse_signature(reflection->isgn, section); if (FAILED(hr)) { WARN("Failed to parse section ISGN.\n"); @@ -1795,7 +1784,7 @@ static HRESULT d3dcompiler_shader_reflection_init(struct d3dcompiler_shader_refl goto err_out; }
- hr = d3dcompiler_parse_signature(reflection->osgn, section, reflection->target); + hr = d3dcompiler_parse_signature(reflection->osgn, section); if (FAILED(hr)) { WARN("Failed to parse section OSGN.\n"); @@ -1812,7 +1801,7 @@ static HRESULT d3dcompiler_shader_reflection_init(struct d3dcompiler_shader_refl goto err_out; }
- hr = d3dcompiler_parse_signature(reflection->pcsg, section, reflection->target); + hr = d3dcompiler_parse_signature(reflection->pcsg, section); if (FAILED(hr)) { WARN("Failed to parse section PCSG.\n"); diff --git a/dlls/d3dcompiler_43/tests/reflection.c b/dlls/d3dcompiler_43/tests/reflection.c index 617003a97b7..b51a0a20f4d 100644 --- a/dlls/d3dcompiler_43/tests/reflection.c +++ b/dlls/d3dcompiler_43/tests/reflection.c @@ -794,9 +794,6 @@ static void test_reflection_desc_ps(void) ok(count == 0, "Release failed %u\n", count); }
-/* - * fxc.exe /E PS /Tps_5_0 /Fx - */ #if 0 float4 PS() : SV_Target3 { @@ -804,25 +801,16 @@ float4 PS() : SV_Target3 return a; } #endif -static const DWORD test_reflection_desc_ps_output_blob_0[] = { -0x43425844, 0x3e7b77e6, 0xe4e920b7, 0x9cad0533, 0x240117cc, 0x00000001, 0x0000018c, 0x00000005, -0x00000034, 0x0000008c, 0x0000009c, 0x000000d0, 0x00000110, 0x46454452, 0x00000050, 0x00000000, -0x00000000, 0x00000000, 0x0000001c, 0xffff0400, 0x00000100, 0x0000001c, 0x7263694d, 0x666f736f, -0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x39207265, 0x2e39322e, -0x2e323539, 0x31313133, 0xababab00, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f, -0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000003, 0x00000000, 0x00000003, 0x00000003, -0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000038, 0x00000040, 0x0000000e, -0x03000065, 0x001020f2, 0x00000003, 0x08000036, 0x001020f2, 0x00000003, 0x00004002, 0x3f99999a, -0x3f800000, 0x3e4ccccd, 0x00000000, 0x0100003e, 0x54415453, 0x00000074, 0x00000002, 0x00000000, -0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, -0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, -0x00000000, 0x00000000, 0x00000000 +static const DWORD test_reflection_desc_ps_output_blob_0[] = +{ + 0x43425844, 0xc3773602, 0x04f86bdc, 0x715f33b2, 0x9c063cae, 0x00000001, 0x000000b4, 0x00000003, + 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f, + 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000003, 0x00000000, 0x00000003, 0x00000003, + 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x0000003c, 0x00000050, 0x0000000f, + 0x0100086a, 0x03000065, 0x001020f2, 0x00000003, 0x08000036, 0x001020f2, 0x00000003, 0x00004002, + 0x3f99999a, 0x3f800000, 0x3e4ccccd, 0x00000000, 0x0100003e, };
-/* - * fxc.exe /E PS /Tps_5_0 /Fx - */ #if 0 float PS() : SV_DepthLessEqual { @@ -830,27 +818,16 @@ float PS() : SV_DepthLessEqual return a; } #endif -static const DWORD test_reflection_desc_ps_output_blob_1[] = { -0x43425844, 0xd8ead3ec, 0x61276ada, 0x70cdaa9e, 0x2cfd7f4c, 0x00000001, 0x000001c4, 0x00000005, -0x00000034, 0x000000ac, 0x000000bc, 0x000000f8, 0x00000128, 0x46454452, 0x00000070, 0x00000000, -0x00000000, 0x00000000, 0x0000003c, 0xffff0500, 0x00000100, 0x0000003c, 0x31314452, 0x0000003c, -0x00000018, 0x00000020, 0x00000028, 0x00000024, 0x0000000c, 0x00000000, 0x7263694d, 0x666f736f, -0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x39207265, 0x2e39322e, -0x2e323539, 0x31313133, 0xababab00, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f, -0x00000034, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0xffffffff, -0x00000e01, 0x445f5653, 0x68747065, 0x7373654c, 0x61757145, 0xabab006c, 0x58454853, 0x00000028, -0x00000050, 0x0000000a, 0x0100086a, 0x02000065, 0x00027001, 0x04000036, 0x00027001, 0x00004001, -0x3f99999a, 0x0100003e, 0x54415453, 0x00000094, 0x00000002, 0x00000000, 0x00000000, 0x00000001, -0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, -0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, -0x00000000, +static const DWORD test_reflection_desc_ps_output_blob_1[] = +{ + 0x43425844, 0xc45db587, 0xdb0601fb, 0x7370900b, 0x219464be, 0x00000001, 0x000000a8, 0x00000003, + 0x0000002c, 0x0000003c, 0x00000078, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f, + 0x00000034, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0xffffffff, + 0x00000e01, 0x445f5653, 0x68747065, 0x7373654c, 0x61757145, 0xabab006c, 0x58454853, 0x00000028, + 0x00000050, 0x0000000a, 0x0100086a, 0x02000065, 0x00027001, 0x04000036, 0x00027001, 0x00004001, + 0x3f99999a, 0x0100003e, };
-/* - * fxc.exe /E PS /Tps_5_0 /Fx - */ #if 0 float PS() : SV_DepthGreaterEqual { @@ -858,27 +835,16 @@ float PS() : SV_DepthGreaterEqual return a; } #endif -static const DWORD test_reflection_desc_ps_output_blob_2[] = { -0x43425844, 0x9f61c8df, 0x612cbb1f, 0x9e1d039e, 0xf925a074, 0x00000001, 0x000001c8, 0x00000005, -0x00000034, 0x000000ac, 0x000000bc, 0x000000fc, 0x0000012c, 0x46454452, 0x00000070, 0x00000000, -0x00000000, 0x00000000, 0x0000003c, 0xffff0500, 0x00000100, 0x0000003c, 0x31314452, 0x0000003c, -0x00000018, 0x00000020, 0x00000028, 0x00000024, 0x0000000c, 0x00000000, 0x7263694d, 0x666f736f, -0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x39207265, 0x2e39322e, -0x2e323539, 0x31313133, 0xababab00, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f, -0x00000038, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0xffffffff, -0x00000e01, 0x445f5653, 0x68747065, 0x61657247, 0x45726574, 0x6c617571, 0xababab00, 0x58454853, -0x00000028, 0x00000050, 0x0000000a, 0x0100086a, 0x02000065, 0x00026001, 0x04000036, 0x00026001, -0x00004001, 0x3f99999a, 0x0100003e, 0x54415453, 0x00000094, 0x00000002, 0x00000000, 0x00000000, -0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, -0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, -0x00000000, 0x00000000, +static const DWORD test_reflection_desc_ps_output_blob_2[] = +{ + 0x43425844, 0x13cce144, 0x3628f322, 0xa8ea9b7d, 0xbbf9f8d7, 0x00000001, 0x000000ac, 0x00000003, + 0x0000002c, 0x0000003c, 0x0000007c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f, + 0x00000038, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0xffffffff, + 0x00000e01, 0x445f5653, 0x68747065, 0x61657247, 0x45726574, 0x6c617571, 0xababab00, 0x58454853, + 0x00000028, 0x00000050, 0x0000000a, 0x0100086a, 0x02000065, 0x00026001, 0x04000036, 0x00026001, + 0x00004001, 0x3f99999a, 0x0100003e, };
-/* - * fxc.exe /E PS /Tps_5_0 /Fx - */ #if 0 float PS() : sV_DePtH { @@ -886,26 +852,15 @@ float PS() : sV_DePtH return a; } #endif -static const DWORD test_reflection_desc_ps_output_blob_3[] = { -0x43425844, 0x32cec0e6, 0x3873ed32, 0x2e86ffd0, 0x21bb00e8, 0x00000001, 0x000001bc, 0x00000005, -0x00000034, 0x000000ac, 0x000000bc, 0x000000f0, 0x00000120, 0x46454452, 0x00000070, 0x00000000, -0x00000000, 0x00000000, 0x0000003c, 0xffff0500, 0x00000100, 0x0000003c, 0x31314452, 0x0000003c, -0x00000018, 0x00000020, 0x00000028, 0x00000024, 0x0000000c, 0x00000000, 0x7263694d, 0x666f736f, -0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x39207265, 0x2e39322e, -0x2e323539, 0x31313133, 0xababab00, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f, -0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0xffffffff, -0x00000e01, 0x445f5673, 0x48745065, 0xababab00, 0x58454853, 0x00000028, 0x00000050, 0x0000000a, -0x0100086a, 0x02000065, 0x0000c001, 0x04000036, 0x0000c001, 0x00004001, 0x3f99999a, 0x0100003e, -0x54415453, 0x00000094, 0x00000002, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, -0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, +static const DWORD test_reflection_desc_ps_output_blob_3[] = +{ + 0x43425844, 0x31c891d1, 0xcbb9d935, 0xa199e1d5, 0x70205254, 0x00000001, 0x000000a0, 0x00000003, + 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f, + 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0xffffffff, + 0x00000e01, 0x445f5673, 0x48745065, 0xababab00, 0x58454853, 0x00000028, 0x00000050, 0x0000000a, + 0x0100086a, 0x02000065, 0x0000c001, 0x04000036, 0x0000c001, 0x00004001, 0x3f99999a, 0x0100003e, };
-/* - * fxc.exe /E PS /Tps_4_0 /Fx - */ #if 0 float PS() : SV_Depth { @@ -913,24 +868,15 @@ float PS() : SV_Depth return a; } #endif -static const DWORD test_reflection_desc_ps_output_blob_4[] = { -0x43425844, 0x7af34874, 0x975f09ad, 0xf6e50764, 0xdfb1255f, 0x00000001, 0x00000178, 0x00000005, -0x00000034, 0x0000008c, 0x0000009c, 0x000000d0, 0x000000fc, 0x46454452, 0x00000050, 0x00000000, -0x00000000, 0x00000000, 0x0000001c, 0xffff0400, 0x00000100, 0x0000001c, 0x7263694d, 0x666f736f, -0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x39207265, 0x2e39322e, -0x2e323539, 0x31313133, 0xababab00, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f, -0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0xffffffff, -0x00000e01, 0x445f5653, 0x68747065, 0xababab00, 0x52444853, 0x00000024, 0x00000040, 0x00000009, -0x02000065, 0x0000c001, 0x04000036, 0x0000c001, 0x00004001, 0x3f99999a, 0x0100003e, 0x54415453, -0x00000074, 0x00000002, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, -0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, +static const DWORD test_reflection_desc_ps_output_blob_4[] = +{ + 0x43425844, 0x1d404736, 0x00e4a4aa, 0x5fcdad54, 0x5abd13f8, 0x00000001, 0x0000009c, 0x00000003, + 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f, + 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0xffffffff, + 0x00000e01, 0x445f5653, 0x68747065, 0xababab00, 0x52444853, 0x00000024, 0x00000040, 0x00000009, + 0x02000065, 0x0000c001, 0x04000036, 0x0000c001, 0x00004001, 0x3f99999a, 0x0100003e, };
-/* - * fxc.exe /E PS /Tps_4_0 /Fx - */ #if 0 bool PS() : SV_COVERAGE { @@ -938,21 +884,13 @@ bool PS() : SV_COVERAGE return a; } #endif -static const DWORD test_reflection_desc_ps_output_blob_5[] = { -0x43425844, 0x40ae32a7, 0xe944bb1c, 0x1a2b1923, 0xea25962d, 0x00000001, 0x000001bc, 0x00000005, -0x00000034, 0x000000ac, 0x000000bc, 0x000000f0, 0x00000120, 0x46454452, 0x00000070, 0x00000000, -0x00000000, 0x00000000, 0x0000003c, 0xffff0500, 0x00000100, 0x0000003c, 0x31314452, 0x0000003c, -0x00000018, 0x00000020, 0x00000028, 0x00000024, 0x0000000c, 0x00000000, 0x7263694d, 0x666f736f, -0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x39207265, 0x2e39322e, -0x2e323539, 0x31313133, 0xababab00, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f, -0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0xffffffff, -0x00000e01, 0x435f5653, 0x5245564f, 0x00454741, 0x58454853, 0x00000028, 0x00000050, 0x0000000a, -0x0100086a, 0x02000065, 0x0000f000, 0x04000036, 0x0000f001, 0x00004001, 0xffffffff, 0x0100003e, -0x54415453, 0x00000094, 0x00000002, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, -0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, +static const DWORD test_reflection_desc_ps_output_blob_5[] = +{ + 0x43425844, 0x6127612d, 0x09e2bb9a, 0xbba3889a, 0x987dafc2, 0x00000001, 0x000000a0, 0x00000003, + 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f, + 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0xffffffff, + 0x00000e01, 0x435f5653, 0x5245564f, 0x00454741, 0x52444853, 0x00000028, 0x00000041, 0x0000000a, + 0x0100086a, 0x02000065, 0x0000f000, 0x04000036, 0x0000f001, 0x00004001, 0xffffffff, 0x0100003e, };
static void test_reflection_desc_ps_output(void)
On Thu, Aug 13, 2020 at 2:34 AM Zebediah Figura z.figura12@gmail.com wrote:
That is, do not check that the shader is a pixel shader and that the signature is an output signature. These semantic names can only be generated in such conditions; using the name for any other stage is invalid.
The motivation for this patch is that the correct sysval should be reported even if the RDEF chunk is missing. Accordingly I have replaced each test shader with a stripped version.
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
diff --git a/dlls/d3dcompiler_43/tests/reflection.c b/dlls/d3dcompiler_43/tests/reflection.c index 617003a97b7..b51a0a20f4d 100644 --- a/dlls/d3dcompiler_43/tests/reflection.c +++ b/dlls/d3dcompiler_43/tests/reflection.c @@ -794,9 +794,6 @@ static void test_reflection_desc_ps(void) ok(count == 0, "Release failed %u\n", count); }
-/*
- fxc.exe /E PS /Tps_5_0 /Fx
- */
#if 0 float4 PS() : SV_Target3 { @@ -804,25 +801,16 @@ float4 PS() : SV_Target3 return a; } #endif -static const DWORD test_reflection_desc_ps_output_blob_0[] = { -0x43425844, 0x3e7b77e6, 0xe4e920b7, 0x9cad0533, 0x240117cc, 0x00000001, 0x0000018c, 0x00000005, -0x00000034, 0x0000008c, 0x0000009c, 0x000000d0, 0x00000110, 0x46454452, 0x00000050, 0x00000000, -0x00000000, 0x00000000, 0x0000001c, 0xffff0400, 0x00000100, 0x0000001c, 0x7263694d, 0x666f736f, -0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x39207265, 0x2e39322e, -0x2e323539, 0x31313133, 0xababab00, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f, -0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000003, 0x00000000, 0x00000003, 0x00000003, -0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000038, 0x00000040, 0x0000000e, -0x03000065, 0x001020f2, 0x00000003, 0x08000036, 0x001020f2, 0x00000003, 0x00004002, 0x3f99999a, -0x3f800000, 0x3e4ccccd, 0x00000000, 0x0100003e, 0x54415453, 0x00000074, 0x00000002, 0x00000000, -0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, -0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, -0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, -0x00000000, 0x00000000, 0x00000000 +static const DWORD test_reflection_desc_ps_output_blob_0[] = +{
- 0x43425844, 0xc3773602, 0x04f86bdc, 0x715f33b2, 0x9c063cae, 0x00000001, 0x000000b4, 0x00000003,
- 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
- 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000003, 0x00000000, 0x00000003, 0x00000003,
- 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x0000003c, 0x00000050, 0x0000000f,
- 0x0100086a, 0x03000065, 0x001020f2, 0x00000003, 0x08000036, 0x001020f2, 0x00000003, 0x00004002,
- 0x3f99999a, 0x3f800000, 0x3e4ccccd, 0x00000000, 0x0100003e,
};
I guess the "fxc command line" comments aren't very significant. Fine with me to get rid of those in general. I think it would be nice to mention that these particular shaders are stripped, though. It doesn't need to be anything crazy, simply bringing some of the commit message into a comment around here would be more than enough.
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/tests/hlsl_d3d11.c | 242 ++++++++++++++++++++++++- 1 file changed, 238 insertions(+), 4 deletions(-)
diff --git a/dlls/d3dcompiler_43/tests/hlsl_d3d11.c b/dlls/d3dcompiler_43/tests/hlsl_d3d11.c index 63f8f3156b3..aff75a5eafa 100644 --- a/dlls/d3dcompiler_43/tests/hlsl_d3d11.c +++ b/dlls/d3dcompiler_43/tests/hlsl_d3d11.c @@ -42,13 +42,14 @@ struct vec4 float x, y, z, w; };
-#define compile_shader(a, b) compile_shader_(__LINE__, a, b) -static ID3D10Blob *compile_shader_(unsigned int line, const char *source, const char *target) +#define compile_shader(a, b) compile_shader_(__LINE__, a, b, 0) +#define compile_shader_flags(a, b, c) compile_shader_(__LINE__, a, b, c) +static ID3D10Blob *compile_shader_(unsigned int line, const char *source, const char *target, UINT flags) { ID3D10Blob *blob = NULL, *errors = NULL; HRESULT hr;
- hr = ppD3DCompile(source, strlen(source), NULL, NULL, NULL, "main", target, 0, 0, &blob, &errors); + hr = ppD3DCompile(source, strlen(source), NULL, NULL, NULL, "main", target, flags, 0, &blob, &errors); ok_(__FILE__, line)(hr == S_OK, "Failed to compile shader, hr %#x.\n", hr); if (errors) { @@ -287,7 +288,7 @@ static void draw_quad_(unsigned int line, struct test_context *context, ID3D10Bl
if (!context->vs) { - ID3D10Blob *vs_code = compile_shader_(line, vs_source, "vs_4_0"); + ID3D10Blob *vs_code = compile_shader_(line, vs_source, "vs_4_0", 0);
hr = ID3D11Device_CreateInputLayout(device, default_layout_desc, ARRAY_SIZE(default_layout_desc), ID3D10Blob_GetBufferPointer(vs_code), ID3D10Blob_GetBufferSize(vs_code), &context->input_layout); @@ -734,6 +735,238 @@ static void test_reflection(void) ok(!refcount, "Got unexpected refcount %u.\n", refcount); }
+static void check_parameter_desc(const char *prefix, const D3D11_SIGNATURE_PARAMETER_DESC *desc, + const D3D11_SIGNATURE_PARAMETER_DESC *expect) +{ + ok(!strcmp(desc->SemanticName, expect->SemanticName), "%s: got name %s.\n", prefix, debugstr_a(desc->SemanticName)); + ok(desc->SemanticIndex == expect->SemanticIndex, "%s: got index %u.\n", prefix, desc->SemanticIndex); + ok(desc->Register == expect->Register, "%s: got register %u.\n", prefix, desc->Register); + ok(desc->SystemValueType == expect->SystemValueType, "%s: got sysval %u.\n", prefix, desc->SystemValueType); + ok(desc->ComponentType == expect->ComponentType, "%s: got data type %u.\n", prefix, desc->ComponentType); + ok(desc->Mask == expect->Mask, "%s: got mask %#x.\n", prefix, desc->Mask); + todo_wine_if(desc->ReadWriteMask != expect->ReadWriteMask) + ok(desc->ReadWriteMask == expect->ReadWriteMask, "%s: got used mask %#x.\n", prefix, desc->ReadWriteMask); + ok(desc->Stream == expect->Stream, "%s: got stream %u.\n", prefix, desc->Stream); +} + +static void test_semantic_reflection(void) +{ + D3D11_SIGNATURE_PARAMETER_DESC desc; + ID3D11ShaderReflection *reflection; + D3D11_SHADER_DESC shader_desc; + ID3D10Blob *code = NULL; + unsigned int i, j; + char prefix[40]; + ULONG refcount; + HRESULT hr; + + static const char vs1_source[] = + "void main(\n" + " in float4 a : apple,\n" + " out float4 b : banana2,\n" + " inout float4 c : color,\n" + " inout float4 d : depth,\n" + " inout float4 e : sv_position,\n" + " in uint3 f : fruit,\n" + " inout bool2 g : grape,\n" + " in int h : honeydew)\n" + "{\n" + " b.yw = a.xz;\n" + "}"; + + static const D3D11_SIGNATURE_PARAMETER_DESC vs1_inputs[] = + { + {"apple", 0, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0x5}, + {"color", 0, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0xf}, + {"depth", 0, 2, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0xf}, + {"sv_position", 0, 3, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0xf}, + {"fruit", 0, 4, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_UINT32, 0x7}, + {"grape", 0, 5, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_UINT32, 0x3, 0x3}, + {"honeydew", 0, 6, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_SINT32, 0x1}, + }; + + static const D3D11_SIGNATURE_PARAMETER_DESC vs1_outputs[] = + { + {"banana", 2, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0x5}, + {"color", 0, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf}, + {"depth", 0, 2, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf}, + {"sv_position", 0, 3, D3D_NAME_POSITION, D3D_REGISTER_COMPONENT_FLOAT32, 0xf}, + {"grape", 0, 4, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_UINT32, 0x3, 0xc}, + }; + + static const char vs2_source[] = + "void main(inout float4 pos : position)\n" + "{\n" + "}"; + + static const D3D11_SIGNATURE_PARAMETER_DESC vs2_inputs[] = + { + {"position", 0, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0xf}, + }; + + static const D3D11_SIGNATURE_PARAMETER_DESC vs2_outputs[] = + { + {"position", 0, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf}, + }; + + static const D3D11_SIGNATURE_PARAMETER_DESC vs2_legacy_outputs[] = + { + {"SV_Position", 0, 0, D3D_NAME_POSITION, D3D_REGISTER_COMPONENT_FLOAT32, 0xf}, + }; + + static const char ps1_source[] = + "void main(\n" + " in float2 a : apple,\n" + " out float4 b : sv_target2,\n" + " out float c : sv_depth,\n" + " in float4 d : position,\n" + " in float4 e : sv_position)\n" + "{\n" + " b = d;\n" + " c = 0;\n" + "}"; + + static const D3D11_SIGNATURE_PARAMETER_DESC ps1_inputs[] = + { + {"apple", 0, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x3}, + {"position", 0, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0xf}, + {"sv_position", 0, 2, D3D_NAME_POSITION, D3D_REGISTER_COMPONENT_FLOAT32, 0xf}, + }; + + static const D3D11_SIGNATURE_PARAMETER_DESC ps1_outputs[] = + { + {"sv_target", 2, 2, D3D_NAME_TARGET, D3D_REGISTER_COMPONENT_FLOAT32, 0xf}, + {"sv_depth", 0, ~0u, D3D_NAME_DEPTH, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe}, + }; + + static const char ps2_source[] = + "void main(\n" + " inout float4 a : color2,\n" + " inout float b : depth,\n" + " in float4 c : position)\n" + "{\n" + "}"; + + static const D3D11_SIGNATURE_PARAMETER_DESC ps2_inputs[] = + { + {"color", 2, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0xf}, + {"depth", 0, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0x1}, + {"SV_Position", 0, 2, D3D_NAME_POSITION, D3D_REGISTER_COMPONENT_FLOAT32, 0xf}, + }; + + static const D3D11_SIGNATURE_PARAMETER_DESC ps2_outputs[] = + { + {"SV_Target", 2, 2, D3D_NAME_TARGET, D3D_REGISTER_COMPONENT_FLOAT32, 0xf}, + {"SV_Depth", 0, ~0u, D3D_NAME_DEPTH, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe}, + }; + + static const char cs1_source[] = + "[numthreads(1, 1, 1)]\n" + "void main(in uint a : sv_dispatchthreadid)\n" + "{\n" + "}"; + + static const char gs1_source[] = + "struct input\n" + "{\n" + " float4 a : sv_position;\n" + " float4 b : apple2;\n" + "};\n" + "struct vertex\n" + "{\n" + " float4 a : sv_position;\n" + " float4 b : apple2;\n" + " uint c : sv_primitiveid;\n" + "};\n" + "[maxvertexcount(1)]\n" + "void main(\n" + " point input i[1],\n" + " inout PointStream<vertex> o,\n" + " uint a : sv_primitiveid)\n" + "{\n" + " struct vertex v;\n" + " v.a = i[0].a;\n" + " v.b = i[0].b;\n" + " v.c = a;\n" + " o.Append(v);\n" + "}"; + + static const D3D11_SIGNATURE_PARAMETER_DESC gs1_inputs[] = + { + {"sv_position", 0, 0, D3D_NAME_POSITION, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0xf}, + {"apple", 2, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0xf}, + {"sv_primitiveid", 0, ~0u, D3D_NAME_PRIMITIVE_ID, D3D_REGISTER_COMPONENT_UINT32, 0x1, 0x1}, + }; + + static const D3D11_SIGNATURE_PARAMETER_DESC gs1_outputs[] = + { + {"sv_position", 0, 0, D3D_NAME_POSITION, D3D_REGISTER_COMPONENT_FLOAT32, 0xf}, + {"apple", 2, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf}, + {"sv_primitiveid", 0, 2, D3D_NAME_PRIMITIVE_ID, D3D_REGISTER_COMPONENT_UINT32, 0x1, 0xe}, + }; + + static const struct + { + const char *source; + const char *target; + BOOL legacy; + const D3D11_SIGNATURE_PARAMETER_DESC *inputs; + unsigned int input_count; + const D3D11_SIGNATURE_PARAMETER_DESC *outputs; + unsigned int output_count; + } + tests[] = + { + {vs1_source, "vs_4_0", FALSE, vs1_inputs, ARRAY_SIZE(vs1_inputs), vs1_outputs, ARRAY_SIZE(vs1_outputs)}, + {vs1_source, "vs_4_0", TRUE, vs1_inputs, ARRAY_SIZE(vs1_inputs), vs1_outputs, ARRAY_SIZE(vs1_outputs)}, + {vs2_source, "vs_4_0", FALSE, vs2_inputs, ARRAY_SIZE(vs2_inputs), vs2_outputs, ARRAY_SIZE(vs2_outputs)}, + {vs2_source, "vs_4_0", TRUE, vs2_inputs, ARRAY_SIZE(vs2_inputs), vs2_legacy_outputs, ARRAY_SIZE(vs2_legacy_outputs)}, + {ps1_source, "ps_4_0", FALSE, ps1_inputs, ARRAY_SIZE(ps1_inputs), ps1_outputs, ARRAY_SIZE(ps1_outputs)}, + {ps2_source, "ps_4_0", TRUE, ps2_inputs, ARRAY_SIZE(ps2_inputs), ps2_outputs, ARRAY_SIZE(ps2_outputs)}, + {cs1_source, "cs_4_0", FALSE, NULL, 0, NULL, 0}, + {gs1_source, "gs_4_0", FALSE, gs1_inputs, ARRAY_SIZE(gs1_inputs), gs1_outputs, ARRAY_SIZE(gs1_outputs)}, + }; + + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + todo_wine code = compile_shader_flags(tests[i].source, tests[i].target, + tests[i].legacy ? D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY : 0); + if (!code) + continue; + + hr = pD3DReflect(ID3D10Blob_GetBufferPointer(code), ID3D10Blob_GetBufferSize(code), + &IID_ID3D11ShaderReflection, (void **)&reflection); + ok(hr == S_OK, "Test %u: got hr %#x.\n", i, hr); + + hr = reflection->lpVtbl->GetDesc(reflection, &shader_desc); + ok(hr == S_OK, "Test %u: got hr %#x.\n", i, hr); + todo_wine ok(shader_desc.InputParameters == tests[i].input_count, + "Test %u: got %u input parameters.\n", i, shader_desc.InputParameters); + todo_wine ok(shader_desc.OutputParameters == tests[i].output_count, + "Test %u: got %u output parameters.\n", i, shader_desc.OutputParameters); + + for (j = 0; j < shader_desc.InputParameters; ++j) + { + hr = reflection->lpVtbl->GetInputParameterDesc(reflection, j, &desc); + ok(hr == S_OK, "Test %u, %u: got hr %#x.\n", i, j, hr); + sprintf(prefix, "Test %u, input %u", i, j); + check_parameter_desc(prefix, &desc, &tests[i].inputs[j]); + } + + for (j = 0; j < shader_desc.OutputParameters; ++j) + { + hr = reflection->lpVtbl->GetOutputParameterDesc(reflection, j, &desc); + ok(hr == S_OK, "Test %u, %u: got hr %#x.\n", i, j, hr); + sprintf(prefix, "Test %u, output %u", i, j); + check_parameter_desc(prefix, &desc, &tests[i].outputs[j]); + } + + ID3D10Blob_Release(code); + refcount = reflection->lpVtbl->Release(reflection); + ok(!refcount, "Got unexpected refcount %u.\n", refcount); + } +} + static BOOL load_d3dcompiler(void) { HMODULE module; @@ -760,6 +993,7 @@ START_TEST(hlsl_d3d11) }
test_reflection(); + test_semantic_reflection();
if (!(mod = LoadLibraryA("d3d11.dll"))) {
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/tests/hlsl_d3d11.c | 226 +++++++++++++++++++++++-- dlls/d3dcompiler_43/tests/hlsl_d3d9.c | 120 ++++++++++++- 2 files changed, 327 insertions(+), 19 deletions(-)
diff --git a/dlls/d3dcompiler_43/tests/hlsl_d3d11.c b/dlls/d3dcompiler_43/tests/hlsl_d3d11.c index aff75a5eafa..7a1243b9ccf 100644 --- a/dlls/d3dcompiler_43/tests/hlsl_d3d11.c +++ b/dlls/d3dcompiler_43/tests/hlsl_d3d11.c @@ -524,6 +524,126 @@ static void test_trig(void) release_test_context(&test_context); }
+static void test_sampling(void) +{ + struct test_context test_context; + ID3D11ShaderResourceView *srv; + ID3D11SamplerState *sampler; + ID3D10Blob *ps_code = NULL; + ID3D11Texture2D *texture; + unsigned int i; + struct vec4 v; + HRESULT hr; + + static const char *tests[] = + { + "sampler s;\n" + "float4 main() : COLOR\n" + "{\n" + " return tex2D(s, float2(0.5, 0.5));\n" + "}", + + "SamplerState s;\n" + "float4 main() : COLOR\n" + "{\n" + " return tex2D(s, float2(0.5, 0.5));\n" + "}", + + "sampler2D s;\n" + "float4 main() : COLOR\n" + "{\n" + " return tex2D(s, float2(0.5, 0.5));\n" + "}", + + "sampler s;\n" + "Texture2D t;\n" + "float4 main() : COLOR\n" + "{\n" + " return t.Sample(s, float2(0.5, 0.5));\n" + "}", + + "SamplerState s;\n" + "Texture2D t;\n" + "float4 main() : COLOR\n" + "{\n" + " return t.Sample(s, float2(0.5, 0.5));\n" + "}", + }; + + static const D3D11_TEXTURE2D_DESC texture_desc = + { + .Width = 2, + .Height = 2, + .MipLevels = 1, + .ArraySize = 1, + .Format = DXGI_FORMAT_R32G32B32A32_FLOAT, + .SampleDesc.Count = 1, + .Usage = D3D11_USAGE_DEFAULT, + .BindFlags = D3D11_BIND_SHADER_RESOURCE, + }; + + static const float texture_data[] = + { + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + 1.0f, 0.0f, 1.0f, 0.0f, + }; + + static const D3D11_SUBRESOURCE_DATA resource_data = {&texture_data, sizeof(texture_data) / 2}; + + static const D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc = + { + .Format = DXGI_FORMAT_R32G32B32A32_FLOAT, + .ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D, + .Texture2D.MipLevels = 1, + }; + + static const D3D11_SAMPLER_DESC sampler_desc = + { + .Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR, + .AddressU = D3D11_TEXTURE_ADDRESS_WRAP, + .AddressV = D3D11_TEXTURE_ADDRESS_WRAP, + .AddressW = D3D11_TEXTURE_ADDRESS_WRAP, + }; + + static const float red[] = {1.0f, 0.0f, 0.0f, 1.0f}; + + if (!init_test_context(&test_context)) + return; + + hr = ID3D11Device_CreateTexture2D(test_context.device, &texture_desc, &resource_data, &texture); + ok(hr == S_OK, "Failed to create texture, hr %#x.\n", hr); + hr = ID3D11Device_CreateShaderResourceView(test_context.device, (ID3D11Resource *)texture, &srv_desc, &srv); + ok(hr == S_OK, "Failed to create SRV, hr %#x.\n", hr); + ID3D11DeviceContext_PSSetShaderResources(test_context.immediate_context, 0, 1, &srv); + + hr = ID3D11Device_CreateSamplerState(test_context.device, &sampler_desc, &sampler); + ok(hr == S_OK, "Failed to create sampler, hr %#x.\n", hr); + ID3D11DeviceContext_PSSetSamplers(test_context.immediate_context, 0, 1, &sampler); + + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + ID3D11DeviceContext_ClearRenderTargetView(test_context.immediate_context, test_context.rtv, red); + todo_wine ps_code = compile_shader_flags(tests[i], "ps_4_0", D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY); + if (ps_code) + { + draw_quad(&test_context, ps_code); + + v = get_color_vec4(&test_context, 0, 0); + todo_wine ok(compare_vec4(&v, 0.25f, 0.0f, 0.25f, 0.0f, 0), + "Test %u: Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", i, v.x, v.y, v.z, v.w); + + ID3D10Blob_Release(ps_code); + } + } + + ID3D11Texture2D_Release(texture); + ID3D11SamplerState_Release(sampler); + ID3D11ShaderResourceView_Release(srv); + release_test_context(&test_context); +} + static void check_type_desc(const char *prefix, const D3D11_SHADER_TYPE_DESC *type, const D3D11_SHADER_TYPE_DESC *expect) { @@ -537,6 +657,19 @@ static void check_type_desc(const char *prefix, const D3D11_SHADER_TYPE_DESC *ty ok(!strcmp(type->Name, expect->Name), "%s: got name %s.\n", prefix, debugstr_a(type->Name)); }
+static void check_resource_binding(const char *prefix, const D3D11_SHADER_INPUT_BIND_DESC *desc, + const D3D11_SHADER_INPUT_BIND_DESC *expect) +{ + ok(!strcmp(desc->Name, expect->Name), "%s: got name %s.\n", prefix, debugstr_a(desc->Name)); + ok(desc->Type == expect->Type, "%s: got type %#x.\n", prefix, desc->Type); + ok(desc->BindPoint == expect->BindPoint, "%s: got bind point %u.\n", prefix, desc->BindPoint); + ok(desc->BindCount == expect->BindCount, "%s: got bind count %u.\n", prefix, desc->BindCount); + ok(desc->uFlags == expect->uFlags, "%s: got flags %#x.\n", prefix, desc->uFlags); + ok(desc->ReturnType == expect->ReturnType, "%s: got return type %#x.\n", prefix, desc->ReturnType); + ok(desc->Dimension == expect->Dimension, "%s: got dimension %#x.\n", prefix, desc->Dimension); + ok(desc->NumSamples == expect->NumSamples, "%s: got multisample count %u.\n", prefix, desc->NumSamples); +} + static void test_reflection(void) { ID3D11ShaderReflectionConstantBuffer *cbuffer; @@ -546,8 +679,10 @@ static void test_reflection(void) D3D11_SHADER_VARIABLE_DESC var_desc; ID3D11ShaderReflection *reflection; D3D11_SHADER_TYPE_DESC type_desc; - ID3D10Blob *vs_code = NULL; + D3D11_SHADER_DESC shader_desc; + ID3D10Blob *code = NULL; unsigned int i, j, k; + char prefix[40]; ULONG refcount; HRESULT hr;
@@ -658,14 +793,55 @@ static void test_reflection(void) {"b5", D3D_SIT_CBUFFER, 5, 1, D3D_SIF_USERPACKED}, };
- todo_wine vs_code = compile_shader(vs_source, "vs_5_0"); - if (!vs_code) + static const char ps_source[] = + "texture2D a;\n" + "sampler c {};\n" + "SamplerState d {};\n" + "sampler e\n" + "{\n" + " Texture = a;\n" + " foo = bar + 2;\n" + "};\n" + "SamplerState f\n" + "{\n" + " Texture = a;\n" + " foo = bar + 2;\n" + "};\n" + "sampler2D g;\n" + "sampler b : register(s5);\n" + "float4 main(float2 pos : texcoord) : SV_TARGET\n" + "{\n" + " return a.Sample(b, pos) + a.Sample(c, pos) + a.Sample(d, pos) + tex2D(f, pos) + tex2D(e, pos)" + " + tex2D(g, pos);\n" + "}"; + + static const D3D11_SHADER_INPUT_BIND_DESC ps_bindings[] = + { + {"c", D3D_SIT_SAMPLER, 0, 1}, + {"d", D3D_SIT_SAMPLER, 1, 1}, + {"e", D3D_SIT_SAMPLER, 2, 1}, + {"f", D3D_SIT_SAMPLER, 3, 1}, + {"g", D3D_SIT_SAMPLER, 4, 1}, + {"b", D3D_SIT_SAMPLER, 5, 1, D3D_SIF_USERPACKED}, + {"f", D3D_SIT_TEXTURE, 0, 1, D3D_SIF_TEXTURE_COMPONENTS, D3D_RETURN_TYPE_FLOAT, D3D_SRV_DIMENSION_TEXTURE2D, ~0u}, + {"e", D3D_SIT_TEXTURE, 1, 1, D3D_SIF_TEXTURE_COMPONENTS, D3D_RETURN_TYPE_FLOAT, D3D_SRV_DIMENSION_TEXTURE2D, ~0u}, + {"g", D3D_SIT_TEXTURE, 2, 1, D3D_SIF_TEXTURE_COMPONENTS, D3D_RETURN_TYPE_FLOAT, D3D_SRV_DIMENSION_TEXTURE2D, ~0u}, + {"a", D3D_SIT_TEXTURE, 3, 1, D3D_SIF_TEXTURE_COMPONENTS, D3D_RETURN_TYPE_FLOAT, D3D_SRV_DIMENSION_TEXTURE2D, ~0u}, + }; + + todo_wine code = compile_shader(vs_source, "vs_5_0"); + if (!code) return;
- hr = pD3DReflect(ID3D10Blob_GetBufferPointer(vs_code), ID3D10Blob_GetBufferSize(vs_code), + hr = pD3DReflect(ID3D10Blob_GetBufferPointer(code), ID3D10Blob_GetBufferSize(code), &IID_ID3D11ShaderReflection, (void **)&reflection); ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = reflection->lpVtbl->GetDesc(reflection, &shader_desc); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(shader_desc.ConstantBuffers == ARRAY_SIZE(vs_buffers), "Got %u buffers.\n", shader_desc.ConstantBuffers); + ok(shader_desc.BoundResources == ARRAY_SIZE(vs_bindings), "Got %u resources.\n", shader_desc.BoundResources); + for (i = 0; i < ARRAY_SIZE(vs_buffers); ++i) { cbuffer = reflection->lpVtbl->GetConstantBufferByIndex(reflection, i); @@ -682,7 +858,6 @@ static void test_reflection(void) for (j = 0; j < buffer_desc.Variables; ++j) { const struct shader_variable *expect = &vs_buffers[i].vars[j]; - char prefix[40];
var = cbuffer->lpVtbl->GetVariableByIndex(cbuffer, j); hr = var->lpVtbl->GetDesc(var, &var_desc); @@ -717,20 +892,36 @@ static void test_reflection(void) D3D11_SHADER_INPUT_BIND_DESC desc;
hr = reflection->lpVtbl->GetResourceBindingDesc(reflection, i, &desc); - todo_wine ok(hr == S_OK, "Test %u: got hr %#x.\n", i, hr); - if (hr != S_OK) - break; - ok(!strcmp(desc.Name, vs_bindings[i].Name), "Test %u: got name %s.\n", i, debugstr_a(desc.Name)); - ok(desc.Type == vs_bindings[i].Type, "Test %u: got type %#x.\n", i, desc.Type); - ok(desc.BindPoint == vs_bindings[i].BindPoint, "Test %u: got bind point %u.\n", i, desc.BindPoint); - ok(desc.BindCount == vs_bindings[i].BindCount, "Test %u: got bind count %u.\n", i, desc.BindCount); - ok(desc.uFlags == vs_bindings[i].uFlags, "Test %u: got flags %#x.\n", i, desc.uFlags); - ok(desc.ReturnType == vs_bindings[i].ReturnType, "Test %u: got return type %#x.\n", i, desc.ReturnType); - ok(desc.Dimension == vs_bindings[i].Dimension, "Test %u: got dimension %#x.\n", i, desc.Dimension); - ok(desc.NumSamples == vs_bindings[i].NumSamples, "Test %u: got multisample count %u.\n", i, desc.NumSamples); + ok(hr == S_OK, "Test %u: got hr %#x.\n", i, hr); + sprintf(prefix, "Test %u", i); + check_resource_binding(prefix, &desc, &vs_bindings[i]); + } + + ID3D10Blob_Release(code); + refcount = reflection->lpVtbl->Release(reflection); + ok(!refcount, "Got unexpected refcount %u.\n", refcount); + + code = compile_shader_flags(ps_source, "ps_4_0", D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY); + hr = pD3DReflect(ID3D10Blob_GetBufferPointer(code), ID3D10Blob_GetBufferSize(code), + &IID_ID3D11ShaderReflection, (void **)&reflection); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = reflection->lpVtbl->GetDesc(reflection, &shader_desc); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(!shader_desc.ConstantBuffers, "Got %u buffers.\n", shader_desc.ConstantBuffers); + ok(shader_desc.BoundResources == ARRAY_SIZE(ps_bindings), "Got %u resources.\n", shader_desc.BoundResources); + + for (i = 0; i < shader_desc.BoundResources; ++i) + { + D3D11_SHADER_INPUT_BIND_DESC desc; + + hr = reflection->lpVtbl->GetResourceBindingDesc(reflection, i, &desc); + ok(hr == S_OK, "Test %u: got hr %#x.\n", i, hr); + sprintf(prefix, "Test %u", i); + check_resource_binding(prefix, &desc, &ps_bindings[i]); }
- ID3D10Blob_Release(vs_code); + ID3D10Blob_Release(code); refcount = reflection->lpVtbl->Release(reflection); ok(!refcount, "Got unexpected refcount %u.\n", refcount); } @@ -1006,4 +1197,5 @@ START_TEST(hlsl_d3d11) test_math(); test_conditionals(); test_trig(); + test_sampling(); } diff --git a/dlls/d3dcompiler_43/tests/hlsl_d3d9.c b/dlls/d3dcompiler_43/tests/hlsl_d3d9.c index 8443406402e..87f63023c58 100644 --- a/dlls/d3dcompiler_43/tests/hlsl_d3d9.c +++ b/dlls/d3dcompiler_43/tests/hlsl_d3d9.c @@ -1054,11 +1054,98 @@ static void test_global_initializer(void) release_test_context(&test_context); }
+static void test_samplers(void) +{ + struct test_context test_context; + IDirect3DTexture9 *texture; + ID3D10Blob *ps_code = NULL; + D3DLOCKED_RECT map_desc; + unsigned int i; + struct vec4 v; + HRESULT hr; + + static const char *tests[] = + { + "sampler s;\n" + "float4 main() : COLOR\n" + "{\n" + " return tex2D(s, float2(0.5, 0.5));\n" + "}", + + "SamplerState s;\n" + "float4 main() : COLOR\n" + "{\n" + " return tex2D(s, float2(0.5, 0.5));\n" + "}", + + "sampler2D s;\n" + "float4 main() : COLOR\n" + "{\n" + " return tex2D(s, float2(0.5, 0.5));\n" + "}", + + "sampler s;\n" + "Texture2D t;\n" + "float4 main() : COLOR\n" + "{\n" + " return t.Sample(s, float2(0.5, 0.5));\n" + "}", + + "SamplerState s;\n" + "Texture2D t;\n" + "float4 main() : COLOR\n" + "{\n" + " return t.Sample(s, float2(0.5, 0.5));\n" + "}", + }; + + if (!init_test_context(&test_context)) + return; + + hr = IDirect3DDevice9_CreateTexture(test_context.device, 2, 2, 1, D3DUSAGE_DYNAMIC, + D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture, NULL); + ok(hr == D3D_OK, "Failed to create texture, hr %#x.\n", hr); + + hr = IDirect3DTexture9_LockRect(texture, 0, &map_desc, NULL, D3DLOCK_DISCARD); + ok(hr == D3D_OK, "Failed to map texture, hr %#x.\n", hr); + memset(map_desc.pBits, 0, 2 * map_desc.Pitch); + ((DWORD *)map_desc.pBits)[1] = 0x00ff00ff; + hr = IDirect3DTexture9_UnlockRect(texture, 0); + ok(hr == D3D_OK, "Failed to unmap texture, hr %#x.\n", hr); + + hr = IDirect3DDevice9_SetTexture(test_context.device, 0, (IDirect3DBaseTexture9 *)texture); + ok(hr == D3D_OK, "Failed to set texture, hr %#x.\n", hr); + hr = IDirect3DDevice9_SetSamplerState(test_context.device, 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); + ok(hr == D3D_OK, "Failed to set sampler state, hr %#x.\n", hr); + + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + hr = IDirect3DDevice9_Clear(test_context.device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(255, 0, 0), 1.0f, 0); + ok(hr == D3D_OK, "Test %u: Failed to clear, hr %#x.\n", i, hr); + todo_wine ps_code = compile_shader(tests[i], "ps_2_0"); + if (ps_code) + { + draw_quad(test_context.device, ps_code); + + v = get_color_vec4(test_context.device, 0, 0); + todo_wine ok(compare_vec4(&v, 0.25f, 0.0f, 0.25f, 0.0f, 128), + "Test %u: Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", i, v.x, v.y, v.z, v.w); + + ID3D10Blob_Release(ps_code); + } + } + + IDirect3DTexture9_Release(texture); + release_test_context(&test_context); +} + static void check_constant_desc(const char *prefix, const D3DXCONSTANT_DESC *desc, const D3DXCONSTANT_DESC *expect, BOOL nonzero_defaultvalue) { ok(!strcmp(desc->Name, expect->Name), "%s: got Name %s.\n", prefix, debugstr_a(desc->Name)); ok(desc->RegisterSet == expect->RegisterSet, "%s: got RegisterSet %#x.\n", prefix, desc->RegisterSet); + if (desc->RegisterSet == D3DXRS_SAMPLER) + ok(desc->RegisterIndex == expect->RegisterIndex, "%s: got RegisterIndex %u.\n", prefix, desc->RegisterIndex); ok(desc->RegisterCount == expect->RegisterCount, "%s: got RegisterCount %u.\n", prefix, desc->RegisterCount); ok(desc->Class == expect->Class, "%s: got Class %#x.\n", prefix, desc->Class); ok(desc->Type == expect->Type, "%s: got Type %#x.\n", prefix, desc->Type); @@ -1093,9 +1180,28 @@ static void test_constant_table(void) "uniform matrix_t i;\n" "uniform struct matrix_record j;\n" "uniform matrix<float,3,1> k;\n" - "float4 main(uniform float4 h) : COLOR\n" + "sampler l : register(s5);\n" + "sampler m {};\n" + "texture dummy_texture;\n" + "sampler n\n" + "{\n" + " Texture = dummy_texture;\n" + " foo = bar + 2;\n" + "};\n" + "SamplerState o\n" + "{\n" + " Texture = dummy_texture;\n" + " foo = bar + 2;\n" + "};\n" + "texture2D p;\n" + "sampler q : register(s7);\n" + "SamplerState r : register(s8);\n" + "sampler2D s;\n" + "float4 main(uniform float4 h, sampler t, uniform sampler u) : COLOR\n" "{\n" - " return a + b + c._31 + d._31 + f.d._22 + g[e].x + h + i._33 + j.a._33 + k._31;\n" + " return b + c._31 + d._31 + f.d._22 + tex2D(l, g[e]) + tex3D(m, h.xyz) + i._33 + j.a._33 + k._31\n" + " + tex2D(n, a.xy) + tex2D(o, a.xy) + p.Sample(r, a.xy) + p.Sample(q, a.xy) + tex2D(s, a.xy)\n" + " + tex2D(t, a.xy) + tex2D(u, a.xy);\n" "}";
D3DXCONSTANTTABLE_DESC table_desc; @@ -1110,6 +1216,7 @@ static void test_constant_table(void) static const D3DXCONSTANT_DESC expect_constants[] = { {"$h", D3DXRS_FLOAT4, 0, 1, D3DXPC_VECTOR, D3DXPT_FLOAT, 1, 4, 1, 0, 16}, + {"$u", D3DXRS_SAMPLER, 10, 1, D3DXPC_OBJECT, D3DXPT_SAMPLER2D, 1, 1, 1, 0, 4}, {"a", D3DXRS_FLOAT4, 0, 1, D3DXPC_VECTOR, D3DXPT_FLOAT, 1, 4, 1, 0, 16}, {"b", D3DXRS_FLOAT4, 0, 1, D3DXPC_SCALAR, D3DXPT_FLOAT, 1, 1, 1, 0, 4}, {"c", D3DXRS_FLOAT4, 0, 1, D3DXPC_MATRIX_COLUMNS, D3DXPT_FLOAT, 3, 1, 1, 0, 12}, @@ -1120,6 +1227,14 @@ static void test_constant_table(void) {"i", D3DXRS_FLOAT4, 0, 3, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 3, 3, 1, 0, 36}, {"j", D3DXRS_FLOAT4, 0, 3, D3DXPC_STRUCT, D3DXPT_VOID, 1, 9, 1, 1, 36}, {"k", D3DXRS_FLOAT4, 0, 3, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 3, 1, 1, 0, 12}, + {"l", D3DXRS_SAMPLER, 5, 1, D3DXPC_OBJECT, D3DXPT_SAMPLER2D, 1, 1, 1, 0, 4}, + {"m", D3DXRS_SAMPLER, 2, 1, D3DXPC_OBJECT, D3DXPT_SAMPLER3D, 1, 1, 1, 0, 4}, + {"n", D3DXRS_SAMPLER, 3, 1, D3DXPC_OBJECT, D3DXPT_SAMPLER2D, 1, 1, 1, 0, 4}, + {"o", D3DXRS_SAMPLER, 4, 1, D3DXPC_OBJECT, D3DXPT_SAMPLER2D, 1, 1, 1, 0, 4}, + {"q+p", D3DXRS_SAMPLER, 0, 1, D3DXPC_OBJECT, D3DXPT_TEXTURE2D, 1, 4, 1, 0, 16}, + {"r+p", D3DXRS_SAMPLER, 1, 1, D3DXPC_OBJECT, D3DXPT_TEXTURE2D, 1, 4, 1, 0, 16}, + {"s", D3DXRS_SAMPLER, 6, 1, D3DXPC_OBJECT, D3DXPT_SAMPLER2D, 1, 1, 1, 0, 4}, + {"t", D3DXRS_SAMPLER, 9, 1, D3DXPC_OBJECT, D3DXPT_SAMPLER2D, 1, 1, 1, 0, 4}, };
static const D3DXCONSTANT_DESC expect_fields_f[] = @@ -1604,6 +1719,7 @@ START_TEST(hlsl_d3d9) test_struct_assignment(); test_struct_semantics(); test_global_initializer(); + test_samplers();
test_constant_table(); test_fail();
Signed-off-by: Matteo Bruni mbruni@codeweavers.com