Commit 9d956379 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d3d8/tests: Port test_lockable_backbuffer() from d3d9.

Note that we use D3DLOCK_READONLY instead of D3DLOCK_DISCARD. The latter doesn't appear to be valid for d3d8 backbuffers. Signed-off-by: 's avatarHenri Verbeet <hverbeet@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 8ab4905d
......@@ -36,6 +36,7 @@ struct vec3
#define CREATE_DEVICE_FULLSCREEN 0x01
#define CREATE_DEVICE_FPU_PRESERVE 0x02
#define CREATE_DEVICE_SWVP_ONLY 0x04
#define CREATE_DEVICE_LOCKABLE_BACKBUFFER 0x08
struct device_desc
{
......@@ -122,6 +123,8 @@ static IDirect3DDevice8 *create_device(IDirect3D8 *d3d8, HWND focus_window, cons
present_parameters.BackBufferHeight = desc->height;
present_parameters.hDeviceWindow = desc->device_window;
present_parameters.Windowed = !(desc->flags & CREATE_DEVICE_FULLSCREEN);
if (desc->flags & CREATE_DEVICE_LOCKABLE_BACKBUFFER)
present_parameters.Flags |= D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
if (desc->flags & CREATE_DEVICE_SWVP_ONLY)
behavior_flags = D3DCREATE_SOFTWARE_VERTEXPROCESSING;
if (desc->flags & CREATE_DEVICE_FPU_PRESERVE)
......@@ -8406,6 +8409,89 @@ 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;
IDirect3DSurface8 *surface;
IDirect3DDevice8 *device;
D3DLOCKED_RECT lockrect;
IDirect3D8 *d3d;
ULONG refcount;
HWND window;
HRESULT hr;
window = create_window();
d3d = Direct3DCreate8(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");
IDirect3D8_Release(d3d);
DestroyWindow(window);
return;
}
hr = IDirect3DDevice8_GetBackBuffer(device, 0, D3DBACKBUFFER_TYPE_MONO, &surface);
ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#x.\n", hr);
hr = IDirect3DSurface8_LockRect(surface, &lockrect, NULL, D3DLOCK_READONLY);
todo_wine
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
IDirect3DSurface8_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 = IDirect3DDevice8_Reset(device, &present_parameters);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
hr = IDirect3DDevice8_GetBackBuffer(device, 0, D3DBACKBUFFER_TYPE_MONO, &surface);
ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#x.\n", hr);
hr = IDirect3DSurface8_LockRect(surface, &lockrect, NULL, D3DLOCK_READONLY);
todo_wine
ok(SUCCEEDED(hr), "Failed to lock rect, hr %#x.\n", hr);
hr = IDirect3DSurface8_UnlockRect(surface);
ok(SUCCEEDED(hr), "Failed to unlock rect, hr %#x.\n", hr);
IDirect3DSurface8_Release(surface);
refcount = IDirect3DDevice8_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 = IDirect3DDevice8_GetBackBuffer(device, 0, D3DBACKBUFFER_TYPE_MONO, &surface);
ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#x.\n", hr);
hr = IDirect3DSurface8_LockRect(surface, &lockrect, NULL, D3DLOCK_READONLY);
ok(SUCCEEDED(hr), "Failed to lock rect, hr %#x.\n", hr);
hr = IDirect3DSurface8_UnlockRect(surface);
ok(SUCCEEDED(hr), "Failed to unlock rect, hr %#x.\n", hr);
IDirect3DSurface8_Release(surface);
refcount = IDirect3DDevice8_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount);
IDirect3D8_Release(d3d);
DestroyWindow(window);
}
static void test_clip_planes_limits(void)
{
static const DWORD device_flags[] = {0, CREATE_DEVICE_SWVP_ONLY};
......@@ -8805,6 +8891,7 @@ START_TEST(device)
test_render_target_device_mismatch();
test_format_unknown();
test_destroyed_window();
test_lockable_backbuffer();
test_clip_planes_limits();
test_swapchain_multisample_reset();
test_device_caps();
......
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