d3d11/tests: Add test for return in a conditional.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Andrew Wesie 2016-12-07 12:42:56 +01:00 committed by Alexandre Julliard
parent b9b8e775ea
commit 809ad52ae6
1 changed files with 85 additions and 0 deletions

View File

@ -11690,6 +11690,90 @@ static void test_uav_load(void)
release_test_context(&test_context);
}
static void test_sm4_ret_instruction(void)
{
struct d3d11_test_context test_context;
ID3D11DeviceContext *context;
ID3D11PixelShader *ps;
struct uvec4 constant;
ID3D11Device *device;
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();
@ -11754,4 +11838,5 @@ START_TEST(d3d11)
test_shader_input_registers_limits();
test_stencil_separate();
test_uav_load();
test_sm4_ret_instruction();
}