[PATCH 3/5] d3dcompiler_43/tests: Added tests for conditional expressions to HLSL test suite
Travis Athougies
iammisc at gmail.com
Sun Sep 26 12:51:30 CDT 2010
---
dlls/d3dcompiler_43/tests/hlsl.c | 65 ++++++++++++++++++++++++++++++++++++++
1 files changed, 65 insertions(+), 0 deletions(-)
diff --git a/dlls/d3dcompiler_43/tests/hlsl.c b/dlls/d3dcompiler_43/tests/hlsl.c
index 900e10b..4004ff9 100644
--- a/dlls/d3dcompiler_43/tests/hlsl.c
+++ b/dlls/d3dcompiler_43/tests/hlsl.c
@@ -333,6 +333,70 @@ static void test_math(IDirect3DDevice9 *device, IDirect3DVertexBuffer9 *quad_geo
}
}
+static void test_conditionals(IDirect3DDevice9 *device, IDirect3DVertexBuffer9 *quad_geometry,
+ IDirect3DVertexShader9 *vshader_passthru)
+{
+ static const char *if_greater_shader =
+ "float4 test(float2 pos: TEXCOORD0): COLOR \
+ { \
+ if((pos.x * 32.0) > 20.0) \
+ return float4(0, 0, 1, 0); \
+ else \
+ return float4(0, 1, 0, 0); \
+ }";
+
+ static const char *ternary_operator_shader =
+ "float4 test(float2 pos: TEXCOORD0): COLOR \
+ { \
+ return (pos.x < 0.5?float4(1, 0, 1, 0):float4(0, 1, 0, 1)); \
+ }";
+
+ ID3DXConstantTable *constants;
+ IDirect3DPixelShader9 *pshader;
+ DWORD *data;
+
+ pshader = compile_pixel_shader9(device, if_greater_shader, "ps_2_0", &constants);
+ if (pshader != NULL)
+ {
+ data = compute_shader_fullscreen9(device, vshader_passthru, pshader, quad_geometry,
+ D3DFMT_A8R8G8B8, 32, 1);
+
+ ok(data[15] == D3DCOLOR_ARGB(0, 0, 255, 0),
+ "if_greater_test: Got color %08x (should be 0x0000ff00)\n", data[15]);
+ ok(data[25] == D3DCOLOR_ARGB(0, 0, 0, 255),
+ "if_greater_test: Got color %08x (should be 0x000000ff)\n", data[25]);
+
+ IUnknown_Release(constants);
+ IUnknown_Release(pshader);
+ }
+
+ pshader = compile_pixel_shader9(device, ternary_operator_shader, "ps_2_0", &constants);
+ if (pshader != NULL)
+ {
+ data = compute_shader_fullscreen9(device, vshader_passthru, pshader, quad_geometry,
+ D3DFMT_A8R8G8B8, 8, 1);
+ ok(data[0] == D3DCOLOR_ARGB(0, 255, 0, 255),
+ "ternary_operator_test: Got color %08x (should be 0x00ff00ff)\n", data[0]);
+ ok(data[1] == D3DCOLOR_ARGB(0, 255, 0, 255),
+ "ternary_operator_test: Got color %08x (should be 0x00ff00ff)\n", data[1]);
+ ok(data[2] == D3DCOLOR_ARGB(0, 255, 0, 255),
+ "ternary_operator_test: Got color %08x (should be 0x00ff00ff)\n", data[2]);
+ ok(data[3] == D3DCOLOR_ARGB(0, 255, 0, 255),
+ "ternary_operator_test: Got color %08x (should be 0x00ff00ff)\n", data[3]);
+ ok(data[4] == D3DCOLOR_ARGB(255, 0, 255, 0),
+ "ternary_operator_test: Got color %08x (should be 0xff00ff00)\n", data[4]);
+ ok(data[5] == D3DCOLOR_ARGB(255, 0, 255, 0),
+ "ternary_operator_test: Got color %08x (should be 0xff00ff00)\n", data[5]);
+ ok(data[6] == D3DCOLOR_ARGB(255, 0, 255, 0),
+ "ternary_operator_test: Got color %08x (should be 0xff00ff00)\n", data[6]);
+ ok(data[7] == D3DCOLOR_ARGB(255, 0, 255, 0),
+ "ternary_operator_test: Got color %08x (should be 0xff00ff00)\n", data[7]);
+
+ IUnknown_Release(constants);
+ IUnknown_Release(pshader);
+ }
+}
+
START_TEST(hlsl)
{
D3DCAPS9 caps;
@@ -354,6 +418,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