[PATCH 3/5] d3dcompiler_43/tests: Added tests for conditional expressions to HLSL test suite

Travis Athougies iammisc at gmail.com
Thu Sep 30 17:43:04 CDT 2010


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

diff --git a/dlls/d3dcompiler_43/tests/hlsl.c b/dlls/d3dcompiler_43/tests/hlsl.c
index 4f75646..2253303 100644
--- a/dlls/d3dcompiler_43/tests/hlsl.c
+++ b/dlls/d3dcompiler_43/tests/hlsl.c
@@ -367,6 +367,72 @@ static void test_math(IDirect3DDevice9 *device, IDirect3DVertexBuffer9 *quad_geo
     }
 }
 
+static void test_conditionals(IDirect3DDevice9 *device, IDirect3DVertexBuffer9 *quad_geometry,
+        IDirect3DVertexShader9 *vshader_passthru)
+{
+    static struct hlsl_probe_info if_greater_probes[] =
+    {
+        { 0, 0, COLOR(0.9f, 0.8f, 0.7f, 0.6f), 0.0001f, "if greater test failed"},
+        { 5, 0, COLOR(0.9f, 0.8f, 0.7f, 0.6f), 0.0001f, "if greater test failed"},
+        {10, 0, COLOR(0.9f, 0.8f, 0.7f, 0.6f), 0.0001f, "if greater test failed"},
+        {15, 0, COLOR(0.9f, 0.8f, 0.7f, 0.6f), 0.0001f, "if greater test failed"},
+        {25, 0, COLOR(0.1f, 0.2f, 0.3f, 0.4f), 0.0001f, "if greater test failed"},
+        {30, 0, COLOR(0.1f, 0.2f, 0.3f, 0.4f), 0.0001f, "if greater test failed"},
+        PROBE_END
+    };
+
+    static const char *if_greater_shader =
+        "float4 test(float2 pos: TEXCOORD0): COLOR \
+        {                                          \
+            if((pos.x * 32.0) > 20.0)              \
+                return float4(0.1, 0.2, 0.3, 0.4); \
+            else                                   \
+                return float4(0.9, 0.8, 0.7, 0.6); \
+        }";
+
+    static struct hlsl_probe_info ternary_operator_probes[] =
+    {
+        {0, 0, COLOR(0.50f, 0.25f, 0.50f, 0.75f), 0.00001f, "ternary operator test failed"},
+        {1, 0, COLOR(0.50f, 0.25f, 0.50f, 0.75f), 0.00001f, "ternary operator test failed"},
+        {2, 0, COLOR(0.50f, 0.25f, 0.50f, 0.75f), 0.00001f, "ternary operator test failed"},
+        {3, 0, COLOR(0.50f, 0.25f, 0.50f, 0.75f), 0.00001f, "ternary operator test failed"},
+        {4, 0, COLOR(0.60f, 0.80f, 0.10f, 0.20f), 0.00001f, "ternary operator test failed"},
+        {5, 0, COLOR(0.60f, 0.80f, 0.10f, 0.20f), 0.00001f, "ternary operator test failed"},
+        {6, 0, COLOR(0.60f, 0.80f, 0.10f, 0.20f), 0.00001f, "ternary operator test failed"},
+        {7, 0, COLOR(0.60f, 0.80f, 0.10f, 0.20f), 0.00001f, "ternary operator test failed"},
+        PROBE_END
+    };
+
+    static const char *ternary_operator_shader =
+        "float4 test(float2 pos: TEXCOORD0): COLOR                                        \
+        {                                                                                 \
+            return (pos.x < 0.5?float4(0.5, 0.25, 0.5, 0.75):float4(0.6, 0.8, 0.1, 0.2)); \
+        }";
+
+    ID3DXConstantTable *constants;
+    IDirect3DPixelShader9 *pshader;
+
+    pshader = compile_pixel_shader9(device, if_greater_shader, "ps_2_0", &constants);
+    if (pshader != NULL)
+    {
+        compute_shader_probe9(device, vshader_passthru, pshader, quad_geometry,
+               if_greater_probes, 32, 1);
+
+        IUnknown_Release(constants);
+        IUnknown_Release(pshader);
+    }
+
+    pshader = compile_pixel_shader9(device, ternary_operator_shader, "ps_2_0", &constants);
+    if (pshader != NULL)
+    {
+        compute_shader_probe9(device, vshader_passthru, pshader, quad_geometry,
+                ternary_operator_probes, 8, 1);
+
+        IUnknown_Release(constants);
+        IUnknown_Release(pshader);
+    }
+}
+
 START_TEST(hlsl)
 {
     D3DCAPS9 caps;
@@ -388,6 +454,7 @@ START_TEST(hlsl)
         {
             test_swizzle(device, quad_geometry, vshader_passthru);
             test_math(device, quad_geometry, vshader_passthru);
+            test_conditionals(device, quad_geometry, vshader_passthru);
         }
     } else skip("no pixel shader support\n");
 
-- 
1.7.0.4




More information about the wine-patches mailing list