[PATCH 7/7] d3d11/tests: Add test for bitwise shader instructions.
Józef Kucia
jkucia at codeweavers.com
Mon Jul 18 06:27:40 CDT 2016
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
dlls/d3d11/tests/d3d11.c | 207 ++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 195 insertions(+), 12 deletions(-)
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index e20b99b..aad9a57 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -821,6 +821,52 @@ static void check_texture_vec4_(unsigned int line, ID3D11Texture2D *texture,
check_texture_sub_resource_vec4_(line, texture, sub_resource_idx, expected_value, max_diff);
}
+#define check_texture_sub_resource_uvec4(a, b, c) check_texture_sub_resource_uvec4_(__LINE__, a, b, c)
+static void check_texture_sub_resource_uvec4_(unsigned int line, ID3D11Texture2D *texture,
+ unsigned int sub_resource_idx, const struct uvec4 *expected_value)
+{
+ struct texture_readback rb;
+ unsigned int x = 0, y = 0;
+ struct uvec4 value = {0};
+ BOOL all_match = TRUE;
+
+ get_texture_readback(texture, sub_resource_idx, &rb);
+ for (y = 0; y < rb.height; ++y)
+ {
+ for (x = 0; x < rb.width; ++x)
+ {
+ value = *get_readback_uvec4(&rb, x, y);
+ if (!compare_uvec4(&value, expected_value))
+ {
+ all_match = FALSE;
+ break;
+ }
+ }
+ if (!all_match)
+ break;
+ }
+ release_texture_readback(&rb);
+ ok_(__FILE__, line)(all_match,
+ "Got {0x%08x, 0x%08x, 0x%08x, 0x%08x}, expected {0x%08x, 0x%08x, 0x%08x, 0x%08x} "
+ "at (%u, %u), sub-resource %u.\n",
+ value.x, value.y, value.z, value.w,
+ expected_value->x, expected_value->y, expected_value->z, expected_value->w,
+ x, y, sub_resource_idx);
+}
+
+#define check_texture_uvec4(a, b) check_texture_uvec4_(__LINE__, a, b)
+static void check_texture_uvec4_(unsigned int line, ID3D11Texture2D *texture,
+ const struct uvec4 *expected_value)
+{
+ unsigned int sub_resource_idx, sub_resource_count;
+ D3D11_TEXTURE2D_DESC texture_desc;
+
+ ID3D11Texture2D_GetDesc(texture, &texture_desc);
+ sub_resource_count = texture_desc.ArraySize * texture_desc.MipLevels;
+ for (sub_resource_idx = 0; sub_resource_idx < sub_resource_count; ++sub_resource_idx)
+ check_texture_sub_resource_uvec4_(line, texture, sub_resource_idx, expected_value);
+}
+
static ID3D11Device *create_device(const struct device_desc *desc)
{
static const D3D_FEATURE_LEVEL default_feature_level[] =
@@ -9284,11 +9330,9 @@ static void test_fp_specials(void)
D3D11_TEXTURE2D_DESC texture_desc;
ID3D11DeviceContext *context;
ID3D11RenderTargetView *rtv;
- struct texture_readback rb;
ID3D11Texture2D *texture;
ID3D11PixelShader *ps;
ID3D11Device *device;
- unsigned int x, y;
HRESULT hr;
static const DWORD ps_code[] =
@@ -9306,7 +9350,7 @@ static void test_fp_specials(void)
0x03000065, 0x001020f2, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0xffc00000,
0x7f800000, 0xff800000, 0x3f800000, 0x0100003e,
};
- const struct uvec4 expected_result = {0xffc00000, 0x7f800000, 0xff800000, 0x3f800000};
+ static const struct uvec4 expected_result = {0xffc00000, 0x7f800000, 0xff800000, 0x3f800000};
if (!init_test_context(&test_context, NULL))
return;
@@ -9329,20 +9373,158 @@ static void test_fp_specials(void)
ID3D11DeviceContext_OMSetRenderTargets(context, 1, &rtv, NULL);
draw_quad(&test_context);
- get_texture_readback(texture, 0, &rb);
- for (y = 0; y < texture_desc.Height; ++y)
+ check_texture_uvec4(texture, &expected_result);
+
+ ID3D11PixelShader_Release(ps);
+ ID3D11Texture2D_Release(texture);
+ ID3D11RenderTargetView_Release(rtv);
+ release_test_context(&test_context);
+}
+
+static void test_bitwise_instructions(void)
+{
+ struct shader
+ {
+ const DWORD *code;
+ size_t size;
+ };
+
+ struct d3d11_test_context test_context;
+ D3D11_TEXTURE2D_DESC texture_desc;
+ ID3D11DeviceContext *context;
+ ID3D11RenderTargetView *rtv;
+ ID3D11Texture2D *texture;
+ ID3D11PixelShader *ps;
+ 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_bfi_code[] =
{
- for (x = 0; x < texture_desc.Width; ++x)
+#if 0
+ uint4 v;
+
+ uint4 main() : SV_Target
+ {
+ return uint4(4 * v.x + 1, 4 * v.y + 2, 4 * v.z + 3, 4 * v.w);
+ }
+#endif
+ 0x43425844, 0xb1a78f7c, 0xaf9d6725, 0x251fdbfc, 0x23c60c00, 0x00000001, 0x00000118, 0x00000003,
+ 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
+ 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
+ 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000a0, 0x00000050, 0x00000028,
+ 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
+ 0x1500008c, 0x00102072, 0x00000000, 0x00004002, 0x0000001e, 0x0000001e, 0x0000001e, 0x00000000,
+ 0x00004002, 0x00000002, 0x00000002, 0x00000002, 0x00000000, 0x00208246, 0x00000000, 0x00000000,
+ 0x00004002, 0x00000001, 0x00000002, 0x00000003, 0x00000000, 0x08000029, 0x00102082, 0x00000000,
+ 0x0020803a, 0x00000000, 0x00000000, 0x00004001, 0x00000002, 0x0100003e,
+ };
+ static const DWORD ps_bfrev_code[] =
+ {
+#if 0
+ uint bits;
+
+ uint4 main() : SV_Target
+ {
+ return uint4(reversebits(bits), reversebits(reversebits(bits)),
+ reversebits(bits & 0xFFFF), reversebits(bits >> 16));
+ }
+#endif
+ 0x43425844, 0x73daef82, 0xe52befa3, 0x8504d5f0, 0xebdb321d, 0x00000001, 0x00000154, 0x00000003,
+ 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
+ 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
+ 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000dc, 0x00000050, 0x00000037,
+ 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
+ 0x02000068, 0x00000001, 0x08000001, 0x00100012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000,
+ 0x00004001, 0x0000ffff, 0x0500008d, 0x00102042, 0x00000000, 0x0010000a, 0x00000000, 0x08000055,
+ 0x00100012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x00004001, 0x00000010, 0x0500008d,
+ 0x00102082, 0x00000000, 0x0010000a, 0x00000000, 0x0600008d, 0x00100012, 0x00000000, 0x0020800a,
+ 0x00000000, 0x00000000, 0x0500008d, 0x00102022, 0x00000000, 0x0010000a, 0x00000000, 0x05000036,
+ 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x0100003e,
+ };
+ static const DWORD ps_not_code[] =
+ {
+#if 0
+ uint bits[2];
+
+ uint4 main() : SV_Target
{
- const struct uvec4 *value = get_readback_uvec4(&rb, x, y);
- ok(compare_uvec4(value, &expected_result),
- "Got unexpected value {0x%08x, 0x%08x, 0x%08x, 0x%08x} at (%u, %u).\n",
- value->x, value->y, value->z, value->w, x, y);
+ return uint4(~bits[0], ~(bits[0] & ~0u), ~bits[1], ~(bits[1] & ~0u));
}
+#endif
+ 0x43425844, 0x6cebaa48, 0xc83105e3, 0xf3717eeb, 0x62f759f0, 0x00000001, 0x00000144, 0x00000003,
+ 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
+ 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
+ 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000cc, 0x00000050, 0x00000033,
+ 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000002, 0x03000065, 0x001020f2, 0x00000000,
+ 0x02000068, 0x00000001, 0x08000057, 0x00100012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000,
+ 0x00004001, 0xffffffff, 0x0500003b, 0x00102022, 0x00000000, 0x0010000a, 0x00000000, 0x08000057,
+ 0x00100012, 0x00000000, 0x0020800a, 0x00000000, 0x00000001, 0x00004001, 0xffffffff, 0x0500003b,
+ 0x00102082, 0x00000000, 0x0010000a, 0x00000000, 0x0600003b, 0x00102012, 0x00000000, 0x0020800a,
+ 0x00000000, 0x00000000, 0x0600003b, 0x00102042, 0x00000000, 0x0020800a, 0x00000000, 0x00000001,
+ 0x0100003e,
+ };
+ static const struct shader ps_bfi = {ps_bfi_code, sizeof(ps_bfi_code)};
+ static const struct shader ps_bfrev = {ps_bfrev_code, sizeof(ps_bfrev_code)};
+ static const struct shader ps_not = {ps_not_code, sizeof(ps_not_code)};
+ static const struct
+ {
+ const struct shader *ps;
+ unsigned int bits[4];
+ struct uvec4 expected_result;
+ BOOL todo;
}
- release_texture_readback(&rb);
+ tests[] =
+ {
+ {&ps_bfi, { 0, 0, 0, 0}, {1, 2, 3, 0}, TRUE},
+ {&ps_bfi, { 1, 1, 1, 1}, {5, 6, 7, 4}, TRUE},
+ {&ps_bfi, { 2, 3, 4, 5}, {9, 14, 19, 20}, TRUE},
+ {&ps_bfi, {~0u, ~0u, ~0u, ~0u}, {0xfffffffd, 0xfffffffe, 0xffffffff, 0xfffffffc}, TRUE},
+ {&ps_bfrev, {0x12345678}, {0x1e6a2c48, 0x12345678, 0x1e6a0000, 0x2c480000}, TRUE},
+ {&ps_bfrev, {0xffff0000}, {0x0000ffff, 0xffff0000, 0x00000000, 0xffff0000}, TRUE},
+ {&ps_bfrev, {0xffffffff}, {0xffffffff, 0xffffffff, 0xffff0000, 0xffff0000}, TRUE},
+ {&ps_not, {0x00000000, 0xffffffff}, {0xffffffff, 0x00000000, 0x00000000, 0xffffffff}},
+ {&ps_not, {0xf0f0f0f0, 0x0f0f0f0f}, {0x0f0f0f0f, 0xf0f0f0f0, 0xf0f0f0f0, 0x0f0f0f0f}},
- ID3D11PixelShader_Release(ps);
+ };
+
+ if (!init_test_context(&test_context, &feature_level))
+ return;
+
+ device = test_context.device;
+ context = test_context.immediate_context;
+
+ cb = create_buffer(device, D3D11_BIND_CONSTANT_BUFFER, 4 * sizeof(tests[0].bits), NULL);
+ ID3D11DeviceContext_PSSetConstantBuffers(context, 0, 1, &cb);
+
+ 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);
+
+ for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i)
+ {
+ hr = ID3D11Device_CreatePixelShader(device, tests[i].ps->code, tests[i].ps->size, NULL, &ps);
+ ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
+ ID3D11DeviceContext_PSSetShader(context, ps, NULL, 0);
+
+ ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)cb, 0, NULL, tests[i].bits, 0, 0);
+
+ draw_quad(&test_context);
+ todo_wine_if(tests[i].todo)
+ check_texture_uvec4(texture, &tests[i].expected_result);
+
+ ID3D11PixelShader_Release(ps);
+ }
+
+ ID3D11Buffer_Release(cb);
ID3D11Texture2D_Release(texture);
ID3D11RenderTargetView_Release(rtv);
release_test_context(&test_context);
@@ -9399,4 +9581,5 @@ START_TEST(d3d11)
test_create_unordered_access_view();
test_immediate_constant_buffer();
test_fp_specials();
+ test_bitwise_instructions();
}
--
2.7.3
More information about the wine-patches
mailing list