From: Józef Kucia Subject: [PATCH 03/11] d3d10core/tests: Add test for return in a conditional. Message-Id: <1481110985-1006-3-git-send-email-jkucia@codeweavers.com> Date: Wed, 7 Dec 2016 12:42:57 +0100 In-Reply-To: <1481110985-1006-1-git-send-email-jkucia@codeweavers.com> References: <1481110985-1006-1-git-send-email-jkucia@codeweavers.com> From: Andrew Wesie Signed-off-by: Józef Kucia --- dlls/d3d10core/tests/device.c | 83 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/dlls/d3d10core/tests/device.c b/dlls/d3d10core/tests/device.c index f278f42..778f33c 100644 --- a/dlls/d3d10core/tests/device.c +++ b/dlls/d3d10core/tests/device.c @@ -9970,6 +9970,88 @@ static void test_stencil_separate(void) release_test_context(&test_context); } +static void test_sm4_ret_instruction(void) +{ + struct d3d10core_test_context test_context; + ID3D10PixelShader *ps; + struct uvec4 constant; + ID3D10Device *device; + ID3D10Buffer *cb; + HRESULT hr; + + static const DWORD ps_code[] = + { +#if 0 + uint c; + + float4 main() : SV_TARGET + { + if (c == 1) + return float4(1, 0, 0, 1); + if (c == 2) + return float4(0, 1, 0, 1); + if (c == 3) + return float4(0, 0, 1, 1); + return float4(1, 1, 1, 1); + } +#endif + 0x43425844, 0x9ee6f808, 0xe74009f3, 0xbb1adaf2, 0x432e97b5, 0x00000001, 0x000001c4, 0x00000003, + 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f, + 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, + 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x0000014c, 0x00000040, 0x00000053, + 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, + 0x00000001, 0x08000020, 0x00100012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x00004001, + 0x00000001, 0x0304001f, 0x0010000a, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, + 0x3f800000, 0x00000000, 0x00000000, 0x3f800000, 0x0100003e, 0x01000015, 0x08000020, 0x00100012, + 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x00004001, 0x00000002, 0x0304001f, 0x0010000a, + 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000, 0x3f800000, 0x00000000, + 0x3f800000, 0x0100003e, 0x01000015, 0x08000020, 0x00100012, 0x00000000, 0x0020800a, 0x00000000, + 0x00000000, 0x00004001, 0x00000003, 0x0304001f, 0x0010000a, 0x00000000, 0x08000036, 0x001020f2, + 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x3f800000, 0x3f800000, 0x0100003e, 0x01000015, + 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000, + 0x0100003e, + }; + + if (!init_test_context(&test_context)) + return; + + device = test_context.device; + + hr = ID3D10Device_CreatePixelShader(device, ps_code, sizeof(ps_code), &ps); + ok(SUCCEEDED(hr), "Failed to create shader, hr %#x.\n", hr); + ID3D10Device_PSSetShader(device, ps); + memset(&constant, 0, sizeof(constant)); + cb = create_buffer(device, D3D10_BIND_CONSTANT_BUFFER, sizeof(constant), &constant); + ID3D10Device_PSSetConstantBuffers(device, 0, 1, &cb); + + draw_quad(&test_context); + check_texture_color(test_context.backbuffer, 0xffffffff, 0); + + constant.x = 1; + ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)cb, 0, NULL, &constant, 0, 0); + draw_quad(&test_context); + check_texture_color(test_context.backbuffer, 0xff0000ff, 0); + + constant.x = 2; + ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)cb, 0, NULL, &constant, 0, 0); + draw_quad(&test_context); + check_texture_color(test_context.backbuffer, 0xff00ff00, 0); + + constant.x = 3; + ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)cb, 0, NULL, &constant, 0, 0); + draw_quad(&test_context); + check_texture_color(test_context.backbuffer, 0xffff0000, 0); + + constant.x = 4; + ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)cb, 0, NULL, &constant, 0, 0); + draw_quad(&test_context); + check_texture_color(test_context.backbuffer, 0xffffffff, 0); + + ID3D10Buffer_Release(cb); + ID3D10PixelShader_Release(ps); + release_test_context(&test_context); +} + START_TEST(device) { test_feature_level(); @@ -10026,4 +10108,5 @@ START_TEST(device) test_ddy(); test_shader_input_registers_limits(); test_stencil_separate(); + test_sm4_ret_instruction(); } -- 2.7.3