[d3dx9_36/tests] Add tests for ID3DXConstantTable::GetConstant and ID3DXConstantTable::GetConstantDesc

Matijn Woudt tijnema at gmail.com
Mon Jun 7 20:06:54 CDT 2010


Add tests for ID3DXConstantTable::GetConstant and
ID3DXConstantTable::GetConstantDesc
-------------- next part --------------
From aed6ca499cf2127ba0119093843d6076eb494eee Mon Sep 17 00:00:00 2001
From: Matijn Woudt <tijnema at gmail.com>
Date: Tue, 8 Jun 2010 02:55:04 +0200
Subject: [d3dx9_36/tests] Add tests for ID3DXConstantTable::GetConstant and ID3DXConstantTable::GetConstantDesc

---
 dlls/d3dx9_36/tests/shader.c |   95 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 95 insertions(+), 0 deletions(-)

diff --git a/dlls/d3dx9_36/tests/shader.c b/dlls/d3dx9_36/tests/shader.c
index 6bf0de3..ec47458 100644
--- a/dlls/d3dx9_36/tests/shader.c
+++ b/dlls/d3dx9_36/tests/shader.c
@@ -48,6 +48,21 @@ static const DWORD shader_with_ctab[] = {
     0x0004fffe, FCC_TEXT,   0x00000000, 0x00000000, 0x00000000,             /* TEXT comment                 */
     0x0000ffff};                                                            /* END                          */
 
+static const DWORD shader_with_extended_ctab[] = {
+    0xfffe0300,                                                             /* vs_3_0                       */
+    0x003dfffe, FCC_CTAB,   0x0000001c, 0x000000bf, 0xfffe0300, 0x00000003, /* CTAB comment                 */
+    0x0000001c, 0x00000100, 0x000000b8, 0x00000058, 0x00040002, 0x00120001,
+    0x0000006c, 0x00000000, 0x0000007c, 0x00020002, 0x000a0001, 0x00000084,
+    0x00000000, 0x00000094, 0x00050002, 0x00160004, 0x000000a8, 0x00000000,
+    0x6f433466, 0x6174736e, 0x6353746e, 0x72656c61, 0xabab0073, 0x00030001,
+    0x00040001, 0x00000001, 0x00000000, 0x6d695466, 0xabab0065, 0x00030000,
+    0x00010001, 0x00000001, 0x00000000, 0x5678746d, 0x50776569, 0x656a6f72,
+    0x6f697463, 0xabab006e, 0x00030003, 0x00040004, 0x00000001, 0x00000000,
+    0x335f7376, 0x4d00305f, 0x6f726369, 0x74666f73, 0x29522820, 0x534c4820,
+    0x6853204c, 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e392072, 0x392e3732,
+    0x332e3235, 0x00323230,
+    0x0000ffff};                                                            /* END                          */
+
 static const DWORD shader_with_invalid_ctab[] = {
     0xfffe0300,                                                             /* vs_3_0                       */
     0x0005fffe, FCC_CTAB,                                                   /* CTAB comment                 */
@@ -121,6 +136,9 @@ static void test_get_shader_constant_table_ex(void)
     LPVOID data;
     DWORD size;
     D3DXCONSTANTTABLE_DESC desc;
+    D3DXCONSTANT_DESC const_desc;
+    D3DXHANDLE constant;
+    UINT const_size;
 
     hr = D3DXGetShaderConstantTableEx(NULL, 0, &constant_table);
     ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
@@ -156,6 +174,83 @@ static void test_get_shader_constant_table_ex(void)
 
         ID3DXConstantTable_Release(constant_table);
     }
