From: Józef Kucia Subject: [PATCH 5/8] d3d11/tests: Add test for SM4 if instruction. Message-Id: <1464166285-21332-5-git-send-email-jkucia@codeweavers.com> Date: Wed, 25 May 2016 10:51:22 +0200 In-Reply-To: <1464166285-21332-1-git-send-email-jkucia@codeweavers.com> References: <1464166285-21332-1-git-send-email-jkucia@codeweavers.com> Signed-off-by: Józef Kucia --- dlls/d3d11/tests/d3d11.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c index 85ec201..43a60b6 100644 --- a/dlls/d3d11/tests/d3d11.c +++ b/dlls/d3d11/tests/d3d11.c @@ -6875,6 +6875,103 @@ static void test_shader_stage_input_output_matching(void) release_test_context(&test_context); } +static void test_sm4_if_instruction(void) +{ + struct d3d11_test_context test_context; + ID3D11PixelShader *ps_if_nz, *ps_if_z; + ID3D11DeviceContext *context; + ID3D11Device *device; + unsigned int bits[4]; + DWORD expected_color; + ID3D11Buffer *cb; + unsigned int i; + HRESULT hr; + + static const DWORD ps_if_nz_code[] = + { +#if 0 + uint bits; + + float4 main() : SV_TARGET + { + if (bits) + return float4(0.0f, 1.0f, 0.0f, 1.0f); + else + return float4(1.0f, 0.0f, 0.0f, 1.0f); + } +#endif + 0x43425844, 0x2a94f6f1, 0xdbe88943, 0x3426a708, 0x09cec990, 0x00000001, 0x00000100, 0x00000003, + 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f, + 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, + 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000088, 0x00000040, 0x00000022, + 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x0404001f, + 0x0020800a, 0x00000000, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000, + 0x3f800000, 0x00000000, 0x3f800000, 0x0100003e, 0x01000012, 0x08000036, 0x001020f2, 0x00000000, + 0x00004002, 0x3f800000, 0x00000000, 0x00000000, 0x3f800000, 0x0100003e, 0x01000015, 0x0100003e, + }; + static const DWORD ps_if_z_code[] = + { +#if 0 + uint bits; + + float4 main() : SV_TARGET + { + if (!bits) + return float4(0.0f, 1.0f, 0.0f, 1.0f); + else + return float4(1.0f, 0.0f, 0.0f, 1.0f); + } +#endif + 0x43425844, 0x2e3030ca, 0x94c8610c, 0xdf0c1b1f, 0x80f2ca2c, 0x00000001, 0x00000100, 0x00000003, + 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f, + 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, + 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000088, 0x00000040, 0x00000022, + 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x0400001f, + 0x0020800a, 0x00000000, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000, + 0x3f800000, 0x00000000, 0x3f800000, 0x0100003e, 0x01000012, 0x08000036, 0x001020f2, 0x00000000, + 0x00004002, 0x3f800000, 0x00000000, 0x00000000, 0x3f800000, 0x0100003e, 0x01000015, 0x0100003e, + }; + static unsigned int bit_patterns[] = + { + 0x00000000, 0x00000001, 0x10010001, 0x10000000, 0x80000000, 0xffff0000, 0x0000ffff, 0xffffffff, + }; + + if (!init_test_context(&test_context, NULL)) + return; + + device = test_context.device; + context = test_context.immediate_context; + + hr = ID3D11Device_CreatePixelShader(device, ps_if_nz_code, sizeof(ps_if_nz_code), NULL, &ps_if_nz); + ok(SUCCEEDED(hr), "Failed to create if_nz pixel shader, hr %#x.\n", hr); + hr = ID3D11Device_CreatePixelShader(device, ps_if_z_code, sizeof(ps_if_z_code), NULL, &ps_if_z); + ok(SUCCEEDED(hr), "Failed to create if_z pixel shader, hr %#x.\n", hr); + + cb = create_buffer(device, D3D11_BIND_CONSTANT_BUFFER, sizeof(bits), NULL); + ID3D11DeviceContext_PSSetConstantBuffers(context, 0, 1, &cb); + + for (i = 0; i < sizeof(bit_patterns) / sizeof(*bit_patterns); ++i) + { + *bits = bit_patterns[i]; + ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)cb, 0, NULL, bits, 0, 0); + + ID3D11DeviceContext_PSSetShader(context, ps_if_nz, NULL, 0); + expected_color = *bits ? 0xff00ff00 : 0xff0000ff; + draw_quad(&test_context); + check_texture_color(test_context.backbuffer, expected_color, 0); + + ID3D11DeviceContext_PSSetShader(context, ps_if_z, NULL, 0); + expected_color = *bits ? 0xff0000ff : 0xff00ff00; + draw_quad(&test_context); + check_texture_color(test_context.backbuffer, expected_color, 0); + } + + ID3D11Buffer_Release(cb); + ID3D11PixelShader_Release(ps_if_z); + ID3D11PixelShader_Release(ps_if_nz); + release_test_context(&test_context); +} + START_TEST(d3d11) { test_create_device(); @@ -6916,4 +7013,5 @@ START_TEST(d3d11) test_cb_relative_addressing(); test_getdc(); test_shader_stage_input_output_matching(); + test_sm4_if_instruction(); } -- 2.7.3