Commit b3602e4c authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

d3d11/tests: Add test for SM5 bufinfo instruction.

parent bdccf5e1
......@@ -11936,6 +11936,301 @@ static void test_primitive_restart(void)
release_test_context(&test_context);
}
static void test_sm5_bufinfo_instruction(void)
{
struct shader
{
const DWORD *code;
size_t size;
};
D3D11_UNORDERED_ACCESS_VIEW_DESC uav_desc;
D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc;
struct d3d11_test_context test_context;
D3D11_TEXTURE2D_DESC texture_desc;
const struct shader *current_ps;
ID3D11UnorderedAccessView *uav;
ID3D11ShaderResourceView *srv;
D3D11_BUFFER_DESC buffer_desc;
ID3D11DeviceContext *context;
ID3D11RenderTargetView *rtv;
ID3D11Texture2D *texture;
ID3D11PixelShader *ps;
ID3D11Buffer *buffer;
ID3D11Device *device;
unsigned int i;
HRESULT hr;
static const D3D_FEATURE_LEVEL feature_level = D3D_FEATURE_LEVEL_11_0;
static const DWORD ps_uav_structured_code[] =
{
#if 0
struct s
{
uint4 u;
bool b;
};
RWStructuredBuffer<s> b;
uint4 main(void) : SV_Target
{
uint count, stride;
b.GetDimensions(count, stride);
return uint4(count, stride, 0, 1);
}
#endif
0x43425844, 0xe1900f85, 0x13c1f338, 0xbb19865e, 0x366df28f, 0x00000001, 0x000000fc, 0x00000003,
0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000084, 0x00000050, 0x00000021,
0x0100086a, 0x0400009e, 0x0011e000, 0x00000001, 0x00000014, 0x03000065, 0x001020f2, 0x00000000,
0x02000068, 0x00000001, 0x87000079, 0x8000a302, 0x00199983, 0x00100012, 0x00000000, 0x0011ee46,
0x00000001, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x08000036, 0x001020e2,
0x00000000, 0x00004002, 0x00000000, 0x00000014, 0x00000000, 0x00000001, 0x0100003e,
};
static const struct shader ps_uav_structured = {ps_uav_structured_code, sizeof(ps_uav_structured_code)};
static const DWORD ps_srv_structured_code[] =
{
#if 0
StructuredBuffer<bool> b;
uint4 main(void) : SV_Target
{
uint count, stride;
b.GetDimensions(count, stride);
return uint4(count, stride, 0, 1);
}
#endif
0x43425844, 0x313f910c, 0x2f60c646, 0x2d87455c, 0xb9988c2c, 0x00000001, 0x000000fc, 0x00000003,
0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000084, 0x00000050, 0x00000021,
0x0100086a, 0x040000a2, 0x00107000, 0x00000000, 0x00000004, 0x03000065, 0x001020f2, 0x00000000,
0x02000068, 0x00000001, 0x87000079, 0x80002302, 0x00199983, 0x00100012, 0x00000000, 0x00107e46,
0x00000000, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x08000036, 0x001020e2,
0x00000000, 0x00004002, 0x00000000, 0x00000004, 0x00000000, 0x00000001, 0x0100003e,
};
static const struct shader ps_srv_structured = {ps_srv_structured_code, sizeof(ps_srv_structured_code)};
static const DWORD ps_uav_raw_code[] =
{
#if 0
RWByteAddressBuffer b;
uint4 main(void) : SV_Target
{
uint width;
b.GetDimensions(width);
return width;
}
#endif
0x43425844, 0xb06e9715, 0x99733b00, 0xaa536550, 0x703a01c5, 0x00000001, 0x000000d8, 0x00000003,
0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000060, 0x00000050, 0x00000018,
0x0100086a, 0x0300009d, 0x0011e000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
0x00000001, 0x87000079, 0x800002c2, 0x00199983, 0x00100012, 0x00000000, 0x0011ee46, 0x00000001,
0x05000036, 0x001020f2, 0x00000000, 0x00100006, 0x00000000, 0x0100003e,
};
static const struct shader ps_uav_raw = {ps_uav_raw_code, sizeof(ps_uav_raw_code)};
static const DWORD ps_srv_raw_code[] =
{
#if 0
ByteAddressBuffer b;
uint4 main(void) : SV_Target
{
uint width;
b.GetDimensions(width);
return width;
}
#endif
0x43425844, 0x934bc27a, 0x3251cc9d, 0xa129bdd3, 0xf7cedcc4, 0x00000001, 0x000000d8, 0x00000003,
0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000060, 0x00000050, 0x00000018,
0x0100086a, 0x030000a1, 0x00107000, 0x00000000, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
0x00000001, 0x87000079, 0x800002c2, 0x00199983, 0x00100012, 0x00000000, 0x00107e46, 0x00000000,
0x05000036, 0x001020f2, 0x00000000, 0x00100006, 0x00000000, 0x0100003e,
};
static const struct shader ps_srv_raw = {ps_srv_raw_code, sizeof(ps_srv_raw_code)};
static const DWORD ps_uav_typed_code[] =
{
#if 0
RWBuffer<float> b;
uint4 main(void) : SV_Target
{
uint width;
b.GetDimensions(width);
return width;
}
#endif
0x43425844, 0x96b39f5f, 0x5fef24c7, 0xed404a41, 0x01c9d4fe, 0x00000001, 0x000000dc, 0x00000003,
0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000064, 0x00000050, 0x00000019,
0x0100086a, 0x0400089c, 0x0011e000, 0x00000001, 0x00005555, 0x03000065, 0x001020f2, 0x00000000,
0x02000068, 0x00000001, 0x87000079, 0x80000042, 0x00155543, 0x00100012, 0x00000000, 0x0011ee46,
0x00000001, 0x05000036, 0x001020f2, 0x00000000, 0x00100006, 0x00000000, 0x0100003e,
};
static const struct shader ps_uav_typed = {ps_uav_typed_code, sizeof(ps_uav_typed_code)};
static const DWORD ps_srv_typed_code[] =
{
#if 0
Buffer<float> b;
uint4 main(void) : SV_Target
{
uint width;
b.GetDimensions(width);
return width;
}
#endif
0x43425844, 0x6ae6dbb0, 0x6289d227, 0xaf4e708e, 0x111efed1, 0x00000001, 0x000000dc, 0x00000003,
0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000064, 0x00000050, 0x00000019,
0x0100086a, 0x04000858, 0x00107000, 0x00000000, 0x00005555, 0x03000065, 0x001020f2, 0x00000000,
0x02000068, 0x00000001, 0x87000079, 0x80000042, 0x00155543, 0x00100012, 0x00000000, 0x00107e46,
0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00100006, 0x00000000, 0x0100003e,
};
static const struct shader ps_srv_typed = {ps_srv_typed_code, sizeof(ps_srv_typed_code)};
static const struct test
{
const struct shader *ps;
BOOL uav;
unsigned int buffer_size;
unsigned int buffer_misc_flags;
unsigned int buffer_structure_byte_stride;
DXGI_FORMAT view_format;
unsigned int view_element_idx;
unsigned int view_element_count;
struct uvec4 expected_result;
}
tests[] =
{
#define RAW D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS
#define STRUCTURED D3D11_RESOURCE_MISC_BUFFER_STRUCTURED
{&ps_uav_raw, TRUE, 100, RAW, 0, DXGI_FORMAT_R32_TYPELESS, 0, 25, {100, 100, 100, 100}},
{&ps_uav_raw, TRUE, 100, RAW, 0, DXGI_FORMAT_R32_TYPELESS, 8, 17, { 68, 68, 68, 68}},
{&ps_srv_raw, FALSE, 100, RAW, 0, DXGI_FORMAT_R32_TYPELESS, 0, 25, {100, 100, 100, 100}},
{&ps_srv_raw, FALSE, 100, RAW, 0, DXGI_FORMAT_R32_TYPELESS, 8, 17, { 68, 68, 68, 68}},
{&ps_uav_structured, TRUE, 100, STRUCTURED, 20, DXGI_FORMAT_UNKNOWN, 0, 5, { 5, 20, 0, 1}},
{&ps_uav_structured, TRUE, 100, STRUCTURED, 20, DXGI_FORMAT_UNKNOWN, 0, 2, { 2, 20, 0, 1}},
{&ps_uav_structured, TRUE, 100, STRUCTURED, 20, DXGI_FORMAT_UNKNOWN, 1, 2, { 2, 20, 0, 1}},
{&ps_srv_structured, FALSE, 100, STRUCTURED, 4, DXGI_FORMAT_UNKNOWN, 0, 5, { 5, 4, 0, 1}},
{&ps_srv_structured, FALSE, 100, STRUCTURED, 4, DXGI_FORMAT_UNKNOWN, 0, 2, { 2, 4, 0, 1}},
{&ps_srv_structured, FALSE, 100, STRUCTURED, 4, DXGI_FORMAT_UNKNOWN, 1, 2, { 2, 4, 0, 1}},
{&ps_uav_typed, TRUE, 200, 0, 0, DXGI_FORMAT_R32_FLOAT, 0, 50, { 50, 50, 50, 50}},
{&ps_uav_typed, TRUE, 200, 0, 0, DXGI_FORMAT_R32_FLOAT, 49, 1, { 1, 1, 1, 1}},
{&ps_uav_typed, TRUE, 100, 0, 0, DXGI_FORMAT_R16_FLOAT, 0, 50, { 50, 50, 50, 50}},
{&ps_uav_typed, TRUE, 100, 0, 0, DXGI_FORMAT_R16_FLOAT, 49, 1, { 1, 1, 1, 1}},
{&ps_srv_typed, FALSE, 200, 0, 0, DXGI_FORMAT_R32_FLOAT, 0, 50, { 50, 50, 50, 50}},
{&ps_srv_typed, FALSE, 200, 0, 0, DXGI_FORMAT_R32_FLOAT, 49, 1, { 1, 1, 1, 1}},
{&ps_srv_typed, FALSE, 100, 0, 0, DXGI_FORMAT_R16_FLOAT, 0, 50, { 50, 50, 50, 50}},
{&ps_srv_typed, FALSE, 100, 0, 0, DXGI_FORMAT_R16_FLOAT, 49, 1, { 1, 1, 1, 1}},
#undef RAW
#undef STRUCTURED
};
if (!init_test_context(&test_context, &feature_level))
return;
device = test_context.device;
context = test_context.immediate_context;
texture_desc.Width = 64;
texture_desc.Height = 64;
texture_desc.MipLevels = 1;
texture_desc.ArraySize = 1;
texture_desc.Format = DXGI_FORMAT_R32G32B32A32_UINT;
texture_desc.SampleDesc.Count = 1;
texture_desc.SampleDesc.Quality = 0;
texture_desc.Usage = D3D11_USAGE_DEFAULT;
texture_desc.BindFlags = D3D11_BIND_RENDER_TARGET;
texture_desc.CPUAccessFlags = 0;
texture_desc.MiscFlags = 0;
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 rendertarget view, hr %#x.\n", hr);
ps = NULL;
current_ps = NULL;
for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i)
{
const struct test *test = &tests[i];
if (current_ps != test->ps)
{
if (ps)
ID3D11PixelShader_Release(ps);
current_ps = test->ps;
hr = ID3D11Device_CreatePixelShader(device, current_ps->code, current_ps->size, NULL, &ps);
ok(SUCCEEDED(hr), "Test %u: Failed to create pixel shader, hr %#x.\n", i, hr);
ID3D11DeviceContext_PSSetShader(context, ps, NULL, 0);
}
buffer_desc.ByteWidth = test->buffer_size;
buffer_desc.Usage = D3D11_USAGE_DEFAULT;
buffer_desc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_UNORDERED_ACCESS;
buffer_desc.CPUAccessFlags = 0;
buffer_desc.MiscFlags = test->buffer_misc_flags;
buffer_desc.StructureByteStride = test->buffer_structure_byte_stride;
hr = ID3D11Device_CreateBuffer(device, &buffer_desc, NULL, &buffer);
ok(SUCCEEDED(hr), "Test %u: Failed to create buffer, hr %#x.\n", i, hr);
if (test->uav)
{
uav_desc.Format = test->view_format;
uav_desc.ViewDimension = D3D11_UAV_DIMENSION_BUFFER;
U(uav_desc).Buffer.FirstElement = test->view_element_idx;
U(uav_desc).Buffer.NumElements = test->view_element_count;
U(uav_desc).Buffer.Flags = 0;
if (buffer_desc.MiscFlags & D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS)
U(uav_desc).Buffer.Flags |= D3D11_BUFFER_UAV_FLAG_RAW;
hr = ID3D11Device_CreateUnorderedAccessView(device, (ID3D11Resource *)buffer, &uav_desc, &uav);
ok(SUCCEEDED(hr), "Test %u: Failed to create unordered access view, hr %#x.\n", i, hr);
srv = NULL;
ID3D11DeviceContext_OMSetRenderTargetsAndUnorderedAccessViews(context, 1, &rtv, NULL,
1, 1, &uav, NULL);
}
else
{
srv_desc.Format = test->view_format;
srv_desc.ViewDimension = D3D11_SRV_DIMENSION_BUFFEREX;
U(srv_desc).BufferEx.FirstElement = test->view_element_idx;
U(srv_desc).BufferEx.NumElements = test->view_element_count;
U(srv_desc).BufferEx.Flags = 0;
if (buffer_desc.MiscFlags & D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS)
U(srv_desc).BufferEx.Flags |= D3D11_BUFFER_UAV_FLAG_RAW;
hr = ID3D11Device_CreateShaderResourceView(device, (ID3D11Resource *)buffer, &srv_desc, &srv);
ok(SUCCEEDED(hr), "Test %u: Failed to create shader resource view, hr %#x.\n", i, hr);
uav = NULL;
ID3D11DeviceContext_PSSetShaderResources(context, 0, 1, &srv);
}
draw_quad(&test_context);
todo_wine check_texture_uvec4(texture, &test->expected_result);
if (srv)
ID3D11ShaderResourceView_Release(srv);
if (uav)
ID3D11UnorderedAccessView_Release(uav);
ID3D11Buffer_Release(buffer);
}
ID3D11PixelShader_Release(ps);
ID3D11RenderTargetView_Release(rtv);
ID3D11Texture2D_Release(texture);
release_test_context(&test_context);
}
START_TEST(d3d11)
{
test_create_device();
......@@ -12002,4 +12297,5 @@ START_TEST(d3d11)
test_uav_load();
test_sm4_ret_instruction();
test_primitive_restart();
test_sm5_bufinfo_instruction();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment