From f37472ae21cc14bea97d6116faaa20387ae1d9f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20D=C3=B6singer?= Date: Sun, 10 Jan 2016 11:21:30 +0000 Subject: [PATCH] d3d10core/tests: Multisampled render targets are zeroed on creation. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stefan Dösinger Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- 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 0dd770741d3..464acd076c4 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(); }