[PATCH 4/5] d3dcompiler_43/tests: Added float vector tests to HLSL test suite

Travis Athougies iammisc at gmail.com
Sun Sep 26 12:51:31 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 4004ff9..4ac8f4d 100644
--- a/dlls/d3dcompiler_43/tests/hlsl.c
+++ b/dlls/d3dcompiler_43/tests/hlsl.c
@@ -397,6 +397,72 @@ static void test_conditionals(IDirect3DDevice9 *device, IDirect3DVertexBuffer9 *
     }
 }
 
+static void test_float_vectors(IDirect3DDevice9 *device, IDirect3DVertexBuffer9 *quad_geometry,
+        IDirect3DVertexShader9 *vshader_passthru)
+{
+    static const char *vec4_indexing_test1_shader =
+        "float4 test(): COLOR                   \
+        {                                       \
+            float4 color;                       \
+            color[0] = 0.0;                     \
+            color[1] = 1.0;                     \
+            color[2] = 0.0;                     \
+            color[3] = 1.0;                     \
+            return color;                       \
+        }";
+
+    /* We have this uniform i here so the compiler can't optimize */
+    static const char *vec4_indexing_test2_shader =
+        "uniform int i;                         \
+        float4 test(): COLOR                    \
+        {                                       \
+            float4 color = float4(0, 0, 1, 1);  \
+            color.g = color[i];                 \
+            color.b = 0;                        \
+            return color;                       \
+        }";
+
+    ID3DXConstantTable *constants;
+    IDirect3DPixelShader9 *pshader;
+    DWORD *data;
+
+    pshader = compile_pixel_shader9(device, vec4_indexing_test1_shader, "ps_2_0", &constants);
+    if (pshader != NULL)
+    {
+        data = compute_shader_fullscreen9(device, vshader_passthru, pshader, quad_geometry,
+                D3DFMT_A8R8G8B8, 32, 1);
+
+        ok(data[10] == D3DCOLOR_ARGB(255, 0, 255, 0),
+               "vec4_indexing_test1: Got color %08x (should be 0xff00ff00)\n", data[10]);
+        ok(data[16] == D3DCOLOR_ARGB(255, 0, 255, 0),
+               "vec4_indexing_test1: Got color %08x (should be 0xff00ff00)\n", data[16]);
+        ok(data[22] == D3DCOLOR_ARGB(255, 0, 255, 0),
+               "vec4_indexing_test1: Got color %08x (should be 0xff00ff00)\n", data[22]);
+
+        IUnknown_Release(constants);
+        IUnknown_Release(pshader);
+    }
+
+    pshader = compile_pixel_shader9(device, vec4_indexing_test2_shader, "ps_2_0", &constants);
+    if (pshader != NULL)
+    {
+        ID3DXConstantTable_SetInt(constants, device, "i", 2);
+
+        data = compute_shader_fullscreen9(device, vshader_passthru, pshader, quad_geometry,
+                 D3DFMT_A8R8G8B8, 32, 1);
+
+        ok(data[10] == D3DCOLOR_ARGB(255, 0, 255, 0),
+               "vec4_indexing_test2: Got color %08x (should be 0xff00ff00)\n", data[10]);
+        ok(data[16] == D3DCOLOR_ARGB(255, 0, 255, 0),
+               "vec4_indexing_test2: Got color %08x (should be 0xff00ff00)\n", data[16]);
+        ok(data[22] == D3DCOLOR_ARGB(255, 0, 255, 0),
+               "vec4_indexing_test2: Got color %08x (should be 0xff00ff00)\n", data[22]);
+
+        IUnknown_Release(constants);
+        IUnknown_Release(pshader);
+    }
+}
+
 START_TEST(hlsl)
 {
     D3DCAPS9 caps;
@@ -419,6 +485,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);
+            test_float_vectors(device, quad_geometry, vshader_passthru);
         }
     } else skip("no pixel shader support\n");
 
-- 
1.7.0.4




More information about the wine-patches mailing list