d3d9/tests: Add test for readback from multisample front buffer.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2018-03-08 16:37:26 +03:30 committed by Alexandre Julliard
parent c114746f6f
commit 57c2c9136f
1 changed files with 73 additions and 0 deletions

View File

@ -16249,6 +16249,78 @@ done:
DestroyWindow(window);
}
static void test_multisample_get_front_buffer_data(void)
{
IDirect3DSwapChain9 *swapchain;
D3DPRESENT_PARAMETERS d3dpp;
IDirect3DSurface9 *readback;
IDirect3DTexture9 *texture;
IDirect3DDevice9 *device;
IDirect3D9 *d3d;
ULONG refcount;
HWND window;
DWORD color;
HRESULT hr;
window = create_window();
d3d = Direct3DCreate9(D3D_SDK_VERSION);
ok(!!d3d, "Failed to create D3D object.\n");
if (FAILED(IDirect3D9_CheckDeviceMultiSampleType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
D3DFMT_A8R8G8B8, TRUE, D3DMULTISAMPLE_2_SAMPLES, NULL)))
{
skip("Multisampling not supported for D3DFMT_A8R8G8B8.\n");
goto done;
}
if (!(device = create_device(d3d, window, window, FALSE)))
{
skip("Failed to create D3D device.\n");
goto done;
}
hr = IDirect3DDevice9_GetSwapChain(device, 0, &swapchain);
ok(hr == D3D_OK, "Failed to get the implicit swapchain, hr %#x.\n", hr);
hr = IDirect3DSwapChain9_GetPresentParameters(swapchain, &d3dpp);
ok(hr == D3D_OK, "Failed to get present parameters, hr %#x.\n", hr);
IDirect3DSwapChain9_Release(swapchain);
d3dpp.MultiSampleType = D3DMULTISAMPLE_2_SAMPLES;
d3dpp.MultiSampleQuality = 0;
hr = IDirect3DDevice9_Reset(device, &d3dpp);
ok(hr == D3D_OK, "Failed to reset device, hr %#x.\n", hr);
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00f0ff0f, 0.0, 0);
ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 640, 480, D3DFMT_A8R8G8B8,
D3DPOOL_SYSTEMMEM, &readback, NULL);
ok(SUCCEEDED(hr), "Failed to create readback surface, hr %#x.\n", hr);
hr = IDirect3DDevice9_GetFrontBufferData(device, 0, readback);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
color = getPixelColorFromSurface(readback, 320, 240);
ok(color == 0x00f0ff0f, "Got unexpected color 0x%08x.\n", color);
IDirect3DSurface9_Release(readback);
hr = IDirect3DDevice9_CreateTexture(device, 640, 480, 1,
0, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &texture, NULL);
ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
hr = IDirect3DTexture9_GetSurfaceLevel(texture, 0, &readback);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
hr = IDirect3DDevice9_GetFrontBufferData(device, 0, readback);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
color = getPixelColorFromSurface(readback, 320, 240);
ok(color == 0x00f0ff0f, "Got unexpected color 0x%08x.\n", color);
IDirect3DSurface9_Release(readback);
IDirect3DTexture9_Release(texture);
refcount = IDirect3DDevice9_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount);
done:
IDirect3D9_Release(d3d);
DestroyWindow(window);
}
static void multisampled_depth_buffer_test(void)
{
IDirect3DDevice9 *device = 0;
@ -23839,6 +23911,7 @@ START_TEST(visual)
srgbwrite_format_test();
update_surface_test();
multisample_get_rtdata_test();
test_multisample_get_front_buffer_data();
zenable_test();
fog_special_test();
volume_srgb_test();