[PATCH 1/3] d3d10core/tests: Multisampled render targets are zeroed on creation (v3).
Stefan Dösinger
stefandoesinger at gmx.at
Sun Jan 10 05:21:30 CST 2016
Version 2: Use ResolveSubresource and check for multisample support.
Version 3: Use a swapchain for debugging, clear the destination before
the resolve call.
Signed-off-by: Stefan Dösinger <stefandoesinger at gmx.at>
---
dlls/d3d10core/tests/device.c | 87 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 87 insertions(+)
diff --git a/dlls/d3d10core/tests/device.c b/dlls/d3d10core/tests/device.c
index 0dd7707..464acd0 100644
--- a/dlls/d3d10core/tests/device.c
+++ b/dlls/d3d10core/tests/device.c
@@ -4637,6 +4637,92 @@ static void test_update_subresource(void)
DestroyWindow(window);
}
+static void test_multisample_init(void)
+{
+ D3D10_TEXTURE2D_DESC desc;
+ ID3D10Texture2D *backbuffer, *multi;
+ ID3D10Device *device;
+ ULONG refcount;
+ DWORD color;
+ HRESULT hr;
+ unsigned int x, y;
+ struct texture_readback rb;
+ BOOL all_zero = TRUE;
+ UINT count = 0;
+ HWND window;
+ IDXGISwapChain *swapchain;
+ ID3D10RenderTargetView *rtview;
+ static const float white[] = {1.0f, 1.0f, 1.0f, 1.0f};
+
+ if (!(device = create_device()))
+ {
+ skip("Failed to create device, skipping tests.\n");
+ return;
+ }
+
+ hr = ID3D10Device_CheckMultisampleQualityLevels(device, DXGI_FORMAT_R8G8B8A8_UNORM, 2, &count);
+ todo_wine ok(SUCCEEDED(hr), "Failed to get quality levels, hr %#x.\n", hr);
+ if (!count)
+ {
+ skip("Multisampling not supported for DXGI_FORMAT_R8G8B8A8_UNORM, skipping tests.\n");
+ goto done;
+ }
+
+ window = CreateWindowA("static", "d3d10core_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
+ 0, 0, 640, 480, NULL, NULL, NULL, NULL);
+ swapchain = create_swapchain(device, window, TRUE);
+ hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_ID3D10Texture2D, (void **)&backbuffer);
+ ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr);
+ hr = ID3D10Device_CreateRenderTargetView(device, (ID3D10Resource *)backbuffer, NULL, &rtview);
+ ok(SUCCEEDED(hr), "Failed to create rendertarget view, hr %#x.\n", hr);
+ ID3D10Device_ClearRenderTargetView(device, rtview, white);
+
+ desc.Width = 640;
+ desc.Height = 480;
+ desc.MipLevels = 1;
+ desc.ArraySize = 1;
+ desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
+ desc.SampleDesc.Count = 2;
+ desc.SampleDesc.Quality = 0;
+ desc.Usage = D3D10_USAGE_DEFAULT;
+ desc.BindFlags = D3D10_BIND_RENDER_TARGET;
+ desc.CPUAccessFlags = 0;
+ desc.MiscFlags = 0;
+ hr = ID3D10Device_CreateTexture2D(device, &desc, NULL, &multi);
+ ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+
+ ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+ ID3D10Device_ResolveSubresource(device, (ID3D10Resource *)backbuffer, 0,
+ (ID3D10Resource *)multi, 0, DXGI_FORMAT_R8G8B8A8_UNORM);
+
+ get_texture_readback(backbuffer, &rb);
+ for (y = 0; y < 480; ++y)
+ {
+ for (x = 0; x < 640; ++x)
+ {
+ color = get_readback_color(&rb, x, y);
+ if (!compare_color(color, 0x00000000, 0))
+ {
+ all_zero = FALSE;
+ break;
+ }
+ }
+ if (!all_zero)
+ break;
+ }
+ release_texture_readback(&rb);
+ ok(all_zero, "Got unexpected color 0x%08x, position %ux%u.\n", color, x, y);
+
+ ID3D10RenderTargetView_Release(rtview);
+ ID3D10Texture2D_Release(backbuffer);
+ IDXGISwapChain_Release(swapchain);
+ ID3D10Texture2D_Release(multi);
+ DestroyWindow(window);
+done:
+ refcount = ID3D10Device_Release(device);
+ ok(!refcount, "Device has %u references left.\n", refcount);
+}
+
START_TEST(device)
{
test_feature_level();
@@ -4664,4 +4750,5 @@ START_TEST(device)
test_il_append_aligned();
test_fragment_coords();
test_update_subresource();
+ test_multisample_init();
}
--
2.4.10
More information about the wine-patches
mailing list