[PATCH 2/5] d3dcompiler_43/tests: Added order of operations test to HLSL test suite

Travis Athougies iammisc at gmail.com
Sun Sep 26 12:51:29 CDT 2010


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

diff --git a/dlls/d3dcompiler_43/tests/hlsl.c b/dlls/d3dcompiler_43/tests/hlsl.c
index f22adff..900e10b 100644
--- a/dlls/d3dcompiler_43/tests/hlsl.c
+++ b/dlls/d3dcompiler_43/tests/hlsl.c
@@ -293,6 +293,46 @@ static void test_swizzle(IDirect3DDevice9 *device, IDirect3DVertexBuffer9 *quad_
     }
 }
 
+static void test_math(IDirect3DDevice9 *device, IDirect3DVertexBuffer9 *quad_geometry,
+        IDirect3DVertexShader9 *vshader_passthru)
+{
+    static const char *order_of_operations_shader =
+        "float4 test(uniform float u, uniform float v, uniform float w, uniform float x, \
+                     uniform float y, uniform float z): COLOR                            \
+        {                                                                                \
+            return float4(x * y - z / w + --u / -v, 0, 0, 0);                            \
+        }";
+
+    const float u = 2.5f, v = 0.3f, w = 0.2f, x = 0.7f, y = 0.1f, z = 1.0f;
+    const float expected_value = (x * y) - (z / w) + ((u - 1) / (-v));
+
+    ID3DXConstantTable *constants;
+    IDirect3DPixelShader9 *pshader;
+    float *data;
+    float actual_value;
+
+    pshader = compile_pixel_shader9(device, order_of_operations_shader, "ps_2_0", &constants);
+    if (pshader != NULL)
+    {
+        ID3DXConstantTable_SetFloat(constants, device, "$u", u);
+        ID3DXConstantTable_SetFloat(constants, device, "$v", v);
+        ID3DXConstantTable_SetFloat(constants, device, "$w", w);
+        ID3DXConstantTable_SetFloat(constants, device, "$x", x);
+        ID3DXConstantTable_SetFloat(constants, device, "$y", y);
+        ID3DXConstantTable_SetFloat(constants, device, "$z", z);
+
+        data = compute_shader_fullscreen9(device, vshader_passthru, pshader, quad_geometry,
+                D3DFMT_R32F, 1, 1);
+        actual_value = *data;
+
+        ok(abs(actual_value - expected_value) < 0.00001f, "order_of_operations_test: Got %f expected %f\n",
+               actual_value, expected_value);
+
+        IUnknown_Release(constants);
+        IUnknown_Release(pshader);
+    }
+}
+
 START_TEST(hlsl)
 {
     D3DCAPS9 caps;
@@ -313,6 +353,7 @@ START_TEST(hlsl)
         todo_wine
         {
             test_swizzle(device, quad_geometry, vshader_passthru);
+            test_math(device, quad_geometry, vshader_passthru);
         }
     } else skip("no pixel shader support\n");
 
-- 
1.7.0.4




More information about the wine-patches mailing list