[PATCH v2 4/7] d3d10core/tests: Test drawing to a multisampled texture.
Zebediah Figura
z.figura12 at gmail.com
Fri Apr 30 11:08:29 CDT 2021
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
v2: Fix test failures.
These tests pass on radeonsi and AMD Windows 10. They currently fail on llvmpipe
due to a bug in llvmpipe, which I intend to fix as soon as possible.
dlls/d3d10core/tests/d3d10core.c | 175 +++++++++++++++++++++++++++++++
1 file changed, 175 insertions(+)
diff --git a/dlls/d3d10core/tests/d3d10core.c b/dlls/d3d10core/tests/d3d10core.c
index ccddb401aed..6c0a1c04120 100644
--- a/dlls/d3d10core/tests/d3d10core.c
+++ b/dlls/d3d10core/tests/d3d10core.c
@@ -18907,6 +18907,180 @@ static void test_unbound_streams(void)
release_test_context(&test_context);
}
+static void test_multisample_draw(void)
+{
+ static const D3D10_INPUT_ELEMENT_DESC layout_desc[] =
+ {
+ {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0},
+ };
+ static const DWORD vs_code[] =
+ {
+#if 0
+ float4 main(float4 position : POSITION) : SV_POSITION
+ {
+ return position;
+ }
+#endif
+ 0x43425844, 0xa7a2f22d, 0x83ff2560, 0xe61638bd, 0x87e3ce90, 0x00000001, 0x000000d8, 0x00000003,
+ 0x0000002c, 0x00000060, 0x00000094, 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, 0x52444853, 0x0000003c, 0x00010040,
+ 0x0000000f, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
+ 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e,
+ };
+ static const DWORD ps_code[] =
+ {
+#if 0
+ float4 main() : sv_target
+ {
+ return float4(1.0, 1.0, 1.0, 1.0);
+ }
+#endif
+ 0x43425844, 0x949557e7, 0x1480242b, 0x831e64fc, 0x7c0305d2, 0x00000001, 0x000000b0, 0x00000003,
+ 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
+ 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
+ 0x0000000f, 0x745f7673, 0x65677261, 0xabab0074, 0x52444853, 0x00000038, 0x00000040, 0x0000000e,
+ 0x03000065, 0x001020f2, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x3f800000,
+ 0x3f800000, 0x3f800000, 0x3f800000, 0x0100003e,
+ };
+ 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 d3d10core_test_context test_context;
+ D3D10_TEXTURE2D_DESC texture_desc;
+ D3D10_RASTERIZER_DESC rs_desc;
+ ID3D10RenderTargetView *rtv;
+ unsigned int stride, offset;
+ ID3D10RasterizerState *rs;
+ ID3D10Texture2D *texture;
+ ID3D10Device *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))
+ return;
+ device = test_context.device;
+
+ if (is_warp_device(device))
+ {
+ /* Line multisampling is broken on all versions of Windows up to at
+ * least Windows 10 2009; triangle multisampling is broken on 2008.
+ * Both cases render as if not multisampled. */
+ win_skip("Multisampling is broken on WARP.\n");
+ release_test_context(&test_context);
+ return;
+ }
+
+ hr = ID3D10Device_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;
+ }
+
+ ID3D10Texture2D_GetDesc(test_context.backbuffer, &texture_desc);
+ texture_desc.SampleDesc.Count = 4;
+ texture_desc.SampleDesc.Quality = 0;
+ hr = ID3D10Device_CreateTexture2D(device, &texture_desc, NULL, &texture);
+ ok(hr == S_OK, "Failed to create texture, hr %#x.\n", hr);
+ hr = ID3D10Device_CreateRenderTargetView(device, (ID3D10Resource *)texture, NULL, &rtv);
+ ok(hr == S_OK, "Failed to create render target view, hr %#x.\n", hr);
+ ID3D10Device_OMSetRenderTargets(device, 1, &rtv, NULL);
+
+ hr = ID3D10Device_CreateVertexShader(device, vs_code, sizeof(vs_code), &test_context.vs);
+ ok(hr == S_OK, "Failed to create vertex shader, hr %#x.\n", hr);
+ hr = ID3D10Device_CreatePixelShader(device, ps_code, sizeof(ps_code), &test_context.ps);
+ ok(hr == S_OK, "Failed to create pixel shader, hr %#x.\n", hr);
+ hr = ID3D10Device_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, D3D10_BIND_VERTEX_BUFFER, sizeof(tri), tri);
+
+ rs_desc.FillMode = D3D10_FILL_SOLID;
+ rs_desc.CullMode = D3D10_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 = ID3D10Device_CreateRasterizerState(device, &rs_desc, &rs);
+ ok(hr == S_OK, "Failed to create rasterizer state, hr %#x.\n", hr);
+
+ ID3D10Device_VSSetShader(device, test_context.vs);
+ ID3D10Device_PSSetShader(device, test_context.ps);
+ ID3D10Device_IASetInputLayout(device, test_context.input_layout);
+ stride = sizeof(*tri);
+ offset = 0;
+ ID3D10Device_IASetVertexBuffers(device, 0, 1, &test_context.vb, &stride, &offset);
+ ID3D10Device_RSSetState(device, rs);
+
+ ID3D10Device_ClearRenderTargetView(device, rtv, black);
+ ID3D10Device_IASetPrimitiveTopology(device, D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
+ ID3D10Device_Draw(device, 4, 0);
+ ID3D10Device_ResolveSubresource(device, (ID3D10Resource *)test_context.backbuffer, 0,
+ (ID3D10Resource *)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);
+ }
+
+ ID3D10Device_ClearRenderTargetView(device, rtv, black);
+ ID3D10Device_IASetPrimitiveTopology(device, D3D10_PRIMITIVE_TOPOLOGY_LINELIST);
+ ID3D10Device_Draw(device, 4, 0);
+ ID3D10Device_ResolveSubresource(device, (ID3D10Resource *)test_context.backbuffer, 0,
+ (ID3D10Resource *)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);
+ }
+
+ ID3D10RasterizerState_Release(rs);
+ ID3D10RenderTargetView_Release(rtv);
+ ID3D10Texture2D_Release(texture);
+ release_test_context(&test_context);
+}
+
START_TEST(d3d10core)
{
unsigned int argc, i;
@@ -19032,6 +19206,7 @@ START_TEST(d3d10core)
queue_test(test_independent_blend);
queue_test(test_dual_source_blend);
queue_test(test_unbound_streams);
+ queue_test(test_multisample_draw);
run_queued_tests();
--
2.30.2
More information about the wine-devel
mailing list