From: Andrew Wesie Subject: [v2 2/3] d3d11/tests: Add test for return in a conditional. Message-Id: <1479447962-13489-2-git-send-email-awesie@gmail.com> Date: Thu, 17 Nov 2016 23:46:01 -0600 In-Reply-To: <1479447962-13489-1-git-send-email-awesie@gmail.com> References: <1479447962-13489-1-git-send-email-awesie@gmail.com> Courtesy of Józef Kucia. Signed-off-by: Andrew Wesie --- dlls/d3d11/tests/d3d11.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c index 123676d..81134c8 100644 --- a/dlls/d3d11/tests/d3d11.c +++ b/dlls/d3d11/tests/d3d11.c @@ -10906,6 +10906,90 @@ float4 main(struct ps_data ps_input) : SV_Target release_test_context(&test_context); } +static void test_sm4_ret_instruction(void) +{ + struct d3d11_test_context test_context; + ID3D11DeviceContext *context; + ID3D11PixelShader *ps; + ID3D11Device *device; + struct uvec4 constant; + ID3D11Buffer *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, NULL)) + return; + + device = test_context.device; + context = test_context.immediate_context; + + hr = ID3D11Device_CreatePixelShader(device, ps_code, sizeof(ps_code), NULL, &ps); + ok(SUCCEEDED(hr), "Failed to create shader, hr %#x.\n", hr); + ID3D11DeviceContext_PSSetShader(context, ps, NULL, 0); + memset(&constant, 0, sizeof(constant)); + cb = create_buffer(device, D3D11_BIND_CONSTANT_BUFFER, sizeof(constant), &constant); + ID3D11DeviceContext_PSSetConstantBuffers(context, 0, 1, &cb); + + draw_quad(&test_context); + check_texture_color(test_context.backbuffer, 0xffffffff, 0); + + constant.x = 1; + ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)cb, 0, NULL, &constant, 0, 0); + draw_quad(&test_context); + check_texture_color(test_context.backbuffer, 0xff0000ff, 0); + + constant.x = 2; + ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)cb, 0, NULL, &constant, 0, 0); + draw_quad(&test_context); + check_texture_color(test_context.backbuffer, 0xff00ff00, 0); + + constant.x = 3; + ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)cb, 0, NULL, &constant, 0, 0); + draw_quad(&test_context); + check_texture_color(test_context.backbuffer, 0xffff0000, 0); + + constant.x = 4; + ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)cb, 0, NULL, &constant, 0, 0); + draw_quad(&test_context); + check_texture_color(test_context.backbuffer, 0xffffffff, 0); + + ID3D11Buffer_Release(cb); + ID3D11PixelShader_Release(ps); + release_test_context(&test_context); +} + START_TEST(d3d11) { test_create_device(); @@ -10965,4 +11049,5 @@ START_TEST(d3d11) run_for_each_feature_level(test_required_format_support); run_for_each_9_x_feature_level(test_fl9_draw); test_ddy(); + test_sm4_ret_instruction(); } -- 2.7.4