Note that we use D3DLOCK_READONLY instead of D3DLOCK_DISCARD. The latter doesn't appear to be valid for d3d8 backbuffers.
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com --- dlls/d3d8/tests/device.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 90 insertions(+), 3 deletions(-)
diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c index 6313d4855fd..aec35ce22f0 100644 --- a/dlls/d3d8/tests/device.c +++ b/dlls/d3d8/tests/device.c @@ -33,9 +33,10 @@ struct vec3 float x, y, z; };
-#define CREATE_DEVICE_FULLSCREEN 0x01 -#define CREATE_DEVICE_FPU_PRESERVE 0x02 -#define CREATE_DEVICE_SWVP_ONLY 0x04 +#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();
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=43957
Your paranoid android.
=== w1064 (32 bit Windows report) ===
d3d8: device: Timeout
=== debian9 (build log) ===
X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 140 (RANDR) Minor opcode of failed request: 21 (RRSetCrtcConfig)
=== debian9 (build log) ===
X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 140 (RANDR) Minor opcode of failed request: 21 (RRSetCrtcConfig) X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 140 (RANDR) Minor opcode of failed request: 21 (RRSetCrtcConfig)