From 44c8a7ae67dc5bdb9712f8c7df73e144cfcf4d40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Wed, 16 May 2018 11:55:28 +0200 Subject: [PATCH] d3d11/tests: Add test for sampleinfo with rasterizer register. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Józef Kucia Signed-off-by: Alexandre Julliard --- dlls/d3d11/tests/d3d11.c | 71 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 4 deletions(-) diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c index 5cf12a8c63e..fadcec42749 100644 --- a/dlls/d3d11/tests/d3d11.c +++ b/dlls/d3d11/tests/d3d11.c @@ -19862,9 +19862,10 @@ static void test_sm5_bufinfo_instruction(void) static void test_sampleinfo_instruction(void) { ID3D11Texture2D *float_rt_texture, *uint_rt_texture; - ID3D11RenderTargetView *float_rtv, *uint_rtv; + ID3D11RenderTargetView *float_rtv, *uint_rtv, *rtv; + ID3D11PixelShader *ps_float, *ps_uint, *ps_rt; + ID3D11Texture2D *texture, *readback_texture; struct d3d11_test_context test_context; - ID3D11PixelShader *ps_float, *ps_uint; unsigned int sample_count, quality; D3D11_TEXTURE2D_DESC texture_desc; ID3D11RenderTargetView *rtvs[2]; @@ -19872,7 +19873,6 @@ static void test_sampleinfo_instruction(void) ID3D11DeviceContext *context; struct uvec4 expected_uint; struct vec4 expected_float; - ID3D11Resource *texture; ID3D11Device *device; HRESULT hr; @@ -19915,6 +19915,21 @@ static void test_sampleinfo_instruction(void) 0x0100086a, 0x04002058, 0x00107000, 0x00000000, 0x00005555, 0x03000065, 0x001020f2, 0x00000000, 0x0500006f, 0x001020f2, 0x00000000, 0x0010700a, 0x00000000, 0x0100003e, }; + static const DWORD ps_rt_code[] = + { +#if 0 + float4 main() : SV_Target + { + return GetRenderTargetSampleCount(); + } +#endif + 0x43425844, 0x74404d37, 0xad6f88e4, 0xb006ea57, 0xf07d9e2a, 0x00000001, 0x000000a4, 0x00000003, + 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f, + 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, + 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x0000002c, 0x00000050, 0x0000000b, + 0x0100086a, 0x03000065, 0x001020f2, 0x00000000, 0x0400006f, 0x001020f2, 0x00000000, 0x0000e00a, + 0x0100003e, + }; static const D3D_FEATURE_LEVEL feature_level = D3D_FEATURE_LEVEL_11_0; if (!init_test_context(&test_context, &feature_level)) @@ -19984,16 +19999,64 @@ static void test_sampleinfo_instruction(void) expected_uint.x = expected_uint.y = expected_uint.z = expected_uint.w = sample_count; check_texture_uvec4(uint_rt_texture, &expected_uint); - ID3D11Resource_Release(texture); + ID3D11Texture2D_Release(texture); ID3D11ShaderResourceView_Release(srv); } + hr = ID3D11Device_CreatePixelShader(device, ps_rt_code, sizeof(ps_rt_code), NULL, &ps_rt); + ok(hr == S_OK, "Failed to create pixel shader, hr %#x.\n", hr); + ID3D11DeviceContext_PSSetShader(context, ps_rt, NULL, 0); + for (sample_count = 1; sample_count <= 8; sample_count *= 2) + { + texture_desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT; + texture_desc.SampleDesc.Count = sample_count; + texture_desc.BindFlags = D3D11_BIND_RENDER_TARGET; + + hr = ID3D11Device_CheckMultisampleQualityLevels(device, texture_desc.Format, sample_count, &quality); + ok(hr == S_OK, "Failed to check multisample quality levels, hr %#x.\n", hr); + if (!quality) + { + skip("Sample count %u not supported.\n", sample_count); + continue; + } + + hr = ID3D11Device_CreateTexture2D(device, &texture_desc, NULL, (ID3D11Texture2D **)&texture); + ok(hr == S_OK, "Failed to create texture, hr %#x, sample count %u.\n", hr, sample_count); + hr = ID3D11Device_CreateRenderTargetView(device, (ID3D11Resource *)texture, NULL, &rtv); + ok(hr == S_OK, "Failed to create render target view, hr %#x.\n", hr); + ID3D11DeviceContext_OMSetRenderTargets(context, 1, &rtv, NULL); + + draw_quad(&test_context); + + if (sample_count != 1) + { + texture_desc.SampleDesc.Count = 1; + hr = ID3D11Device_CreateTexture2D(device, &texture_desc, NULL, &readback_texture); + ok(hr == S_OK, "Failed to create texture, hr %#x.\n", hr); + ID3D11DeviceContext_ResolveSubresource(context, (ID3D11Resource *)readback_texture, 0, + (ID3D11Resource *)texture, 0, texture_desc.Format); + } + else + { + readback_texture = texture; + ID3D11Texture2D_AddRef(readback_texture); + } + + expected_float.x = expected_float.y = expected_float.z = expected_float.w = sample_count; + check_texture_vec4(readback_texture, &expected_float, 0); + + ID3D11Texture2D_Release(readback_texture); + ID3D11Texture2D_Release(texture); + ID3D11RenderTargetView_Release(rtv); + } + ID3D11RenderTargetView_Release(float_rtv); ID3D11RenderTargetView_Release(uint_rtv); ID3D11Texture2D_Release(float_rt_texture); ID3D11Texture2D_Release(uint_rt_texture); ID3D11PixelShader_Release(ps_float); ID3D11PixelShader_Release(ps_uint); + ID3D11PixelShader_Release(ps_rt); release_test_context(&test_context); }