[PATCH 5/5] d3dx9_36/tests: Added tests for structures and arrays in constant tables

Travis Athougies iammisc at gmail.com
Tue Jul 5 16:45:04 CDT 2011


---
 dlls/d3dx9_36/tests/shader.c |  177 ++++++++++++++++++++++++++++++------------
 1 files changed, 127 insertions(+), 50 deletions(-)

diff --git a/dlls/d3dx9_36/tests/shader.c b/dlls/d3dx9_36/tests/shader.c
index 5bcd216..a2e1125 100644
--- a/dlls/d3dx9_36/tests/shader.c
+++ b/dlls/d3dx9_36/tests/shader.c
@@ -20,6 +20,12 @@
 #include "wine/test.h"
 #include "d3dx9.h"
 
+typedef struct
+{
+    const char *full_name;
+    D3DXCONSTANT_DESC d;
+} constant_test;
+
 static const DWORD simple_vs[] = {
     0xfffe0101,                                                             /* vs_1_1                       */
     0x0000001f, 0x80000000, 0x900f0000,                                     /* dcl_position0 v0             */
@@ -92,12 +98,12 @@ static const DWORD ctab_basic[] = {
     0x656e6957, 0x6f727020, 0x7463656a, 0xababab00,                         /* Creator name string          */
     0x0000ffff};                                                            /* END                          */
 
-static const D3DXCONSTANT_DESC ctab_basic_expected[] = {
-    {"mvp", D3DXRS_FLOAT4, 0, 4, D3DXPC_MATRIX_COLUMNS, D3DXPT_FLOAT, 4, 4, 1, 0, 64, 0},
-    {"i",   D3DXRS_FLOAT4, 4, 1, D3DXPC_SCALAR,         D3DXPT_INT,   1, 1, 1, 0,  4, 0},
-    {"i4",  D3DXRS_FLOAT4, 5, 1, D3DXPC_VECTOR,         D3DXPT_INT,   1, 4, 1, 0, 16, 0},
-    {"f",   D3DXRS_FLOAT4, 6, 1, D3DXPC_SCALAR,         D3DXPT_FLOAT, 1, 1, 1, 0,  4, 0},
-    {"f4",  D3DXRS_FLOAT4, 7, 1, D3DXPC_VECTOR,         D3DXPT_FLOAT, 1, 4, 1, 0, 16, 0}};
+static const constant_test ctab_basic_expected[] = {
+    {"mvp", {"mvp", D3DXRS_FLOAT4, 0, 4, D3DXPC_MATRIX_COLUMNS, D3DXPT_FLOAT, 4, 4, 1, 0, 64, 0}},
+    {"i",   {"i",   D3DXRS_FLOAT4, 4, 1, D3DXPC_SCALAR,         D3DXPT_INT,   1, 1, 1, 0,  4, 0}},
+    {"i4",  {"i4",  D3DXRS_FLOAT4, 5, 1, D3DXPC_VECTOR,         D3DXPT_INT,   1, 4, 1, 0, 16, 0}},
+    {"f",   {"f",   D3DXRS_FLOAT4, 6, 1, D3DXPC_SCALAR,         D3DXPT_FLOAT, 1, 1, 1, 0,  4, 0}},
+    {"f4",  {"f4",  D3DXRS_FLOAT4, 7, 1, D3DXPC_VECTOR,         D3DXPT_FLOAT, 1, 4, 1, 0, 16, 0}}};
 
 static const DWORD ctab_matrices[] = {
     0xfffe0300,                                                             /* vs_3_0                       */
@@ -117,10 +123,10 @@ static const DWORD ctab_matrices[] = {
     0x656e6957, 0x6f727020, 0x7463656a, 0xababab00,                         /* Creator name string          */
     0x0000ffff};                                                            /* END                          */
 
-static const D3DXCONSTANT_DESC ctab_matrices_expected[] = {
-    {"fmatrix4x4", D3DXRS_FLOAT4, 0, 4, D3DXPC_MATRIX_COLUMNS, D3DXPT_FLOAT, 4, 4, 1, 0, 64, 0},
-    {"imatrix2x3", D3DXRS_FLOAT4, 4, 3, D3DXPC_MATRIX_ROWS,    D3DXPT_INT,   2, 3, 1, 0, 24, 0},
-    {"fmatrix3x1", D3DXRS_FLOAT4, 7, 1, D3DXPC_MATRIX_COLUMNS, D3DXPT_FLOAT, 3, 1, 1, 0, 12, 0}};
+static const constant_test ctab_matrices_expected[] = {
+    {"fmatrix4x4", {"fmatrix4x4", D3DXRS_FLOAT4, 0, 4, D3DXPC_MATRIX_COLUMNS, D3DXPT_FLOAT, 4, 4, 1, 0, 64, 0}},
+    {"imatrix2x3", {"imatrix2x3", D3DXRS_FLOAT4, 4, 3, D3DXPC_MATRIX_ROWS,    D3DXPT_INT,   2, 3, 1, 0, 24, 0}},
+    {"fmatrix3x1", {"fmatrix3x1", D3DXRS_FLOAT4, 7, 1, D3DXPC_MATRIX_COLUMNS, D3DXPT_FLOAT, 3, 1, 1, 0, 12, 0}}};
 
 static const DWORD ctab_arrays[] = {
     0xfffe0300,                                                             /* vs_3_0                       */
@@ -149,13 +155,13 @@ static const DWORD ctab_arrays[] = {
     0x656e6957, 0x6f727020, 0x7463656a, 0xababab00,                         /* Creator name string          */
     0x0000ffff};                                                            /* END                          */
 
-static const D3DXCONSTANT_DESC ctab_arrays_expected[] = {
-    {"fmtxarray", D3DXRS_FLOAT4,  0, 8, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 4, 4, 2, 0, 128, 0},
-    {"farray",    D3DXRS_FLOAT4,  8, 4, D3DXPC_SCALAR,      D3DXPT_FLOAT, 1, 1, 4, 0,  16, 0},
-    {"fvecarray", D3DXRS_FLOAT4, 12, 2, D3DXPC_VECTOR,      D3DXPT_FLOAT, 1, 4, 2, 0,  32, 0},
-    {"barray",    D3DXRS_FLOAT4, 14, 2, D3DXPC_SCALAR,      D3DXPT_BOOL,  1, 1, 2, 0,   8, 0},
-    {"bvecarray", D3DXRS_FLOAT4, 16, 2, D3DXPC_VECTOR,      D3DXPT_BOOL,  1, 3, 3, 0,  36, 0},
-    {"ivecarray", D3DXRS_FLOAT4, 18, 1, D3DXPC_VECTOR,      D3DXPT_INT,   1, 4, 1, 0,  16, 0}};
+static const constant_test ctab_arrays_expected[] = {
+    {"fmtxarray", {"fmtxarray", D3DXRS_FLOAT4,  0, 8, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 4, 4, 2, 0, 128, 0}},
+    {"farray",    {"farray",    D3DXRS_FLOAT4,  8, 4, D3DXPC_SCALAR,      D3DXPT_FLOAT, 1, 1, 4, 0,  16, 0}},
+    {"fvecarray", {"fvecarray", D3DXRS_FLOAT4, 12, 2, D3DXPC_VECTOR,      D3DXPT_FLOAT, 1, 4, 2, 0,  32, 0}},
+    {"barray",    {"barray",    D3DXRS_FLOAT4, 14, 2, D3DXPC_SCALAR,      D3DXPT_BOOL,  1, 1, 2, 0,   8, 0}},
+    {"bvecarray", {"bvecarray", D3DXRS_FLOAT4, 16, 2, D3DXPC_VECTOR,      D3DXPT_BOOL,  1, 3, 3, 0,  36, 0}},
+    {"ivecarray", {"ivecarray", D3DXRS_FLOAT4, 18, 1, D3DXPC_VECTOR,      D3DXPT_INT,   1, 4, 1, 0,  16, 0}}};
 
 static const DWORD ctab_samplers[] = {
     0xfffe0300,                                                             /* vs_3_0                        */
@@ -175,10 +181,79 @@ static const DWORD ctab_samplers[] = {
     0x656e6957, 0x6f727020, 0x7463656a, 0xababab00,                         /* Creator name string           */
     0x0000ffff};                                                            /* END                           */
 
-static const D3DXCONSTANT_DESC ctab_samplers_expected[] = {
-    {"sampler1",   D3DXRS_SAMPLER, 0, 1, D3DXPC_OBJECT, D3DXPT_SAMPLER2D, 1, 1, 1, 0, 4,  0},
-    {"sampler2",   D3DXRS_SAMPLER, 3, 1, D3DXPC_OBJECT, D3DXPT_SAMPLER3D, 1, 1, 1, 0, 4,  0},
-    {"notsampler", D3DXRS_FLOAT4,  2, 1, D3DXPC_VECTOR, D3DXPT_FLOAT,     1, 4, 1, 0, 16, 0}};
+static const constant_test ctab_samplers_expected[] = {
+    {"sampler1",   {"sampler1",   D3DXRS_SAMPLER, 0, 1, D3DXPC_OBJECT, D3DXPT_SAMPLER2D, 1, 1, 1, 0, 4,  0}},
+    {"sampler2",   {"sampler2",   D3DXRS_SAMPLER, 3, 1, D3DXPC_OBJECT, D3DXPT_SAMPLER3D, 1, 1, 1, 0, 4,  0}},
+    {"notsampler", {"notsampler", D3DXRS_FLOAT4,  2, 1, D3DXPC_VECTOR, D3DXPT_FLOAT,     1, 4, 1, 0, 16, 0}}};
+
+static const DWORD ctab_structs[] = {
+    0xfffe0300,                                                             /* vs_3_0                        */
+    0x005ffffe, FCC_CTAB,                                                   /* CTAB comment                  */
+    0x0000001c, 0x00000168, 0xfffe0300, 0x00000004, 0x0000001c, 0x20008100, /* Header                        */
+    0x00000160,
+    0x00000100, 0x00100002, 0x00000005, 0x00000134, 0x00000000,             /* Constant 1 desc (arystruct1)  */
+    0x00000144, 0x00150002, 0x00000014, 0x00000150, 0x00000000,             /* Constant 2 desc (arystruct2)  */
+    0x0000006c, 0x00000002, 0x00000004, 0x000000d4, 0x00000000,             /* Constant 3 desc (struct1)     */
+    0x000000e4, 0x00040002, 0x0000000C, 0x000000f0, 0x00000000,             /* Constant 4 desc (struct1ary)  */
+
+    0x75727473, 0x00317463,                                                 /* Constant 3 name               */
+    0xab003166, 0x00030000, 0x00010001, 0x00000001, 0x00000000, 0xab003266, /* 'f1'; f1, f2 type desc; 'f2'  */
+    0xab003169, 0x00020000, 0x00010001, 0x00000001, 0x00000000,             /* 'i1'; i1 type desc            */
+    0xab003176, 0x00030001, 0x00040001, 0x00000001, 0x00000000,             /* 'v1'; v1 type desc            */
+    0x00000074, 0x00000078, 0x00000088, 0x00000078,                         /* f1, f2 struct member info     */
+    0x0000008c, 0x00000090, 0x000000a0, 0x000000a4,                         /* i1, v1 struct member info     */
+    0x00000005, 0x00010001, 0x00040001, 0x000000b4,                         /* Constant 3 type desc          */
+
+    0x75727473, 0x61317463, 0xab007972,                                     /* Constant 4 name               */
+    0x00000005, 0x00010001, 0x00040003, 0x000000b4,                         /* Constant 4 type desc          */
+
+    0x73797261, 0x63757274, 0xab003174,                                     /* Constant 1 name               */
+    0x72726176, 0x00317961, 0x00020001, 0x00040001, 0x00000004, 0x00000000, /* 'varray1'; varray type desc   */
+    0x0000010c, 0x00000114, 0x000000a0, 0x000000a4,                         /* varray1, v1 struct member info*/
+    0x00000005, 0x00010001, 0x00020001, 0x00000124,                         /* Constant 1 type desc          */
+
+    0x73797261, 0x63757274, 0xab003274,                                     /* Constant 2 name               */
+    0x00000005, 0x00010001, 0x00020004, 0x00000124,                         /* Constant 2 type desc          */
+
+    0x335f7376, 0xab00305f,                                                 /* Target name string            */
+    0x656e6957, 0x6f727020, 0x7463656a, 0xababab00,                         /* Creator name string           */
+    0x0000ffff};                                                            /* END                           */
+
+static const constant_test ctab_structs_expected[] = {
+    {"struct1",          {"struct1",    D3DXRS_FLOAT4,  0,  4, D3DXPC_STRUCT, D3DXPT_VOID,  1, 1, 1, 4,  4, 0}},
+    {"struct1ary",       {"struct1ary", D3DXRS_FLOAT4,  4, 12, D3DXPC_STRUCT, D3DXPT_VOID,  1, 1, 3, 4, 12, 0}},
+    {"arystruct1",       {"arystruct1", D3DXRS_FLOAT4, 16,  5, D3DXPC_STRUCT, D3DXPT_VOID,  1, 1, 1, 2,  4, 0}},
+    {"arystruct2",       {"arystruct2", D3DXRS_FLOAT4, 21, 20, D3DXPC_STRUCT, D3DXPT_VOID,  1, 1, 4, 2, 16, 0}},
+
+    /* struct1 members */
+    {"struct1.f1",       {"f1",         D3DXRS_FLOAT4,  0,  1, D3DXPC_SCALAR, D3DXPT_FLOAT, 1, 1, 1, 0,  4, 0}},
+    {"struct1.f2",       {"f2",         D3DXRS_FLOAT4,  1,  1, D3DXPC_SCALAR, D3DXPT_FLOAT, 1, 1, 1, 0,  4, 0}},
+    {"struct1.i1",       {"i1",         D3DXRS_FLOAT4,  2,  1, D3DXPC_SCALAR, D3DXPT_INT,   1, 1, 1, 0,  4, 0}},
+    {"struct1.v1",       {"v1",         D3DXRS_FLOAT4,  3,  1, D3DXPC_VECTOR, D3DXPT_FLOAT, 1, 4, 1, 0, 16, 0}},
+
+    /* struct1ary elements */
+    {"struct1ary[0]",    {"struct1ary", D3DXRS_FLOAT4,  4,  4, D3DXPC_STRUCT, D3DXPT_VOID,  1, 1, 1, 4,  4, 0}},
+    {"struct1ary[1]",    {"struct1ary", D3DXRS_FLOAT4,  8,  4, D3DXPC_STRUCT, D3DXPT_VOID,  1, 1, 1, 4,  4, 0}},
+    {"struct1ary[2]",    {"struct1ary", D3DXRS_FLOAT4, 12,  4, D3DXPC_STRUCT, D3DXPT_VOID,  1, 1, 1, 4,  4, 0}},
+
+    /* struct1ary[0] members */
+    {"struct1ary[0].f1", {"f1",         D3DXRS_FLOAT4,  4,  1, D3DXPC_SCALAR, D3DXPT_FLOAT, 1, 1, 1, 0,  4, 0}},
+    {"struct1ary[0].f2", {"f2",         D3DXRS_FLOAT4,  5,  1, D3DXPC_SCALAR, D3DXPT_FLOAT, 1, 1, 1, 0,  4, 0}},
+    {"struct1ary[0].i1", {"i1",         D3DXRS_FLOAT4,  6,  1, D3DXPC_SCALAR, D3DXPT_INT,   1, 1, 1, 0,  4, 0}},
+    {"struct1ary[0].v1", {"v1",         D3DXRS_FLOAT4,  7,  1, D3DXPC_VECTOR, D3DXPT_FLOAT, 1, 4, 1, 0, 16, 0}},
+
+    /* struct1ary[1] members */
+    {"struct1ary[1].f1", {"f1",         D3DXRS_FLOAT4,  8,  1, D3DXPC_SCALAR, D3DXPT_FLOAT, 1, 1, 1, 0,  4, 0}},
+    {"struct1ary[1].f2", {"f2",         D3DXRS_FLOAT4,  9,  1, D3DXPC_SCALAR, D3DXPT_FLOAT, 1, 1, 1, 0,  4, 0}},
+    {"struct1ary[1].i1", {"i1",         D3DXRS_FLOAT4, 10,  1, D3DXPC_SCALAR, D3DXPT_INT,   1, 1, 1, 0,  4, 0}},
+    {"struct1ary[1].v1", {"v1",         D3DXRS_FLOAT4, 11,  1, D3DXPC_VECTOR, D3DXPT_FLOAT, 1, 4, 1, 0, 16, 0}},
+
+    /* struct1ary[2] members */
+    {"struct1ary[2].f1", {"f1",         D3DXRS_FLOAT4, 12,  1, D3DXPC_SCALAR, D3DXPT_FLOAT, 1, 1, 1, 0,  4, 0}},
+    {"struct1ary[2].f2", {"f2",         D3DXRS_FLOAT4, 13,  1, D3DXPC_SCALAR, D3DXPT_FLOAT, 1, 1, 1, 0,  4, 0}},
+    {"struct1ary[2].i1", {"i1",         D3DXRS_FLOAT4, 14,  1, D3DXPC_SCALAR, D3DXPT_INT,   1, 1, 1, 0,  4, 0}},
+    {"struct1ary[2].v1", {"v1",         D3DXRS_FLOAT4, 15,  1, D3DXPC_VECTOR, D3DXPT_FLOAT, 1, 4, 1, 0, 16, 0}},
+};
 
 static void test_get_shader_size(void)
 {
@@ -373,7 +448,7 @@ static void test_get_shader_constant_table_ex(void)
 }
 
 static void test_constant_table(const char *test_name, const DWORD *ctable_fn,
-        const D3DXCONSTANT_DESC *expecteds, UINT count)
+        const constant_test *expecteds, UINT count)
 {
     UINT i;
     ID3DXConstantTable *ctable;
@@ -386,49 +461,49 @@ static void test_constant_table(const char *test_name, const DWORD *ctable_fn,
 
     for (i = 0; i < count; i++)
     {
-        const D3DXCONSTANT_DESC *expected = &expecteds[i];
+        const constant_test *expected = &expecteds[i];
         D3DXHANDLE const_handle;
         D3DXCONSTANT_DESC actual;
         UINT pCount = 1;
 
-        const_handle = ID3DXConstantTable_GetConstantByName(ctable, NULL, expected->Name);
+        const_handle = ID3DXConstantTable_GetConstantByName(ctable, NULL, expected->full_name);
 
         res = ID3DXConstantTable_GetConstantDesc(ctable, const_handle, &actual, &pCount);
-        ok(SUCCEEDED(res), "%s in %s: ID3DXConstantTable_GetConstantDesc returned %08x\n", expected->Name,
+        ok(SUCCEEDED(res), "%s in %s: ID3DXConstantTable_GetConstantDesc returned %08x\n", expected->d.Name,
                 test_name, res);
-        ok(pCount == 1, "%s in %s: Got more or less descriptions: %d\n", expected->Name, test_name, pCount);
+        ok(pCount == 1, "%s in %s: Got more or less descriptions: %d\n", expected->d.Name, test_name, pCount);
 
-        ok(strcmp(actual.Name, expected->Name) == 0,
-           "%s in %s: Got different names: Got %s, expected %s\n", expected->Name,
-           test_name, actual.Name, expected->Name);
-        ok(actual.RegisterSet == expected->RegisterSet,
+        ok(strcmp(actual.Name, expected->d.Name) == 0,
+           "%s in %s: Got different names: Got %s, expected %s\n", expected->full_name,
+           test_name, actual.Name, expected->d.Name);
+        ok(actual.RegisterSet == expected->d.RegisterSet,
            "%s in %s: Got different register sets: Got %d, expected %d\n",
-           expected->Name, test_name, actual.RegisterSet, expected->RegisterSet);
-        ok(actual.RegisterIndex == expected->RegisterIndex,
+           expected->full_name, test_name, actual.RegisterSet, expected->d.RegisterSet);
+        ok(actual.RegisterIndex == expected->d.RegisterIndex,
            "%s in %s: Got different register indices: Got %d, expected %d\n",
-           expected->Name, test_name, actual.RegisterIndex, expected->RegisterIndex);
-        ok(actual.RegisterCount == expected->RegisterCount,
+           expected->full_name, test_name, actual.RegisterIndex, expected->d.RegisterIndex);
+        ok(actual.RegisterCount == expected->d.RegisterCount,
            "%s in %s: Got different register counts: Got %d, expected %d\n",
-           expected->Name, test_name, actual.RegisterCount, expected->RegisterCount);
-        ok(actual.Class == expected->Class,
-           "%s in %s: Got different classes: Got %d, expected %d\n", expected->Name,
-           test_name, actual.Class, expected->Class);
-        ok(actual.Type == expected->Type,
-           "%s in %s: Got different types: Got %d, expected %d\n", expected->Name,
-           test_name, actual.Type, expected->Type);
-        ok(actual.Rows == expected->Rows && actual.Columns == expected->Columns,
+           expected->full_name, test_name, actual.RegisterCount, expected->d.RegisterCount);
+        ok(actual.Class == expected->d.Class,
+           "%s in %s: Got different classes: Got %d, expected %d\n", expected->full_name,
+           test_name, actual.Class, expected->d.Class);
+        ok(actual.Type == expected->d.Type,
+           "%s in %s: Got different types: Got %d, expected %d\n", expected->full_name,
+           test_name, actual.Type, expected->d.Type);
+        ok(actual.Rows == expected->d.Rows && actual.Columns == expected->d.Columns,
            "%s in %s: Got different dimensions: Got (%d, %d), expected (%d, %d)\n",
-           expected->Name, test_name, actual.Rows, actual.Columns, expected->Rows,
-           expected->Columns);
-        ok(actual.Elements == expected->Elements,
+           expected->full_name, test_name, actual.Rows, actual.Columns, expected->d.Rows,
+           expected->d.Columns);
+        ok(actual.Elements == expected->d.Elements,
            "%s in %s: Got different element count: Got %d, expected %d\n",
-           expected->Name, test_name, actual.Elements, expected->Elements);
-        ok(actual.StructMembers == expected->StructMembers,
+           expected->full_name, test_name, actual.Elements, expected->d.Elements);
+        ok(actual.StructMembers == expected->d.StructMembers,
            "%s in %s: Got different struct member count: Got %d, expected %d\n",
-           expected->Name, test_name, actual.StructMembers, expected->StructMembers);
-        ok(actual.Bytes == expected->Bytes,
+           expected->full_name, test_name, actual.StructMembers, expected->d.StructMembers);
+        ok(actual.Bytes == expected->d.Bytes,
            "%s in %s: Got different byte count: Got %d, expected %d\n",
-           expected->Name, test_name, actual.Bytes, expected->Bytes);
+           expected->full_name, test_name, actual.Bytes, expected->d.Bytes);
     }
 
     /* Finally, release the constant table */
@@ -445,6 +520,8 @@ static void test_constant_tables(void)
             sizeof(ctab_arrays_expected)/sizeof(*ctab_arrays_expected));
     test_constant_table("test_samplers", ctab_samplers, ctab_samplers_expected,
             sizeof(ctab_samplers_expected)/sizeof(*ctab_samplers_expected));
+    test_constant_table("test_structs", ctab_structs, ctab_structs_expected,
+            sizeof(ctab_structs_expected)/sizeof(*ctab_structs_expected));
 }
 
 static void test_setting_basic_table(IDirect3DDevice9 *device)
-- 
1.6.4.4




More information about the wine-patches mailing list