d3d10core/tests: Port test_resinfo_instruction() from d3d11.

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:
Józef Kucia 2017-02-13 13:07:32 +01:00 committed by Alexandre Julliard
parent 1226765403
commit 2d3e23c60f
1 changed files with 315 additions and 0 deletions

View File

@ -10625,6 +10625,320 @@ static void test_primitive_restart(void)
release_test_context(&test_context);
}
static void test_resinfo_instruction(void)
{
struct shader
{
const DWORD *code;
size_t size;
};
struct d3d10core_test_context test_context;
D3D10_TEXTURE3D_DESC texture3d_desc;
D3D10_TEXTURE2D_DESC texture_desc;
const struct shader *current_ps;
ID3D10ShaderResourceView *srv;
ID3D10Texture2D *rtv_texture;
ID3D10RenderTargetView *rtv;
ID3D10Resource *texture;
struct uvec4 constant;
ID3D10PixelShader *ps;
ID3D10Device *device;
unsigned int i, type;
ID3D10Buffer *cb;
HRESULT hr;
static const DWORD ps_2d_code[] =
{
#if 0
Texture2D t;
uint type;
uint level;
float4 main() : SV_TARGET
{
if (!type)
{
float width, height, miplevels;
t.GetDimensions(level, width, height, miplevels);
return float4(width, height, miplevels, 0);
}
else
{
uint width, height, miplevels;
t.GetDimensions(level, width, height, miplevels);
return float4(width, height, miplevels, 0);
}
}
#endif
0x43425844, 0x9c2db58d, 0x7218d757, 0x23255414, 0xaa86938e, 0x00000001, 0x00000168, 0x00000003,
0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x000000f0, 0x00000040, 0x0000003c,
0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0400001f, 0x0020800a, 0x00000000,
0x00000000, 0x0800003d, 0x001000f2, 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x00107e46,
0x00000000, 0x05000036, 0x00102072, 0x00000000, 0x00100346, 0x00000000, 0x05000036, 0x00102082,
0x00000000, 0x00004001, 0x00000000, 0x0100003e, 0x01000012, 0x0800103d, 0x001000f2, 0x00000000,
0x0020801a, 0x00000000, 0x00000000, 0x00107e46, 0x00000000, 0x05000056, 0x00102072, 0x00000000,
0x00100346, 0x00000000, 0x05000036, 0x00102082, 0x00000000, 0x00004001, 0x00000000, 0x0100003e,
0x01000015, 0x0100003e,
};
static const struct shader ps_2d = {ps_2d_code, sizeof(ps_2d_code)};
static const DWORD ps_2d_array_code[] =
{
#if 0
Texture2DArray t;
uint type;
uint level;
float4 main() : SV_TARGET
{
if (!type)
{
float width, height, elements, miplevels;
t.GetDimensions(level, width, height, elements, miplevels);
return float4(width, height, elements, miplevels);
}
else
{
uint width, height, elements, miplevels;
t.GetDimensions(level, width, height, elements, miplevels);
return float4(width, height, elements, miplevels);
}
}
#endif
0x43425844, 0x92cd8789, 0x38e359ac, 0xd65ab502, 0xa018a5ae, 0x00000001, 0x0000012c, 0x00000003,
0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x000000b4, 0x00000040, 0x0000002d,
0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04004058, 0x00107000, 0x00000000, 0x00005555,
0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0400001f, 0x0020800a, 0x00000000,
0x00000000, 0x0800003d, 0x001020f2, 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x00107e46,
0x00000000, 0x0100003e, 0x01000012, 0x0800103d, 0x001000f2, 0x00000000, 0x0020801a, 0x00000000,
0x00000000, 0x00107e46, 0x00000000, 0x05000056, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000,
0x0100003e, 0x01000015, 0x0100003e,
};
static const struct shader ps_2d_array = {ps_2d_array_code, sizeof(ps_2d_array_code)};
static const DWORD ps_3d_code[] =
{
#if 0
Texture3D t;
uint type;
uint level;
float4 main() : SV_TARGET
{
if (!type)
{
float width, height, depth, miplevels;
t.GetDimensions(level, width, height, depth, miplevels);
return float4(width, height, depth, miplevels);
}
else
{
uint width, height, depth, miplevels;
t.GetDimensions(level, width, height, depth, miplevels);
return float4(width, height, depth, miplevels);
}
}
#endif
0x43425844, 0xac1f73b9, 0x2bce1322, 0x82c599e6, 0xbff0d681, 0x00000001, 0x0000012c, 0x00000003,
0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x000000b4, 0x00000040, 0x0000002d,
0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04002858, 0x00107000, 0x00000000, 0x00005555,
0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0400001f, 0x0020800a, 0x00000000,
0x00000000, 0x0800003d, 0x001020f2, 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x00107e46,
0x00000000, 0x0100003e, 0x01000012, 0x0800103d, 0x001000f2, 0x00000000, 0x0020801a, 0x00000000,
0x00000000, 0x00107e46, 0x00000000, 0x05000056, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000,
0x0100003e, 0x01000015, 0x0100003e,
};
static const struct shader ps_3d = {ps_3d_code, sizeof(ps_3d_code)};
static const DWORD ps_cube_code[] =
{
#if 0
TextureCube t;
uint type;
uint level;
float4 main() : SV_TARGET
{
if (!type)
{
float width, height, miplevels;
t.GetDimensions(level, width, height, miplevels);
return float4(width, height, miplevels, 0);
}
else
{
uint width, height, miplevels;
t.GetDimensions(level, width, height, miplevels);
return float4(width, height, miplevels, 0);
}
}
#endif
0x43425844, 0x795eb161, 0xb8291400, 0xcc531086, 0x2a8143ce, 0x00000001, 0x00000168, 0x00000003,
0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x000000f0, 0x00000040, 0x0000003c,
0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04003058, 0x00107000, 0x00000000, 0x00005555,
0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0400001f, 0x0020800a, 0x00000000,
0x00000000, 0x0800003d, 0x001000f2, 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x00107e46,
0x00000000, 0x05000036, 0x00102072, 0x00000000, 0x00100346, 0x00000000, 0x05000036, 0x00102082,
0x00000000, 0x00004001, 0x00000000, 0x0100003e, 0x01000012, 0x0800103d, 0x001000f2, 0x00000000,
0x0020801a, 0x00000000, 0x00000000, 0x00107e46, 0x00000000, 0x05000056, 0x00102072, 0x00000000,
0x00100346, 0x00000000, 0x05000036, 0x00102082, 0x00000000, 0x00004001, 0x00000000, 0x0100003e,
0x01000015, 0x0100003e,
};
static const struct shader ps_cube = {ps_cube_code, sizeof(ps_cube_code)};
static const struct test
{
const struct shader *ps;
struct
{
unsigned int width;
unsigned int height;
unsigned int depth;
unsigned int miplevel_count;
unsigned int array_size;
unsigned int cube_count;
} texture_desc;
unsigned int miplevel;
struct vec4 expected_result;
}
tests[] =
{
{&ps_2d, {64, 64, 1, 1, 1, 0}, 0, {64.0f, 64.0f, 1.0f, 0.0f}},
{&ps_2d, {32, 16, 1, 3, 1, 0}, 0, {32.0f, 16.0f, 3.0f, 0.0f}},
{&ps_2d, {32, 16, 1, 3, 1, 0}, 1, {16.0f, 8.0f, 3.0f, 0.0f}},
{&ps_2d, {32, 16, 1, 3, 1, 0}, 2, { 8.0f, 4.0f, 3.0f, 0.0f}},
{&ps_2d_array, {64, 64, 1, 1, 6, 0}, 0, {64.0f, 64.0f, 6.0f, 1.0f}},
{&ps_2d_array, {32, 16, 1, 3, 9, 0}, 0, {32.0f, 16.0f, 9.0f, 3.0f}},
{&ps_2d_array, {32, 16, 1, 3, 7, 0}, 1, {16.0f, 8.0f, 7.0f, 3.0f}},
{&ps_2d_array, {32, 16, 1, 3, 3, 0}, 2, { 8.0f, 4.0f, 3.0f, 3.0f}},
{&ps_3d, {64, 64, 2, 1, 1, 0}, 0, {64.0f, 64.0f, 2.0f, 1.0f}},
{&ps_3d, {64, 64, 2, 2, 1, 0}, 1, {32.0f, 32.0f, 1.0f, 2.0f}},
{&ps_3d, {64, 64, 4, 1, 1, 0}, 0, {64.0f, 64.0f, 4.0f, 1.0f}},
{&ps_3d, {64, 64, 4, 2, 1, 0}, 1, {32.0f, 32.0f, 2.0f, 2.0f}},
{&ps_3d, { 8, 8, 8, 1, 1, 0}, 0, { 8.0f, 8.0f, 8.0f, 1.0f}},
{&ps_3d, { 8, 8, 8, 4, 1, 0}, 0, { 8.0f, 8.0f, 8.0f, 4.0f}},
{&ps_3d, { 8, 8, 8, 4, 1, 0}, 1, { 4.0f, 4.0f, 4.0f, 4.0f}},
{&ps_3d, { 8, 8, 8, 4, 1, 0}, 2, { 2.0f, 2.0f, 2.0f, 4.0f}},
{&ps_3d, { 8, 8, 8, 4, 1, 0}, 3, { 1.0f, 1.0f, 1.0f, 4.0f}},
{&ps_cube, { 4, 4, 1, 1, 6, 1}, 0, { 4.0f, 4.0f, 1.0f, 0.0f}},
{&ps_cube, {32, 32, 1, 1, 6, 1}, 0, {32.0f, 32.0f, 1.0f, 0.0f}},
{&ps_cube, {32, 32, 1, 3, 6, 1}, 0, {32.0f, 32.0f, 3.0f, 0.0f}},
{&ps_cube, {32, 32, 1, 3, 6, 1}, 1, {16.0f, 16.0f, 3.0f, 0.0f}},
{&ps_cube, {32, 32, 1, 3, 6, 1}, 2, { 8.0f, 8.0f, 3.0f, 0.0f}},
};
if (!init_test_context(&test_context))
return;
device = test_context.device;
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 = D3D10_USAGE_DEFAULT;
texture_desc.BindFlags = D3D10_BIND_RENDER_TARGET;
texture_desc.CPUAccessFlags = 0;
texture_desc.MiscFlags = 0;
hr = ID3D10Device_CreateTexture2D(device, &texture_desc, NULL, &rtv_texture);
ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
hr = ID3D10Device_CreateRenderTargetView(device, (ID3D10Resource *)rtv_texture, NULL, &rtv);
ok(SUCCEEDED(hr), "Failed to create rendertarget view, hr %#x.\n", hr);
memset(&constant, 0, sizeof(constant));
cb = create_buffer(device, D3D10_BIND_CONSTANT_BUFFER, sizeof(constant), &constant);
ID3D10Device_OMSetRenderTargets(device, 1, &rtv, NULL);
ID3D10Device_PSSetConstantBuffers(device, 0, 1, &cb);
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)
ID3D10PixelShader_Release(ps);
current_ps = test->ps;
hr = ID3D10Device_CreatePixelShader(device, current_ps->code, current_ps->size, &ps);
ok(SUCCEEDED(hr), "Test %u: Failed to create pixel shader, hr %#x.\n", i, hr);
ID3D10Device_PSSetShader(device, ps);
}
if (test->texture_desc.depth != 1)
{
texture3d_desc.Width = test->texture_desc.width;
texture3d_desc.Height = test->texture_desc.height;
texture3d_desc.Depth = test->texture_desc.depth;
texture3d_desc.MipLevels = test->texture_desc.miplevel_count;
texture3d_desc.Format = DXGI_FORMAT_R8_UNORM;
texture3d_desc.Usage = D3D10_USAGE_DEFAULT;
texture3d_desc.BindFlags = D3D10_BIND_SHADER_RESOURCE;
texture3d_desc.CPUAccessFlags = 0;
texture3d_desc.MiscFlags = 0;
hr = ID3D10Device_CreateTexture3D(device, &texture3d_desc, NULL, (ID3D10Texture3D **)&texture);
ok(SUCCEEDED(hr), "Test %u: Failed to create 3d texture, hr %#x.\n", i, hr);
}
else
{
texture_desc.Width = test->texture_desc.width;
texture_desc.Height = test->texture_desc.height;
texture_desc.MipLevels = test->texture_desc.miplevel_count;
texture_desc.ArraySize = test->texture_desc.array_size;
texture_desc.Format = DXGI_FORMAT_R8_UNORM;
texture_desc.BindFlags = D3D10_BIND_SHADER_RESOURCE;
texture_desc.MiscFlags = 0;
if (test->texture_desc.cube_count)
texture_desc.MiscFlags |= D3D10_RESOURCE_MISC_TEXTURECUBE;
hr = ID3D10Device_CreateTexture2D(device, &texture_desc, NULL, (ID3D10Texture2D **)&texture);
ok(SUCCEEDED(hr), "Test %u: Failed to create 2d texture, hr %#x.\n", i, hr);
}
hr = ID3D10Device_CreateShaderResourceView(device, texture, NULL, &srv);
ok(SUCCEEDED(hr), "Test %u: Failed to create shader resource view, hr %#x.\n", i, hr);
ID3D10Device_PSSetShaderResources(device, 0, 1, &srv);
for (type = 0; type < 2; ++type)
{
constant.x = type;
constant.y = test->miplevel;
ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)cb, 0, NULL, &constant, 0, 0);
draw_quad(&test_context);
check_texture_vec4(rtv_texture, &test->expected_result, 0);
}
ID3D10Resource_Release(texture);
ID3D10ShaderResourceView_Release(srv);
}
ID3D10PixelShader_Release(ps);
ID3D10Buffer_Release(cb);
ID3D10RenderTargetView_Release(rtv);
ID3D10Texture2D_Release(rtv_texture);
release_test_context(&test_context);
}
static void test_render_target_device_mismatch(void)
{
struct d3d10core_test_context test_context;
@ -10893,6 +11207,7 @@ START_TEST(device)
test_stencil_separate();
test_sm4_ret_instruction();
test_primitive_restart();
test_resinfo_instruction();
test_render_target_device_mismatch();
test_buffer_srv();
}