[PATCH 2/2] d3dcompiler/tests: Make test_reflection_constant_buffer() work on d3d10.

Matteo Bruni mbruni at codeweavers.com
Fri Feb 14 12:31:04 CST 2020


Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
---
 dlls/d3dcompiler_43/tests/reflection.c | 147 ++++++++++++++++++++++---
 1 file changed, 131 insertions(+), 16 deletions(-)

diff --git a/dlls/d3dcompiler_43/tests/reflection.c b/dlls/d3dcompiler_43/tests/reflection.c
index 44e66044ec1..aa691ff762a 100644
--- a/dlls/d3dcompiler_43/tests/reflection.c
+++ b/dlls/d3dcompiler_43/tests/reflection.c
@@ -1307,7 +1307,8 @@ static const D3D11_SHADER_BUFFER_DESC test_reflection_constant_buffer_cb_result[
     {"c1", D3D_CT_CBUFFER, 4, 64, 0},
 };
 
-static const struct {
+static const struct
+{
     D3D11_SHADER_VARIABLE_DESC desc;
     unsigned int type;
 } test_reflection_constant_buffer_variable_result[] =
@@ -1319,6 +1320,104 @@ static const struct {
     {{"t", 48, 8, 2, 0}, 4},
 };
 
+#else
+/*
+ * fxc.exe /E PS /Tps_4_0 /Fx
+ */
+#if 0
+cbuffer c1
+{
+    float a;
+    float b[2];
+    int i;
+    struct s {
+        float a;
+        float b;
+    } t;
+};
+
+class cTest
+{
+    bool m_on;
+    float4 test(float2 vec);
+};
+
+float4 cTest::test(float2 vec)
+{
+    float4 res;
+    if(m_on)
+        res = float4(vec.x, vec.y, vec.x+vec.y, 0);
+    else
+        res = 0;
+    return res;
+}
+
+cTest g_Test;
+
+
+float4 PS(float2 uv : TEXCOORD0) : sv_target
+{
+    float4 q = g_Test.test(uv);
+    q.x = q.x + t.a;
+    return q;
+}
+#endif
+static DWORD test_reflection_constant_buffer_blob[] = {
+0x43425844, 0x0241ca0a, 0xa3bf8da0, 0xdd5f853e, 0xfe868252, 0x00000001, 0x00000414, 0x00000005,
+0x00000034, 0x00000230, 0x00000264, 0x00000298, 0x00000398, 0x46454452, 0x000001f4, 0x00000002,
+0x00000068, 0x00000002, 0x0000001c, 0xffff0400, 0x00000100, 0x000001c0, 0x0000005c, 0x00000000,
+0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000065, 0x00000000,
+0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000000, 0x6f6c4724, 0x736c6162,
+0x00316300, 0x0000005c, 0x00000001, 0x00000098, 0x00000010, 0x00000000, 0x00000000, 0x00000065,
+0x00000004, 0x000000e8, 0x00000040, 0x00000000, 0x00000000, 0x000000b0, 0x00000000, 0x00000004,
+0x00000002, 0x000000d8, 0x00000000, 0x65545f67, 0x6d007473, 0x006e6f5f, 0x00010000, 0x00010001,
+0x00000000, 0x00000000, 0x000000b7, 0x000000bc, 0x00000000, 0x00000005, 0x00010001, 0x00010000,
+0x000000cc, 0x00000148, 0x00000000, 0x00000004, 0x00000000, 0x0000014c, 0x00000000, 0x0000015c,
+0x00000010, 0x00000014, 0x00000000, 0x00000160, 0x00000000, 0x00000170, 0x00000024, 0x00000004,
+0x00000000, 0x00000174, 0x00000000, 0x00000184, 0x00000030, 0x00000008, 0x00000002, 0x000001b0,
+0x00000000, 0xabab0061, 0x00030000, 0x00010001, 0x00000000, 0x00000000, 0xabab0062, 0x00030000,
+0x00010001, 0x00000002, 0x00000000, 0xabab0069, 0x00020000, 0x00010001, 0x00000000, 0x00000000,
+0xabab0074, 0x00030000, 0x00010001, 0x00000000, 0x00000000, 0x00000148, 0x00000188, 0x00000000,
+0x0000015c, 0x00000188, 0x00000004, 0x00000005, 0x00020001, 0x00020000, 0x00000198, 0x7263694d,
+0x666f736f, 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x39207265,
+0x2e39322e, 0x2e323539, 0x31313133, 0xababab00, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008,
+0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000303, 0x43584554, 0x44524f4f,
+0xababab00, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
+0x00000003, 0x00000000, 0x0000000f, 0x745f7673, 0x65677261, 0xabab0074, 0x52444853, 0x000000f8,
+0x00000040, 0x0000003e, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04000059, 0x00208e46,
+0x00000001, 0x00000004, 0x03001062, 0x00101032, 0x00000000, 0x03000065, 0x001020f2, 0x00000000,
+0x02000068, 0x00000001, 0x07000000, 0x00100042, 0x00000000, 0x0010101a, 0x00000000, 0x0010100a,
+0x00000000, 0x05000036, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x05000036, 0x00100082,
+0x00000000, 0x00004001, 0x00000000, 0x0d000037, 0x001000f2, 0x00000000, 0x00208006, 0x00000000,
+0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+0x08000000, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x0020800a, 0x00000001, 0x00000003,
+0x05000036, 0x001020e2, 0x00000000, 0x00100e56, 0x00000000, 0x0100003e, 0x54415453, 0x00000074,
+0x00000007, 0x00000001, 0x00000000, 0x00000002, 0x00000002, 0x00000000, 0x00000000, 0x00000001,
+0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000000, 0x00000000, 0x00000000,
+0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+};
+
+static const D3D11_SHADER_BUFFER_DESC test_reflection_constant_buffer_cb_result[] =
+{
+    {"$Globals", D3D_CT_CBUFFER, 1, 16, 0},
+    {"c1", D3D_CT_CBUFFER, 4, 64, 0},
+};
+
+static const struct
+{
+    D3D11_SHADER_VARIABLE_DESC desc;
+    unsigned int type;
+} test_reflection_constant_buffer_variable_result[] =
+{
+    {{"a", 0, 4, 0, 0}, 1},
+    {{"b", 16, 20, 0, 0}, 2},
+    {{"i", 36, 4, 0, 0}, 3},
+    {{"t", 48, 8, 2, 0}, 4},
+};
+
+#endif
+
 static const D3D11_SHADER_TYPE_DESC test_reflection_constant_buffer_type_result[] =
 {
     {D3D11_SVC_INTERFACE_POINTER, D3D11_SVT_INTERFACE_POINTER, 1, 4, 0, 1, 0, "iTest"},
@@ -1343,7 +1442,7 @@ static void test_reflection_constant_buffer(void)
     const D3D11_SHADER_BUFFER_DESC *pcbdesc;
     const D3D11_SHADER_VARIABLE_DESC *pvdesc;
     const D3D11_SHADER_TYPE_DESC *ptdesc;
-    unsigned int i;
+    unsigned int i, expected;
     LPCSTR string;
 
     hr = call_reflect(test_reflection_constant_buffer_blob, test_reflection_constant_buffer_blob[6],
@@ -1353,15 +1452,19 @@ static void test_reflection_constant_buffer(void)
     hr = ref11->lpVtbl->GetDesc(ref11, &sdesc);
     ok(hr == S_OK, "GetDesc failed %x\n", hr);
 
-    ok(sdesc.Version == 80, "GetDesc failed, got %u, expected %u\n", sdesc.Version, 80);
+    expected = D3D_COMPILER_VERSION ? 80 : 64;
+    ok(sdesc.Version == expected, "Got unexpected version %u.\n", sdesc.Version);
     ok(strcmp(sdesc.Creator, (char*) shader_creator) == 0, "GetDesc failed, got \"%s\", expected \"%s\"\n", sdesc.Creator, (char*)shader_creator);
     ok(sdesc.Flags == 256, "GetDesc failed, got %u, expected %u\n", sdesc.Flags, 256);
     ok(sdesc.ConstantBuffers == 2, "GetDesc failed, got %u, expected %u\n", sdesc.ConstantBuffers, 2);
-    ok(sdesc.BoundResources == 1, "GetDesc failed, got %u, expected %u\n", sdesc.BoundResources, 1);
+    expected = D3D_COMPILER_VERSION ? 1 : 2;
+    ok(sdesc.BoundResources == expected, "Got unexpected BoundResources %u.\n", sdesc.BoundResources);
     ok(sdesc.InputParameters == 1, "GetDesc failed, got %u, expected %u\n", sdesc.InputParameters, 1);
     ok(sdesc.OutputParameters == 1, "GetDesc failed, got %u, expected %u\n", sdesc.OutputParameters, 1);
-    ok(sdesc.InstructionCount == 8, "GetDesc failed, got %u, expected %u\n", sdesc.InstructionCount, 8);
-    ok(sdesc.TempRegisterCount == 2, "GetDesc failed, got %u, expected %u\n", sdesc.TempRegisterCount, 2);
+    expected = D3D_COMPILER_VERSION ? 8 : 7;
+    ok(sdesc.InstructionCount == expected, "Got unexpected InstructionCount %u.\n", sdesc.InstructionCount);
+    expected = D3D_COMPILER_VERSION ? 2 : 1;
+    ok(sdesc.TempRegisterCount == expected, "Got unexpected TempRegisterCount %u.\n", sdesc.TempRegisterCount);
     ok(sdesc.TempArrayCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc.TempArrayCount, 0);
     ok(sdesc.DefCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc.DefCount, 0);
     ok(sdesc.DclCount == 2, "GetDesc failed, got %u, expected %u\n", sdesc.DclCount, 2);
@@ -1372,7 +1475,9 @@ static void test_reflection_constant_buffer(void)
     ok(sdesc.TextureGradientInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc.TextureGradientInstructions, 0);
     ok(sdesc.FloatInstructionCount == 2, "GetDesc failed, got %u, expected %u\n", sdesc.FloatInstructionCount, 2);
     ok(sdesc.IntInstructionCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc.IntInstructionCount, 0);
-    ok(sdesc.UintInstructionCount == 1, "GetDesc failed, got %u, expected %u\n", sdesc.UintInstructionCount, 1);
+    expected = D3D_COMPILER_VERSION ? 1 : 0;
+    ok(sdesc.UintInstructionCount == expected, "Got unexpected UintInstructionCount %u.\n",
+            sdesc.UintInstructionCount);
     ok(sdesc.StaticFlowControlCount == 1, "GetDesc failed, got %u, expected %u\n", sdesc.StaticFlowControlCount, 1);
     ok(sdesc.DynamicFlowControlCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc.DynamicFlowControlCount, 0);
     ok(sdesc.MacroInstructionCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc.MacroInstructionCount, 0);
@@ -1419,6 +1524,7 @@ static void test_reflection_constant_buffer(void)
     cb11 = ref11->lpVtbl->GetConstantBufferByName(ref11, NULL);
     ok(cb11_dummy == cb11, "GetConstantBufferByName failed, got %p, expected %p\n", cb11, cb11_dummy);
 
+#if D3D_COMPILER_VERSION
     v11 = ref11->lpVtbl->GetVariableByName(ref11, NULL);
     ok(v11_dummy == v11, "GetVariableByIndex failed, got %p, expected %p\n", v11, v11_dummy);
 
@@ -1427,6 +1533,7 @@ static void test_reflection_constant_buffer(void)
 
     v11 = ref11->lpVtbl->GetVariableByName(ref11, "a");
     ok(v11_valid == v11, "GetVariableByName failed, got %p, expected %p\n", v11, v11_valid);
+#endif
 
     /* constant buffer calls */
     v11 = cb11_dummy->lpVtbl->GetVariableByName(cb11_dummy, NULL);
@@ -1497,6 +1604,7 @@ static void test_reflection_constant_buffer(void)
     t11 = t11_valid->lpVtbl->GetMemberTypeByName(t11_valid, "invalid");
     ok(t11_dummy == t11, "GetMemberTypeByName failed, got %p, expected %p\n", t11, t11_dummy);
 
+#if D3D_COMPILER_VERSION
     hr = t11_dummy->lpVtbl->IsEqual(t11_dummy, t11_dummy);
     ok(hr == E_FAIL, "IsEqual failed, got %x, expected %x\n", hr, E_FAIL);
 
@@ -1508,6 +1616,7 @@ static void test_reflection_constant_buffer(void)
 
     hr = t11_valid->lpVtbl->IsEqual(t11_valid, t11_valid);
     ok(hr == S_OK, "IsEqual failed, got %x, expected %x\n", hr, S_OK);
+#endif
 
     /* constant buffers */
     for (i = 0; i < ARRAY_SIZE(test_reflection_constant_buffer_cb_result); ++i)
@@ -1537,8 +1646,11 @@ static void test_reflection_constant_buffer(void)
     {
         pvdesc = &test_reflection_constant_buffer_variable_result[i].desc;
 
-        v11 = ref11->lpVtbl->GetVariableByName(ref11, pvdesc->Name);
-        ok(v11_dummy != v11, "GetVariableByName(%u) failed\n", i);
+        if (D3D_COMPILER_VERSION)
+            v11 = ref11->lpVtbl->GetVariableByName(ref11, pvdesc->Name);
+        else
+            v11 = cb11_valid->lpVtbl->GetVariableByName(cb11_valid, pvdesc->Name);
+        ok(v11_dummy != v11, "Test %u: got unexpected variable %p.\n", i, v11);
 
         hr = v11->lpVtbl->GetDesc(v11, &vdesc);
         ok(hr == S_OK, "GetDesc(%u) failed, got %x, expected %x\n", i, hr, S_OK);
@@ -1574,13 +1686,17 @@ static void test_reflection_constant_buffer(void)
                 i, tdesc.Elements, ptdesc->Elements);
         ok(tdesc.Offset == ptdesc->Offset, "GetDesc(%u) Offset failed, got %u, expected %u\n",
                 i, tdesc.Offset, ptdesc->Offset);
-        ok(!strcmp(tdesc.Name, ptdesc->Name), "GetDesc(%u) Name failed, got %s, expected %s\n",
-                i, tdesc.Name, ptdesc->Name);
+        if (D3D_COMPILER_VERSION)
+            ok(!strcmp(tdesc.Name, ptdesc->Name), "Test %u: got unexpected Name %s.\n",
+                    i, debugstr_a(tdesc.Name));
     }
 
     /* types */
-    v11 = ref11->lpVtbl->GetVariableByName(ref11, "t");
-    ok(v11_dummy != v11, "GetVariableByName failed\n");
+    if (D3D_COMPILER_VERSION)
+        v11 = ref11->lpVtbl->GetVariableByName(ref11, "t");
+    else
+        v11 = cb11_valid->lpVtbl->GetVariableByName(cb11_valid, pvdesc->Name);
+    ok(v11_dummy != v11, "Got unexpected variable %p.\n", v11);
 
     t11 = v11->lpVtbl->GetType(v11);
     ok(t11 != t11_dummy, "GetType failed\n");
@@ -1603,6 +1719,7 @@ static void test_reflection_constant_buffer(void)
     string = t11->lpVtbl->GetMemberTypeName(t11, 1);
     ok(!strcmp(string, "b"), "GetMemberTypeName failed, got \"%s\", expected \"%s\"\n", string, "b");
 
+#if D3D_COMPILER_VERSION
     /* float vs float (in struct) */
     hr = t11->lpVtbl->IsEqual(t11, t11_valid);
     ok(hr == S_FALSE, "IsEqual failed, got %x, expected %x\n", hr, S_FALSE);
@@ -1619,11 +1736,11 @@ static void test_reflection_constant_buffer(void)
 
     hr = t->lpVtbl->IsEqual(t, t2);
     ok(hr == S_OK, "IsEqual failed, got %x, expected %x\n", hr, S_OK);
+#endif
 
     count = ref11->lpVtbl->Release(ref11);
     ok(count == 0, "Release failed %u\n", count);
 }
-#endif
 
 static BOOL load_d3dreflect(void)
 {
@@ -1658,7 +1775,5 @@ START_TEST(reflection)
     test_reflection_desc_ps();
     test_reflection_desc_ps_output();
     test_reflection_bound_resources();
-#if D3D_COMPILER_VERSION
     test_reflection_constant_buffer();
-#endif
 }
-- 
2.24.1




More information about the wine-devel mailing list