[PATCH 5/7] d3dx9_36/tests: Added float vector tests to HLSL test suite
Travis Athougies
iammisc at gmail.com
Wed Aug 25 02:59:36 CDT 2010
---
dlls/d3dx9_36/tests/hlsl.c | 60 +++++++++++++++++++++++++++++++++++++++++--
1 files changed, 57 insertions(+), 3 deletions(-)
diff --git a/dlls/d3dx9_36/tests/hlsl.c b/dlls/d3dx9_36/tests/hlsl.c
index 9e2eb79..3647207 100644
--- a/dlls/d3dx9_36/tests/hlsl.c
+++ b/dlls/d3dx9_36/tests/hlsl.c
@@ -215,9 +215,6 @@ static void setup_device(IDirect3DDevice9* device, IDirect3DSurface9 **render_ta
ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShader returned: %08x\n", hr);
}
-/* For all compute_shader_* calls, this framework assumes that the data types are 4 bytes
- long. The two formats used here are D3DFMT_R32F and D3DFMT_A8R8G8B8 */
-
/* Compute a shader on a fullscreen quad and get the results back */
static void* compute_shader_fullscreen(IDirect3DDevice9* device, IDirect3DPixelShader9 *pshader, D3DFORMAT format,
int width, int height)
@@ -374,6 +371,62 @@ static void test_conditionals(IDirect3DDevice9* device)
}
}
+static void test_float_vectors(IDirect3DDevice9* device)
+{
+ 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_shader(device, vec4_indexing_test1_shader, "ps_2_0", &constants);
+ if(pshader != NULL) {
+ data = (DWORD*) compute_shader_fullscreen(device, pshader, 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_shader(device, vec4_indexing_test2_shader, "ps_2_0", &constants);
+ if(pshader != NULL)
+ {
+ ID3DXConstantTable_SetInt(constants, device, "i", 2);
+
+ data = (DWORD*) compute_shader_fullscreen(device, pshader, 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);
+ }
+}
+
/* The heart of our little testing framework */
START_TEST(hlsl)
{
@@ -391,6 +444,7 @@ START_TEST(hlsl)
test_swizzle(device);
test_math(device);
test_conditionals(device);
+ test_float_vectors(device);
}
} else skip("no pixel shader support\n");
--
1.7.0.4
More information about the wine-patches
mailing list