[PATCH 7/7] d3dx9_36/tests: Added constant tables tests to HLSL test suite

Travis Athougies iammisc at gmail.com
Wed Aug 25 02:59:38 CDT 2010


---
 dlls/d3dx9_36/tests/hlsl.c |   82 +++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 81 insertions(+), 1 deletions(-)

diff --git a/dlls/d3dx9_36/tests/hlsl.c b/dlls/d3dx9_36/tests/hlsl.c
index 794c7da..24bd3c8 100644
--- a/dlls/d3dx9_36/tests/hlsl.c
+++ b/dlls/d3dx9_36/tests/hlsl.c
@@ -551,6 +551,85 @@ static void test_trig(IDirect3DDevice9* device)
     }
 }
 
+static void test_constant_tables(IDirect3DDevice9* device)
+{
+    static const char *vector_array_staticindex_test_shader =
+        "uniform float4 colors[4];                                      \
+         float4 test(float2 wpos: TEXCOORD0):COLOR                      \
+         {                                                              \
+             return colors[0] + colors[1] + colors[2] + colors[3];      \
+         }";
+
+    static const char *integer_constant_test_shader =
+        "uniform int brk;                           \
+        float4 test(float2 wpos: TEXCOORD0):COLOR   \
+        {                                           \
+            if((wpos.x * 8) > brk)                  \
+                return float4(1, 0, 1, 0);          \
+            else                                    \
+                return float4(1, 1, 1, 1);          \
+        }";
+
+    static const char *uniform_array_test_shader =
+        "uniform float4 colors[4];              \
+        float4 test(float2 wpos: VPOS):COLOR    \
+        {                                       \
+             return colors[wpos.x];             \
+        }";
+
+    static D3DXVECTOR4 test_colors[] = {
+        {1, 0, 0, 0},
+        {0, 0, 1, 0},
+        {0, 0, 0, 1},
+        {0, 1, 0, 0}
+    };
+
+    ID3DXConstantTable *constants;
+    IDirect3DPixelShader9 *pshader;
+    DWORD* data;
+
+    pshader = compile_pixel_shader(device, vector_array_staticindex_test_shader, "ps_2_0", &constants);
+    if(pshader != NULL)
+    {
+        ID3DXConstantTable_SetVectorArray(constants, device, "colors", test_colors, 4);
+        data = (DWORD*) compute_shader_fullscreen(device, pshader, D3DFMT_A8R8G8B8, 1, 1);
+
+        ok(data[0] == D3DCOLOR_ARGB(255, 255, 255, 255), 
+	   "vector_array_staticindex_test: Got color %08x (should be 0xffffffff)\n", data[0]);
+
+        IUnknown_Release(constants);
+        IUnknown_Release(pshader);
+    }
+
+    pshader = compile_pixel_shader(device, integer_constant_test_shader, "ps_2_0", &constants);
+    if(pshader != NULL)
+    {
+        ID3DXConstantTable_SetInt(constants, device, "brk", 5);
+        data = (DWORD*) compute_shader_fullscreen(device, pshader, D3DFMT_A8R8G8B8, 8, 1);
+
+        ok(data[0] == D3DCOLOR_ARGB(255, 255, 255, 255), "integer_constant_test: Got color %08x (should be 0xffffffff)\n", data[0]);
+        ok(data[6] == D3DCOLOR_ARGB(0, 255, 0, 255), "integer_constant_test: Got color %08x (should be 0x00ff00ff\n", data[6]);
+
+        IUnknown_Release(constants);
+        IUnknown_Release(pshader);
+    }
+
+    pshader = compile_pixel_shader(device, uniform_array_test_shader, "ps_3_0", &constants);
+    if(pshader != NULL) {
+      ID3DXConstantTable_SetVectorArray(constants, device, "colors", test_colors, 4);
+
+      data = (DWORD*) compute_shader_fullscreen(device, pshader, D3DFMT_A8R8G8B8, 4, 1);
+
+      ok(data[0] == D3DCOLOR_ARGB(0, 255, 0, 0), "uniform_array_test: Got color %08x (should be 0x00ff0000)\n", data[0]);
+      ok(data[1] == D3DCOLOR_ARGB(0, 0, 0, 255), "uniform_array_test: Got color %08x (should be 0x000000ff)\n", data[1]);
+      ok(data[2] == D3DCOLOR_ARGB(255, 0, 0, 0), "uniform_array_test: Got color %08x (should be 0xff000000)\n", data[2]);
+      ok(data[3] == D3DCOLOR_ARGB(0, 0, 255, 0), "uniform_array_test: Got color %08x (should be 0x0000ff00)\n", data[3]);
+
+      IUnknown_Release(constants);
+      IUnknown_Release(pshader);
+    }
+}
+
 /* The heart of our little testing framework */
 START_TEST(hlsl)
 {
@@ -569,7 +648,8 @@ START_TEST(hlsl)
             test_math(device);
             test_conditionals(device);
             test_float_vectors(device);
-	    test_trig(device);
+        test_trig(device);
+        test_constant_tables(device);
         }
     } else skip("no pixel shader support\n");
 
-- 
1.7.0.4




More information about the wine-patches mailing list