Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/d3d11/tests/d3d11.c | 173 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 173 insertions(+)
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c index ca60170d080..b2c719b7667 100644 --- a/dlls/d3d11/tests/d3d11.c +++ b/dlls/d3d11/tests/d3d11.c @@ -32438,6 +32438,178 @@ static void test_deferred_context_rendering(void) release_test_context(&test_context); }
+static void test_multisample_draw(const D3D_FEATURE_LEVEL feature_level) +{ + static const D3D11_INPUT_ELEMENT_DESC layout_desc[] = + { + {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0}, + }; + static const DWORD vs_code[] = + { +#if 0 + float4 main(float4 position : POSITION) : SV_POSITION + { + return position; + } +#endif + 0x43425844, 0x06bbe9c8, 0x927aedde, 0xb3c454df, 0xd739785a, 0x00000001, 0x00000140, 0x00000004, + 0x00000030, 0x00000094, 0x000000d8, 0x0000010c, 0x396e6f41, 0x0000005c, 0x0000005c, 0xfffe0200, + 0x00000034, 0x00000028, 0x00240000, 0x00240000, 0x00240000, 0x00240000, 0x00240001, 0x00000000, + 0xfffe0200, 0x0200001f, 0x80000005, 0x900f0000, 0x04000004, 0xc0030000, 0x90ff0000, 0xa0e40000, + 0x90e40000, 0x02000001, 0xc00c0000, 0x90e40000, 0x0000ffff, 0x52444853, 0x0000003c, 0x00010040, + 0x0000000f, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, + 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e, 0x4e475349, 0x0000002c, + 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, + 0x49534f50, 0x4e4f4954, 0xababab00, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, + 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, + }; + static const DWORD ps_code[] = + { +#if 0 + float4 main() : sv_target + { + return float4(1.0, 1.0, 1.0, 1.0); + } +#endif + 0x43425844, 0xe8ed6039, 0xd42f2bf4, 0x38efe2fd, 0x9dc3406f, 0x00000001, 0x00000118, 0x00000004, + 0x00000030, 0x00000094, 0x000000d4, 0x000000e4, 0x396e6f41, 0x0000005c, 0x0000005c, 0xffff0200, + 0x00000038, 0x00000024, 0x00240000, 0x00240000, 0x00240000, 0x00240000, 0x00240000, 0xffff0200, + 0x05000051, 0xa00f0000, 0x3f800000, 0x00000000, 0x00000000, 0x00000000, 0x02000001, 0x800f0000, + 0xa0000000, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff, 0x52444853, 0x00000038, 0x00000040, + 0x0000000e, 0x03000065, 0x001020f2, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, + 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000, 0x0100003e, 0x4e475349, 0x00000008, 0x00000000, + 0x00000008, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, + 0x00000003, 0x00000000, 0x0000000f, 0x745f7673, 0x65677261, 0xabab0074, + }; + static const struct vec3 tri[] = + { + { 0.9f, -0.5f, 0.0f}, + {-0.8f, -0.9f, 0.0f}, + { 0.2f, 0.7f, 0.0f}, + }; + static const float black[] = {0.0f, 0.0f, 0.0f, 1.0f}; + struct d3d11_test_context test_context; + D3D11_TEXTURE2D_DESC texture_desc; + D3D11_RASTERIZER_DESC rs_desc; + ID3D11DeviceContext *context; + ID3D11RenderTargetView *rtv; + unsigned int stride, offset; + ID3D11RasterizerState *rs; + ID3D11Texture2D *texture; + ID3D11Device *device; + UINT quality_levels; + unsigned int i; + DWORD color; + HRESULT hr; + + static const struct + { + unsigned int x, y; + DWORD colour_tri, colour_line; + } + pixels[] = + { + {333, 407, 0xffffffff, 0xff000000}, + {334, 407, 0xffffffff, 0xff3f3f3f}, + {335, 407, 0xffffffff, 0xff3f3f3f}, + {336, 407, 0xffffffff, 0xffbfbfbf}, + {337, 407, 0xffbfbfbf, 0xffbfbfbf}, + {338, 407, 0xff7f7f7f, 0xffffffff}, + {339, 407, 0xff3f3f3f, 0xffbfbfbf}, + {340, 407, 0xff3f3f3f, 0xffbfbfbf}, + {341, 407, 0xff000000, 0xff7f7f7f}, + {342, 407, 0xff000000, 0xff3f3f3f}, + {343, 407, 0xff000000, 0xff3f3f3f}, + {344, 407, 0xff000000, 0xff000000}, + }; + + if (!init_test_context(&test_context, &feature_level)) + return; + device = test_context.device; + context = test_context.immediate_context; + + hr = ID3D11Device_CheckMultisampleQualityLevels(device, DXGI_FORMAT_R8G8B8A8_TYPELESS, 4, &quality_levels); + ok(hr == S_OK, "Failed to check multisample quality levels, hr %#x.\n", hr); + if (!quality_levels) + { + skip("4xMSAA not supported.\n"); + release_test_context(&test_context); + return; + } + + ID3D11Texture2D_GetDesc(test_context.backbuffer, &texture_desc); + texture_desc.SampleDesc.Count = 4; + texture_desc.SampleDesc.Quality = 0; + hr = ID3D11Device_CreateTexture2D(device, &texture_desc, NULL, &texture); + ok(hr == S_OK, "Failed to create texture, hr %#x.\n", hr); + 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); + + hr = ID3D11Device_CreateVertexShader(device, vs_code, sizeof(vs_code), NULL, &test_context.vs); + ok(hr == S_OK, "Failed to create vertex shader, hr %#x.\n", hr); + hr = ID3D11Device_CreatePixelShader(device, ps_code, sizeof(ps_code), NULL, &test_context.ps); + ok(hr == S_OK, "Failed to create pixel shader, hr %#x.\n", hr); + hr = ID3D11Device_CreateInputLayout(device, layout_desc, ARRAY_SIZE(layout_desc), + vs_code, sizeof(vs_code), &test_context.input_layout); + ok(hr == S_OK, "Failed to create input layout, hr %#x.\n", hr); + test_context.vb = create_buffer(device, D3D11_BIND_VERTEX_BUFFER, sizeof(tri), tri); + + rs_desc.FillMode = D3D11_FILL_SOLID; + rs_desc.CullMode = D3D11_CULL_BACK; + rs_desc.FrontCounterClockwise = FALSE; + rs_desc.DepthBias = 0; + rs_desc.DepthBiasClamp = 0.0f; + rs_desc.SlopeScaledDepthBias = 0.0f; + rs_desc.DepthClipEnable = TRUE; + rs_desc.ScissorEnable = FALSE; + rs_desc.MultisampleEnable = FALSE; + rs_desc.AntialiasedLineEnable = FALSE; + hr = ID3D11Device_CreateRasterizerState(device, &rs_desc, &rs); + ok(hr == S_OK, "Failed to create rasterizer state, hr %#x.\n", hr); + + ID3D11DeviceContext_VSSetShader(context, test_context.vs, NULL, 0); + ID3D11DeviceContext_PSSetShader(context, test_context.ps, NULL, 0); + ID3D11DeviceContext_IASetInputLayout(context, test_context.input_layout); + stride = sizeof(*tri); + offset = 0; + ID3D11DeviceContext_IASetVertexBuffers(context, 0, 1, &test_context.vb, &stride, &offset); + ID3D11DeviceContext_RSSetState(context, rs); + + ID3D11DeviceContext_ClearRenderTargetView(context, rtv, black); + ID3D11DeviceContext_IASetPrimitiveTopology(context, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); + ID3D11DeviceContext_Draw(context, 3, 0); + ID3D11DeviceContext_ResolveSubresource(context, (ID3D11Resource *)test_context.backbuffer, 0, + (ID3D11Resource *)texture, 0, texture_desc.Format); + + for (i = 0; i < ARRAY_SIZE(pixels); ++i) + { + color = get_texture_color(test_context.backbuffer, pixels[i].x, pixels[i].y); + todo_wine_if (pixels[i].colour_tri != 0xff000000 && pixels[i].colour_tri != 0xffffffff) + ok(compare_color(color, pixels[i].colour_tri, 1), + "Got unexpected color 0x%08x at (%u, %u).\n", color, pixels[i].x, pixels[i].y); + } + + ID3D11DeviceContext_ClearRenderTargetView(context, rtv, black); + ID3D11DeviceContext_IASetPrimitiveTopology(context, D3D11_PRIMITIVE_TOPOLOGY_LINELIST); + ID3D11DeviceContext_Draw(context, 2, 0); + ID3D11DeviceContext_ResolveSubresource(context, (ID3D11Resource *)test_context.backbuffer, 0, + (ID3D11Resource *)texture, 0, texture_desc.Format); + + for (i = 0; i < ARRAY_SIZE(pixels); ++i) + { + color = get_texture_color(test_context.backbuffer, pixels[i].x, pixels[i].y); + todo_wine_if (pixels[i].colour_line != 0xff000000 && pixels[i].colour_line != 0xffffffff) + ok(compare_color(color, pixels[i].colour_line, 1), + "Got unexpected color 0x%08x at (%u, %u).\n", color, pixels[i].x, pixels[i].y); + } + + ID3D11RasterizerState_Release(rs); + ID3D11RenderTargetView_Release(rtv); + ID3D11Texture2D_Release(texture); + release_test_context(&test_context); +} + START_TEST(d3d11) { unsigned int argc, i; @@ -32608,6 +32780,7 @@ START_TEST(d3d11) queue_test(test_deferred_context_swap_state); queue_test(test_deferred_context_rendering); queue_test(test_unbound_streams); + queue_for_each_feature_level(test_multisample_draw);
run_queued_tests(); }