Commit a5328e51 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

d3d9/tests: Some tests for D3DPRESENTFLAG_LOCKABLE_BACKBUFFER mode.

parent b4940eba
......@@ -11740,6 +11740,96 @@ static void test_destroyed_window(void)
ok(!refcount, "Device has %u references left.\n", refcount);
}
static void test_lockable_backbuffer(void)
{
D3DPRESENT_PARAMETERS present_parameters = {0};
struct device_desc device_desc;
IDirect3DSurface9 *surface;
IDirect3DDevice9 *device;
D3DLOCKED_RECT lockrect;
IDirect3D9 *d3d;
ULONG refcount;
HWND window;
HRESULT hr;
HDC dc;
window = CreateWindowA("d3d9_test_wc", "d3d9_test", WS_OVERLAPPEDWINDOW,
0, 0, 640, 480, 0, 0, 0, 0);
d3d = Direct3DCreate9(D3D_SDK_VERSION);
ok(!!d3d, "Failed to create a D3D object.\n");
if (!(device = create_device(d3d, window, NULL)))
{
skip("Failed to create a D3D device, skipping tests.\n");
IDirect3D9_Release(d3d);
DestroyWindow(window);
return;
}
hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &surface);
ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#x.\n", hr);
hr = IDirect3DSurface9_LockRect(surface, &lockrect, NULL, D3DLOCK_DISCARD);
todo_wine
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
dc = (void *)0xdeadbeef;
hr = IDirect3DSurface9_GetDC(surface, &dc);
ok(dc == (void *)0xdeadbeef, "Unexpected DC returned.\n");
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
IDirect3DSurface9_Release(surface);
/* Reset with D3DPRESENTFLAG_LOCKABLE_BACKBUFFER. */
present_parameters.BackBufferWidth = 640;
present_parameters.BackBufferHeight = 480;
present_parameters.BackBufferFormat = D3DFMT_A8R8G8B8;
present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
present_parameters.hDeviceWindow = window;
present_parameters.Windowed = TRUE;
present_parameters.EnableAutoDepthStencil = TRUE;
present_parameters.AutoDepthStencilFormat = D3DFMT_D24S8;
present_parameters.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
hr = IDirect3DDevice9_Reset(device, &present_parameters);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &surface);
ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#x.\n", hr);
hr = IDirect3DSurface9_LockRect(surface, &lockrect, NULL, D3DLOCK_DISCARD);
todo_wine
ok(SUCCEEDED(hr), "Failed to lock rect, hr %#x.\n", hr);
hr = IDirect3DSurface9_UnlockRect(surface);
ok(SUCCEEDED(hr), "Failed to unlock rect, hr %#x.\n", hr);
IDirect3DSurface9_Release(surface);
refcount = IDirect3DDevice9_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount);
device_desc.width = 640;
device_desc.height = 480;
device_desc.device_window = window;
device_desc.flags = CREATE_DEVICE_LOCKABLE_BACKBUFFER;
device = create_device(d3d, window, &device_desc);
ok(!!device, "Failed to create device.\n");
hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &surface);
ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#x.\n", hr);
hr = IDirect3DSurface9_LockRect(surface, &lockrect, NULL, D3DLOCK_DISCARD);
ok(SUCCEEDED(hr), "Failed to lock rect, hr %#x.\n", hr);
hr = IDirect3DSurface9_UnlockRect(surface);
ok(SUCCEEDED(hr), "Failed to unlock rect, hr %#x.\n", hr);
IDirect3DSurface9_Release(surface);
refcount = IDirect3DDevice9_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount);
IDirect3D9_Release(d3d);
DestroyWindow(window);
}
START_TEST(device)
{
WNDCLASSA wc = {0};
......@@ -11859,6 +11949,7 @@ START_TEST(device)
test_render_target_device_mismatch();
test_format_unknown();
test_destroyed_window();
test_lockable_backbuffer();
UnregisterClassA("d3d9_test_wc", GetModuleHandleA(NULL));
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment