[PATCH 2/2] d3d11/tests: Add test for swapc instruction.
Józef Kucia
jkucia at codeweavers.com
Wed Jul 12 17:35:47 CDT 2017
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
dlls/d3d11/tests/d3d11.c | 274 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 274 insertions(+)
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index 00e11fb3e1..cd3fdb53cd 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -12230,6 +12230,279 @@ static void test_sm4_continuec_instruction(void)
release_test_context(&test_context);
}
+static void test_sm5_swapc_instruction(void)
+{
+ struct input
+ {
+ struct uvec4 src0;
+ struct uvec4 src1;
+ struct uvec4 src2;
+ };
+
+ struct d3d11_test_context test_context;
+ D3D11_TEXTURE2D_DESC texture_desc;
+ ID3D11DeviceContext *context;
+ ID3D11RenderTargetView *rtv;
+ ID3D11Texture2D *texture;
+ ID3D11PixelShader *ps[6];
+ ID3D11Device *device;
+ ID3D11Buffer *cb;
+ unsigned int i;
+ HRESULT hr;
+
+ static const D3D_FEATURE_LEVEL feature_level = D3D_FEATURE_LEVEL_11_0;
+ static const DWORD ps_swapc0_code[] =
+ {
+#if 0
+ ps_5_0
+ dcl_globalFlags refactoringAllowed
+ dcl_constantbuffer cb0[3], immediateIndexed
+ dcl_output o0.xyzw
+ dcl_temps 2
+ swapc r0.xyzw, r1.xyzw, cb0[0].xyzw, cb0[1].xyzw, cb0[2].xyzw
+ mov o0.xyzw, r0.xyzw
+ ret
+#endif
+ 0x43425844, 0x9e089246, 0x9f8b5cbe, 0xbac66faf, 0xaef23488, 0x00000001, 0x000000f8, 0x00000003,
+ 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
+ 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
+ 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000080, 0x00000050, 0x00000020,
+ 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000003, 0x03000065, 0x001020f2, 0x00000000,
+ 0x02000068, 0x00000002, 0x0e00008e, 0x001000f2, 0x00000000, 0x001000f2, 0x00000001, 0x00208e46,
+ 0x00000000, 0x00000000, 0x00208e46, 0x00000000, 0x00000001, 0x00208e46, 0x00000000, 0x00000002,
+ 0x05000036, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x0100003e,
+ };
+ static const DWORD ps_swapc1_code[] =
+ {
+#if 0
+ ps_5_0
+ dcl_globalFlags refactoringAllowed
+ dcl_constantbuffer cb0[3], immediateIndexed
+ dcl_output o0.xyzw
+ dcl_temps 2
+ swapc r0.xyzw, r1.xyzw, cb0[0].xyzw, cb0[1].xyzw, cb0[2].xyzw
+ mov o0.xyzw, r1.xyzw
+ ret
+#endif
+ 0x43425844, 0xf2daed61, 0xede211f7, 0x7300dbea, 0x573ed49f, 0x00000001, 0x000000f8, 0x00000003,
+ 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
+ 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
+ 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000080, 0x00000050, 0x00000020,
+ 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000003, 0x03000065, 0x001020f2, 0x00000000,
+ 0x02000068, 0x00000002, 0x0e00008e, 0x001000f2, 0x00000000, 0x001000f2, 0x00000001, 0x00208e46,
+ 0x00000000, 0x00000000, 0x00208e46, 0x00000000, 0x00000001, 0x00208e46, 0x00000000, 0x00000002,
+ 0x05000036, 0x001020f2, 0x00000000, 0x00100e46, 0x00000001, 0x0100003e,
+ };
+ static const DWORD ps_swapc2_code[] =
+ {
+#if 0
+ ps_5_0
+ dcl_globalFlags refactoringAllowed
+ dcl_constantbuffer cb0[3], immediateIndexed
+ dcl_output o0.xyzw
+ dcl_temps 2
+ mov r0.xyzw, cb0[1].xyzw
+ mov r1.xyzw, cb0[2].xyzw
+ swapc r0.xyzw, r1.xyzw, cb0[0].xyzw, r0.xyzw, r1.xyzw
+ mov o0.xyzw, r0.xyzw
+ ret
+#endif
+ 0x43425844, 0x230fcb22, 0x70d99148, 0x65814d89, 0x97473498, 0x00000001, 0x00000120, 0x00000003,
+ 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
+ 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
+ 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000a8, 0x00000050, 0x0000002a,
+ 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000003, 0x03000065, 0x001020f2, 0x00000000,
+ 0x02000068, 0x00000002, 0x06000036, 0x001000f2, 0x00000000, 0x00208e46, 0x00000000, 0x00000001,
+ 0x06000036, 0x001000f2, 0x00000001, 0x00208e46, 0x00000000, 0x00000002, 0x0c00008e, 0x001000f2,
+ 0x00000000, 0x001000f2, 0x00000001, 0x00208e46, 0x00000000, 0x00000000, 0x00100e46, 0x00000000,
+ 0x00100e46, 0x00000001, 0x05000036, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x0100003e,
+ };
+ static const DWORD ps_swapc3_code[] =
+ {
+#if 0
+ ps_5_0
+ dcl_globalFlags refactoringAllowed
+ dcl_constantbuffer cb0[3], immediateIndexed
+ dcl_output o0.xyzw
+ dcl_temps 2
+ mov r0.xyzw, cb0[1].xyzw
+ mov r1.xyzw, cb0[2].xyzw
+ swapc r0.xyzw, r1.xyzw, cb0[0].xyzw, r0.xyzw, r1.xyzw
+ mov o0.xyzw, r1.xyzw
+ ret
+#endif
+ 0x43425844, 0xce595d62, 0x98305541, 0xb04e74c8, 0xfc010f3a, 0x00000001, 0x00000120, 0x00000003,
+ 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
+ 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
+ 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000a8, 0x00000050, 0x0000002a,
+ 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000003, 0x03000065, 0x001020f2, 0x00000000,
+ 0x02000068, 0x00000002, 0x06000036, 0x001000f2, 0x00000000, 0x00208e46, 0x00000000, 0x00000001,
+ 0x06000036, 0x001000f2, 0x00000001, 0x00208e46, 0x00000000, 0x00000002, 0x0c00008e, 0x001000f2,
+ 0x00000000, 0x001000f2, 0x00000001, 0x00208e46, 0x00000000, 0x00000000, 0x00100e46, 0x00000000,
+ 0x00100e46, 0x00000001, 0x05000036, 0x001020f2, 0x00000000, 0x00100e46, 0x00000001, 0x0100003e,
+ };
+ static const DWORD ps_swapc4_code[] =
+ {
+#if 0
+ ps_5_0
+ dcl_globalFlags refactoringAllowed
+ dcl_constantbuffer cb0[3], immediateIndexed
+ dcl_output o0.xyzw
+ dcl_temps 2
+ mov r0.xyzw, cb0[0].xyzw
+ swapc r0.xyzw, r1.xyzw, r0.xyzw, cb0[1].xyzw, cb0[2].xyzw
+ mov o0.xyzw, r0.xyzw
+ ret
+#endif
+ 0x43425844, 0x72067c48, 0xb53572a0, 0x9dd9e0fd, 0x903e37e3, 0x00000001, 0x0000010c, 0x00000003,
+ 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
+ 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
+ 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000094, 0x00000050, 0x00000025,
+ 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000003, 0x03000065, 0x001020f2, 0x00000000,
+ 0x02000068, 0x00000002, 0x06000036, 0x001000f2, 0x00000000, 0x00208e46, 0x00000000, 0x00000000,
+ 0x0d00008e, 0x001000f2, 0x00000000, 0x001000f2, 0x00000001, 0x00100e46, 0x00000000, 0x00208e46,
+ 0x00000000, 0x00000001, 0x00208e46, 0x00000000, 0x00000002, 0x05000036, 0x001020f2, 0x00000000,
+ 0x00100e46, 0x00000000, 0x0100003e,
+ };
+ static const DWORD ps_swapc5_code[] =
+ {
+#if 0
+ ps_5_0
+ dcl_globalFlags refactoringAllowed
+ dcl_constantbuffer cb0[3], immediateIndexed
+ dcl_output o0.xyzw
+ dcl_temps 2
+ mov r1.xyzw, cb0[0].xyzw
+ swapc r0.xyzw, r1.xyzw, r1.xyzw, cb0[1].xyzw, cb0[2].xyzw
+ mov o0.xyzw, r1.xyzw
+ ret
+#endif
+ 0x43425844, 0x7078fb08, 0xdd24cd44, 0x469d3258, 0x9e33a0bc, 0x00000001, 0x0000010c, 0x00000003,
+ 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
+ 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
+ 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000094, 0x00000050, 0x00000025,
+ 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000003, 0x03000065, 0x001020f2, 0x00000000,
+ 0x02000068, 0x00000002, 0x06000036, 0x001000f2, 0x00000001, 0x00208e46, 0x00000000, 0x00000000,
+ 0x0d00008e, 0x001000f2, 0x00000000, 0x001000f2, 0x00000001, 0x00100e46, 0x00000001, 0x00208e46,
+ 0x00000000, 0x00000001, 0x00208e46, 0x00000000, 0x00000002, 0x05000036, 0x001020f2, 0x00000000,
+ 0x00100e46, 0x00000001, 0x0100003e,
+ };
+ static const struct
+ {
+ struct input input;
+ struct uvec4 dst0;
+ struct uvec4 dst1;
+ }
+ tests[] =
+ {
+ {
+ {{0, 0, 0, 0}, {0xdead, 0xc0de, 0xffff, 0xeeee}, {0xaaaa, 0xbbbb, 0xcccc, 0xdddd}},
+ {0xdead, 0xc0de, 0xffff, 0xeeee}, {0xaaaa, 0xbbbb, 0xcccc, 0xdddd}
+ },
+ {
+ {{1, 1, 1, 1}, {0xdead, 0xc0de, 0xffff, 0xeeee}, {0xaaaa, 0xbbbb, 0xcccc, 0xdddd}},
+ {0xaaaa, 0xbbbb, 0xcccc, 0xdddd}, {0xdead, 0xc0de, 0xffff, 0xeeee},
+ },
+ {
+ {{0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff},
+ {0xdead, 0xc0de, 0xffff, 0xeeee}, {0xaaaa, 0xbbbb, 0xcccc, 0xdddd}},
+ {0xaaaa, 0xbbbb, 0xcccc, 0xdddd}, {0xdead, 0xc0de, 0xffff, 0xeeee},
+ },
+ {
+ {{1, 0, 1, 0}, {0xdead, 0xc0de, 0xffff, 0xeeee}, {0xaaaa, 0xbbbb, 0xcccc, 0xdddd}},
+ {0xaaaa, 0xc0de, 0xcccc, 0xeeee}, {0xdead, 0xbbbb, 0xffff, 0xdddd},
+ },
+ {
+ {{1, 0, 0, 1}, {0xdead, 0xc0de, 0xffff, 0xeeee}, {0xaaaa, 0xbbbb, 0xcccc, 0xdddd}},
+ {0xaaaa, 0xc0de, 0xffff, 0xdddd}, {0xdead, 0xbbbb, 0xcccc, 0xeeee},
+ },
+ {
+ {{1, 0, 0, 0}, {0xdead, 0xc0de, 0xffff, 0xeeee}, {0xaaaa, 0xbbbb, 0xcccc, 0xdddd}},
+ {0xaaaa, 0xc0de, 0xffff, 0xeeee}, {0xdead, 0xbbbb, 0xcccc, 0xdddd}
+ },
+ {
+ {{0, 1, 0, 0}, {0xdead, 0xc0de, 0xffff, 0xeeee}, {0xaaaa, 0xbbbb, 0xcccc, 0xdddd}},
+ {0xdead, 0xbbbb, 0xffff, 0xeeee}, {0xaaaa, 0xc0de, 0xcccc, 0xdddd}
+ },
+ {
+ {{0, 0, 1, 0}, {0xdead, 0xc0de, 0xffff, 0xeeee}, {0xaaaa, 0xbbbb, 0xcccc, 0xdddd}},
+ {0xdead, 0xc0de, 0xcccc, 0xeeee}, {0xaaaa, 0xbbbb, 0xffff, 0xdddd}
+ },
+ {
+ {{0, 0, 0, 1}, {0xdead, 0xc0de, 0xffff, 0xeeee}, {0xaaaa, 0xbbbb, 0xcccc, 0xdddd}},
+ {0xdead, 0xc0de, 0xffff, 0xdddd}, {0xaaaa, 0xbbbb, 0xcccc, 0xeeee},
+ },
+ };
+
+ if (!init_test_context(&test_context, &feature_level))
+ return;
+
+ device = test_context.device;
+ context = test_context.immediate_context;
+
+ ID3D11Texture2D_GetDesc(test_context.backbuffer, &texture_desc);
+ texture_desc.Format = DXGI_FORMAT_R32G32B32A32_UINT;
+ hr = ID3D11Device_CreateTexture2D(device, &texture_desc, NULL, &texture);
+ ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+
+ hr = ID3D11Device_CreateRenderTargetView(device, (ID3D11Resource *)texture, NULL, &rtv);
+ ok(SUCCEEDED(hr), "Failed to create render target view, hr %#x.\n", hr);
+
+ ID3D11DeviceContext_OMSetRenderTargets(context, 1, &rtv, NULL);
+
+ cb = create_buffer(device, D3D11_BIND_CONSTANT_BUFFER, sizeof(struct input), NULL);
+ ID3D11DeviceContext_PSSetConstantBuffers(context, 0, 1, &cb);
+
+ hr = ID3D11Device_CreatePixelShader(device, ps_swapc0_code, sizeof(ps_swapc0_code), NULL, &ps[0]);
+ ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
+ hr = ID3D11Device_CreatePixelShader(device, ps_swapc1_code, sizeof(ps_swapc1_code), NULL, &ps[1]);
+ ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
+ hr = ID3D11Device_CreatePixelShader(device, ps_swapc2_code, sizeof(ps_swapc2_code), NULL, &ps[2]);
+ ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
+ hr = ID3D11Device_CreatePixelShader(device, ps_swapc3_code, sizeof(ps_swapc3_code), NULL, &ps[3]);
+ ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
+ hr = ID3D11Device_CreatePixelShader(device, ps_swapc4_code, sizeof(ps_swapc4_code), NULL, &ps[4]);
+ ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
+ hr = ID3D11Device_CreatePixelShader(device, ps_swapc5_code, sizeof(ps_swapc5_code), NULL, &ps[5]);
+ ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
+
+ for (i = 0; i < ARRAY_SIZE(tests); ++i)
+ {
+ ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)cb, 0, NULL, &tests[i].input, 0, 0);
+
+ ID3D11DeviceContext_PSSetShader(context, ps[0], NULL, 0);
+ draw_quad(&test_context);
+ check_texture_uvec4(texture, &tests[i].dst0);
+
+ ID3D11DeviceContext_PSSetShader(context, ps[1], NULL, 0);
+ draw_quad(&test_context);
+ check_texture_uvec4(texture, &tests[i].dst1);
+
+ ID3D11DeviceContext_PSSetShader(context, ps[2], NULL, 0);
+ draw_quad(&test_context);
+ check_texture_uvec4(texture, &tests[i].dst0);
+
+ ID3D11DeviceContext_PSSetShader(context, ps[3], NULL, 0);
+ draw_quad(&test_context);
+ check_texture_uvec4(texture, &tests[i].dst1);
+
+ ID3D11DeviceContext_PSSetShader(context, ps[4], NULL, 0);
+ draw_quad(&test_context);
+ check_texture_uvec4(texture, &tests[i].dst0);
+
+ ID3D11DeviceContext_PSSetShader(context, ps[5], NULL, 0);
+ draw_quad(&test_context);
+ check_texture_uvec4(texture, &tests[i].dst1);
+ }
+
+ for (i = 0; i < ARRAY_SIZE(ps); ++i)
+ ID3D11PixelShader_Release(ps[i]);
+ ID3D11RenderTargetView_Release(rtv);
+ ID3D11Texture2D_Release(texture);
+ ID3D11Buffer_Release(cb);
+ release_test_context(&test_context);
+}
+
static void test_create_input_layout(void)
{
D3D11_INPUT_ELEMENT_DESC layout_desc[] =
@@ -20360,6 +20633,7 @@ START_TEST(d3d11)
test_sm4_if_instruction();
test_sm4_breakc_instruction();
test_sm4_continuec_instruction();
+ test_sm5_swapc_instruction();
test_create_input_layout();
test_input_assembler();
test_null_sampler();
--
2.13.0
More information about the wine-patches
mailing list