[PATCH 3/6] d3dx9_36/tests: Added tests for conditional expressions to HLSL test suite

Travis Athougies iammisc at gmail.com
Wed Aug 4 17:06:41 CDT 2010


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

diff --git a/dlls/d3dx9_36/tests/hlsl.c b/dlls/d3dx9_36/tests/hlsl.c
index 8c45935..97f00b6 100644
--- a/dlls/d3dx9_36/tests/hlsl.c
+++ b/dlls/d3dx9_36/tests/hlsl.c
@@ -319,6 +319,57 @@ static void test_math(void)
     }
 }
 
+static void test_conditionals(void)
+{
+    static const char *if_greater_shader =
+        "float4 test(float2 pos: TEXCOORD0): COLOR \
+        {                                          \
+            if((pos.x * 32.0) > 20.0)              \
+                return float4(0, 0, 1, 0);         \
+            else                                   \
+                return float4(0, 1, 0, 0);         \
+        }";
+
+    static const char *ternary_operator_shader =
+        "float4 test(float2 pos: TEXCOORD0): COLOR                      \
+        {                                                               \
+            return (pos.x < 0.5?float4(1, 0, 1, 0):float4(0, 1, 0, 1)); \
+        }";
+
+    ID3DXConstantTable *constants;
+    IDirect3DPixelShader9 *pshader;
+    DWORD *data;
+
+    pshader = compile_pixel_shader(if_greater_shader, "ps_2_0", &constants);
+    if(pshader != NULL)
+    {
+        data = (DWORD*) compute_shader_fullscreen(pshader, D3DFMT_A8R8G8B8, 32, 1);
+
+        ok(data[15] == D3DCOLOR_ARGB(0, 0, 255, 0), "if_greater_test: Got color %08x (should be 0x0000ff00)\n", data[15]);
+        ok(data[25] == D3DCOLOR_ARGB(0, 0, 0, 255), "if_greater_test: Got color %08x (should be 0x000000ff)\n", data[25]);
+
+        IUnknown_Release(constants);
+        IUnknown_Release(pshader);
+    }
+
+    pshader = compile_pixel_shader(ternary_operator_shader, "ps_2_0", &constants);
+    if(pshader != NULL)
+    {
+        data = (DWORD*) compute_shader_fullscreen(pshader, D3DFMT_A8R8G8B8, 8, 1);
+        ok(data[0] == D3DCOLOR_ARGB(0, 255, 0, 255), "ternary_operator_test: Got color %08x (should be 0x00ff00ff)\n", data[0]);
+        ok(data[1] == D3DCOLOR_ARGB(0, 255, 0, 255), "ternary_operator_test: Got color %08x (should be 0x00ff00ff)\n", data[1]);
+        ok(data[2] == D3DCOLOR_ARGB(0, 255, 0, 255), "ternary_operator_test: Got color %08x (should be 0x00ff00ff)\n", data[2]);
+        ok(data[3] == D3DCOLOR_ARGB(0, 255, 0, 255), "ternary_operator_test: Got color %08x (should be 0x00ff00ff)\n", data[3]);
+        ok(data[4] == D3DCOLOR_ARGB(255, 0, 255, 0), "ternary_operator_test: Got color %08x (should be 0xff00ff00)\n", data[4]);
+        ok(data[5] == D3DCOLOR_ARGB(255, 0, 255, 0), "ternary_operator_test: Got color %08x (should be 0xff00ff00)\n", data[5]);
+        ok(data[6] == D3DCOLOR_ARGB(255, 0, 255, 0), "ternary_operator_test: Got color %08x (should be 0xff00ff00)\n", data[6]);
+        ok(data[7] == D3DCOLOR_ARGB(255, 0, 255, 0), "ternary_operator_test: Got color %08x (should be 0xff00ff00)\n", data[7]);
+
+        IUnknown_Release(constants);
+        IUnknown_Release(pshader);
+    }
+}
+
 /* The heart of our little testing framework */
 START_TEST(hlsl)
 {
@@ -334,6 +385,7 @@ START_TEST(hlsl)
         todo_wine {
             test_swizzle();
             test_math();
+            test_conditionals();
         }
     } else skip("no pixel shader support\n");
 
-- 
1.6.4.4




More information about the wine-patches mailing list