[PATCH 6/6] d3dx9_36/tests: Added tests for constant tables in HLSL test suite
Travis Athougies
iammisc at gmail.com
Wed Aug 4 17:07:39 CDT 2010
---
dlls/d3dx9_36/tests/hlsl.c | 79 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 79 insertions(+), 0 deletions(-)
diff --git a/dlls/d3dx9_36/tests/hlsl.c b/dlls/d3dx9_36/tests/hlsl.c
index 609d9e3..4502e6a 100644
--- a/dlls/d3dx9_36/tests/hlsl.c
+++ b/dlls/d3dx9_36/tests/hlsl.c
@@ -547,6 +547,84 @@ static void test_trig(void)
}
}
+static void test_constant_tables(void)
+{
+ 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(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(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(integer_constant_test_shader, "ps_2_0", &constants);
+ if(pshader != NULL)
+ {
+ ID3DXConstantTable_SetInt(constants, device, "brk", 5);
+ data = (DWORD*) compute_shader_fullscreen(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(uniform_array_test_shader, "ps_3_0", &constants);
+ if(pshader != NULL) {
+ ID3DXConstantTable_SetVectorArray(constants, device, "colors", test_colors, 4);
+
+ data = (DWORD*) compute_shader_fullscreen(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)
{
@@ -565,6 +643,7 @@ START_TEST(hlsl)
test_conditionals();
test_float_vectors();
test_trig();
+ test_constant_tables();
}
} else skip("no pixel shader support\n");
--
1.6.4.4
More information about the wine-patches
mailing list