d3d10core/tests: Add test for ResolveSubresource().

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 2018-04-25 11:23:53 +02:00 committed by Alexandre Julliard
parent a81a6d6eab
commit f4b1b20190
1 changed files with 139 additions and 0 deletions

View File

@ -16568,6 +16568,144 @@ static void test_multiple_viewports(void)
release_test_context(&test_context);
}
static void test_multisample_resolve(void)
{
struct d3d10core_test_context test_context;
D3D10_RENDER_TARGET_VIEW_DESC rtv_desc;
ID3D10Texture2D *texture, *ms_texture;
D3D10_TEXTURE2D_DESC texture_desc;
ID3D10RenderTargetView *rtv;
ID3D10Device *device;
unsigned int i;
HRESULT hr;
static const float white[] = {1.0f, 1.0f, 1.0f, 1.0f};
static const struct vec4 green = {0.0f, 1.0f, 0.0f, 1.0f};
static const struct vec4 color = {0.25f, 0.5f, 0.75f, 1.0f};
static const struct
{
DXGI_FORMAT src_format;
DXGI_FORMAT dst_format;
DXGI_FORMAT format;
DXGI_FORMAT rtv_format;
const struct vec4 *color;
DWORD expected_color;
BOOL todo;
}
tests[] =
{
{DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_R8G8B8A8_UNORM,
&green, 0xff00ff00},
{DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
&green, 0xff00ff00},
{DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_R8G8B8A8_UNORM,
&color, 0xffbf7f40},
{DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
&color, 0xffe1bc89},
{DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
DXGI_FORMAT_R8G8B8A8_TYPELESS,
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
&green, 0xff00ff00, TRUE},
{DXGI_FORMAT_R8G8B8A8_TYPELESS,
DXGI_FORMAT_R8G8B8A8_TYPELESS,
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
&green, 0xff00ff00, TRUE},
{DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
DXGI_FORMAT_R8G8B8A8_TYPELESS,
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
&color, 0xffe1bc89, TRUE},
{DXGI_FORMAT_R8G8B8A8_TYPELESS,
DXGI_FORMAT_R8G8B8A8_TYPELESS,
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
&color, 0xffe1bc89, TRUE},
{DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_R8G8B8A8_TYPELESS,
DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_R8G8B8A8_UNORM,
&green, 0xff00ff00, TRUE},
{DXGI_FORMAT_R8G8B8A8_TYPELESS,
DXGI_FORMAT_R8G8B8A8_TYPELESS,
DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_R8G8B8A8_UNORM,
&green, 0xff00ff00, TRUE},
{DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_R8G8B8A8_TYPELESS,
DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_R8G8B8A8_UNORM,
&color, 0xffbf7f40, TRUE},
{DXGI_FORMAT_R8G8B8A8_TYPELESS,
DXGI_FORMAT_R8G8B8A8_TYPELESS,
DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_R8G8B8A8_UNORM,
&color, 0xffbf7f40, TRUE},
};
if (!init_test_context(&test_context))
return;
device = test_context.device;
if (FAILED(hr = ID3D10Device_CheckMultisampleQualityLevels(device,
DXGI_FORMAT_R8G8B8A8_TYPELESS, 4, &i)))
{
skip("4xMSAA not supported.\n");
release_test_context(&test_context);
return;
}
for (i = 0; i < ARRAY_SIZE(tests); ++i)
{
ID3D10Texture2D_GetDesc(test_context.backbuffer, &texture_desc);
texture_desc.Format = tests[i].dst_format;
hr = ID3D10Device_CreateTexture2D(device, &texture_desc, NULL, &texture);
ok(hr == S_OK, "Failed to create texture, hr %#x.\n", hr);
texture_desc.Format = tests[i].src_format;
texture_desc.SampleDesc.Count = 4;
texture_desc.SampleDesc.Quality = 0;
hr = ID3D10Device_CreateTexture2D(device, &texture_desc, NULL, &ms_texture);
ok(hr == S_OK, "Failed to create texture, hr %#x.\n", hr);
rtv_desc.Format = tests[i].rtv_format;
rtv_desc.ViewDimension = D3D10_RTV_DIMENSION_TEXTURE2DMS;
hr = ID3D10Device_CreateRenderTargetView(device, (ID3D10Resource *)ms_texture, &rtv_desc, &rtv);
ok(hr == S_OK, "Failed to create render target view, hr %#x.\n", hr);
ID3D10Device_OMSetRenderTargets(device, 1, &rtv, NULL);
ID3D10Device_ClearRenderTargetView(device, rtv, white);
draw_color_quad(&test_context, tests[i].color);
ID3D10Device_ResolveSubresource(device, (ID3D10Resource *)texture, 0,
(ID3D10Resource *)ms_texture, 0, tests[i].format);
todo_wine_if(tests[i].todo)
check_texture_color(texture, tests[i].expected_color, 2);
ID3D10RenderTargetView_Release(rtv);
ID3D10Texture2D_Release(ms_texture);
ID3D10Texture2D_Release(texture);
}
release_test_context(&test_context);
}
START_TEST(device)
{
unsigned int argc, i;
@ -16670,4 +16808,5 @@ START_TEST(device)
test_generate_mips();
test_alpha_to_coverage();
test_multiple_viewports();
test_multisample_resolve();
}