Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/d3d11/tests/d3d11.c | 141 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+)
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c index b3597ad1b394..36320f44bbb7 100644 --- a/dlls/d3d11/tests/d3d11.c +++ b/dlls/d3d11/tests/d3d11.c @@ -26110,6 +26110,146 @@ todo_wine release_test_context(&test_context); }
+static void test_multisample_resolve(void) +{ + struct d3d11_test_context test_context; + D3D11_RENDER_TARGET_VIEW_DESC rtv_desc; + ID3D11Texture2D *texture, *ms_texture; + D3D11_TEXTURE2D_DESC texture_desc; + ID3D11DeviceContext *context; + ID3D11RenderTargetView *rtv; + ID3D11Device *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, NULL)) + return; + device = test_context.device; + context = test_context.immediate_context; + + if (FAILED(hr = ID3D11Device_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) + { + ID3D11Texture2D_GetDesc(test_context.backbuffer, &texture_desc); + texture_desc.Format = tests[i].dst_format; + hr = ID3D11Device_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 = ID3D11Device_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 = D3D11_RTV_DIMENSION_TEXTURE2DMS; + hr = ID3D11Device_CreateRenderTargetView(device, (ID3D11Resource *)ms_texture, &rtv_desc, &rtv); + ok(hr == S_OK, "Failed to create render target view, hr %#x.\n", hr); + + ID3D11DeviceContext_OMSetRenderTargets(context, 1, &rtv, NULL); + ID3D11DeviceContext_ClearRenderTargetView(context, rtv, white); + draw_color_quad(&test_context, tests[i].color); + ID3D11DeviceContext_ResolveSubresource(context, (ID3D11Resource *)texture, 0, + (ID3D11Resource *)ms_texture, 0, tests[i].format); + todo_wine_if(tests[i].todo) + check_texture_color(texture, tests[i].expected_color, 2); + + ID3D11RenderTargetView_Release(rtv); + ID3D11Texture2D_Release(ms_texture); + ID3D11Texture2D_Release(texture); + } + + release_test_context(&test_context); +} + START_TEST(d3d11) { unsigned int argc, i; @@ -26244,4 +26384,5 @@ START_TEST(d3d11) test_alpha_to_coverage(); test_unbound_multisample_texture(); test_multiple_viewports(); + test_multisample_resolve(); }