+
+    hr = D3DXGetShaderConstantTableEx(shader_with_extended_ctab, 0, &constant_table);
+    ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n", hr);
+
+    if (constant_table)
+    {
+        size = ID3DXConstantTable_GetBufferSize(constant_table);
+        ok(size == 0xF0, "Got result %x, expected 0xF0\n", size);
+
+        data = ID3DXConstantTable_GetBufferPointer(constant_table);
+        ok(!memcmp(data, shader_with_extended_ctab + 3, size), "Retrieved wrong CTAB data\n");
+
+        hr = ID3DXConstantTable_GetDesc(constant_table, NULL);
+        ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
+
+        hr = ID3DXConstantTable_GetDesc(constant_table, &desc);
+        ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n", hr);
+        ok(desc.Creator == (LPCSTR)data + 0xBF, "Got result %p, expected %p\n", desc.Creator, (LPCSTR)data + 0xBF);
+        ok(desc.Version == D3DVS_VERSION(3, 0), "Got result %x, expected %x\n", desc.Version, D3DVS_VERSION(3, 0));
+        ok(desc.Constants == 3, "Got result %x, expected 3\n", desc.Constants);
+
+        constant = ID3DXConstantTable_GetConstant(constant_table, NULL, 0);
+        const_size = 1;
+        hr = ID3DXConstantTable_GetConstantDesc(constant_table, constant, &const_desc, &const_size);
+        todo_wine ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n", hr);
+        ok(const_size == 1, "Got size %x, expected 1\n", const_size);
+        todo_wine ok(const_desc.Name == (LPCSTR)data + 0x58, "Got result %p, expected %p\n", const_desc.Name, (LPCSTR)data + 0x58);
+        todo_wine ok(const_desc.RegisterSet == D3DXRS_FLOAT4, "Got result %x, expected %x (D3DXRS_FLOAT4)\n", const_desc.RegisterSet, D3DXRS_FLOAT4);
+        todo_wine ok(const_desc.RegisterIndex == 4, "Got result %x, expected 4\n", const_desc.RegisterIndex);
+        todo_wine ok(const_desc.RegisterCount == 1, "Got result %x, expected 4\n", const_desc.RegisterCount);
+        todo_wine ok(const_desc.Class == D3DXPC_VECTOR, "Got result %x, expected %x (D3DXPC_VECTOR)\n", const_desc.Class, D3DXPC_VECTOR);
+        todo_wine ok(const_desc.Type == D3DXPT_FLOAT, "Got result %x, expected %x (D3DXPT_FLOAT)\n", const_desc.Type, D3DXPT_FLOAT);
+        todo_wine ok(const_desc.Rows == 1, "Got result %x, expected 1\n", const_desc.Rows);
+        todo_wine ok(const_desc.Columns == 4, "Got result %x, expected 4\n", const_desc.Columns);
+        todo_wine ok(const_desc.Elements == 1, "Got result %x, expected 1\n", const_desc.Elements);
+        todo_wine ok(const_desc.StructMembers == 0, "Got result %x, expected 0\n", const_desc.StructMembers);
+        todo_wine ok(const_desc.Bytes == 16, "Got result %x, expected 16\n", const_desc.Bytes);
+        ok(const_desc.DefaultValue == NULL, "Got result %p, expected NULL\n", const_desc.DefaultValue);
+
+        constant = ID3DXConstantTable_GetConstant(constant_table, NULL, 1);
+        const_size = 1;
+        hr = ID3DXConstantTable_GetConstantDesc(constant_table, constant, &const_desc, &const_size);
+        todo_wine ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n", hr);
+        ok(const_size == 1, "Got size %x, expected 1\n", const_size);
+        todo_wine ok(const_desc.Name == (LPCSTR)data + 0x7C, "Got result %p, expected %p\n", const_desc.Name, (LPCSTR)data + 0x7C);
+        todo_wine ok(const_desc.RegisterSet == D3DXRS_FLOAT4, "Got result %x, expected %x (D3DXRS_FLOAT4)\n", const_desc.RegisterSet, D3DXRS_FLOAT4);
+        todo_wine ok(const_desc.RegisterIndex == 2, "Got result %x, expected 2\n", const_desc.RegisterIndex);
+        todo_wine ok(const_desc.RegisterCount == 1, "Got result %x, expected 4\n", const_desc.RegisterCount);
+        todo_wine ok(const_desc.Class == D3DXPC_SCALAR, "Got result %x, expected %x (D3DXPC_SCALAR)\n", const_desc.Class, D3DXPC_SCALAR);
+        todo_wine ok(const_desc.Type == D3DXPT_FLOAT, "Got result %x, expected %x (D3DXPT_FLOAT)\n", const_desc.Type, D3DXPT_FLOAT);
+        todo_wine ok(const_desc.Rows == 1, "Got result %x, expected 1\n", const_desc.Rows);
+        todo_wine ok(const_desc.Columns == 1, "Got result %x, expected 1\n", const_desc.Columns);
+        todo_wine ok(const_desc.Elements == 1, "Got result %x, expected 1\n", const_desc.Elements);
+        todo_wine ok(const_desc.StructMembers == 0, "Got result %x, expected 0\n", const_desc.StructMembers);
+        todo_wine ok(const_desc.Bytes == 4, "Got result %x, expected 4\n", const_desc.Bytes);
+        ok(const_desc.DefaultValue == NULL, "Got result %p, expected NULL\n", const_desc.DefaultValue);
+
+        constant = ID3DXConstantTable_GetConstant(constant_table, NULL, 2);
+        const_size = 1;
+        hr = ID3DXConstantTable_GetConstantDesc(constant_table, constant, &const_desc, &const_size);
+        todo_wine ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n", hr);
+        ok(const_size == 1, "Got size %x, expected 1\n", const_size);
+        todo_wine ok(const_desc.Name == (LPCSTR)data + 0x94, "Got result %p, expected %p\n", const_desc.Name, (LPCSTR)data + 0x94);
+        todo_wine ok(const_desc.RegisterSet == D3DXRS_FLOAT4, "Got result %x, expected %x (D3DXRS_FLOAT4)\n", const_desc.RegisterSet, D3DXRS_FLOAT4);
+        todo_wine ok(const_desc.RegisterIndex == 5, "Got result %x, expected 5\n", const_desc.RegisterIndex);
+        todo_wine ok(const_desc.RegisterCount == 4, "Got result %x, expected 4\n", const_desc.RegisterCount);
+        todo_wine ok(const_desc.Class == D3DXPC_MATRIX_COLUMNS, "Got result %x, expected %x (D3DXPC_MATRIX_COLUMNS)\n", const_desc.Class, D3DXPC_MATRIX_COLUMNS);
+        todo_wine ok(const_desc.Type == D3DXPT_FLOAT, "Got result %x, expected %x (D3DXPT_FLOAT)\n", const_desc.Type, D3DXPT_FLOAT);
+        todo_wine ok(const_desc.Rows == 4, "Got result %x, expected 4\n", const_desc.Rows);
+        todo_wine ok(const_desc.Columns == 4, "Got result %x, expected 4\n", const_desc.Columns);
+        todo_wine ok(const_desc.Elements == 1, "Got result %x, expected 1\n", const_desc.Elements);
+        todo_wine ok(const_desc.StructMembers == 0, "Got result %x, expected 0\n", const_desc.StructMembers);
+        todo_wine ok(const_desc.Bytes == 64, "Got result %x, expected 64\n", const_desc.Bytes);
+        ok(const_desc.DefaultValue == NULL, "Got result %p, expected NULL\n", const_desc.DefaultValue);
+        
+        ID3DXConstantTable_Release(constant_table);
+    }
 }
 
 START_TEST(shader)
-- 
1.7.0.4


More information about the wine-patches mailing list