Signed-off-by: Paul Gofman pgofman@codeweavers.com --- v3: - add patch.
dlls/ddraw/ddraw.c | 2 +- dlls/ddraw/ddraw_private.h | 7 +++++-- dlls/ddraw/surface.c | 34 +++++++++++++++++----------------- 3 files changed, 23 insertions(+), 20 deletions(-)
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c index 95e9fba901..0a916048bc 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c @@ -4899,7 +4899,7 @@ void ddraw_update_lost_surfaces(struct ddraw *ddraw)
LIST_FOR_EACH_ENTRY(surface, &ddraw->surface_list, struct ddraw_surface, surface_list_entry) { - surface->is_lost = TRUE; + surface->flags |= DDRAW_SURFACE_LOST; } ddraw->device_state = DDRAW_DEVICE_STATE_OK; } diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h index 83e3ee10c0..b99ad1f805 100644 --- a/dlls/ddraw/ddraw_private.h +++ b/dlls/ddraw/ddraw_private.h @@ -154,6 +154,9 @@ void DDRAW_Convert_DDSCAPS_1_To_2(const DDSCAPS *pIn, DDSCAPS2 *pOut) DECLSPEC_H void DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(const DDDEVICEIDENTIFIER2 *pIn, DDDEVICEIDENTIFIER *pOut) DECLSPEC_HIDDEN; struct wined3d_vertex_declaration *ddraw_find_decl(struct ddraw *ddraw, DWORD fvf) DECLSPEC_HIDDEN;
+#define DDRAW_SURFACE_COMPLEX_ROOT 0x00000001 +#define DDRAW_SURFACE_LOST 0x00000002 + struct ddraw_surface { /* IUnknown fields */ @@ -195,8 +198,8 @@ struct ddraw_surface /* You can't traverse the tree upwards. Only a flag for Surface::Release because it's needed there, * but no pointer to prevent temptations to traverse it in the wrong direction. */ - BOOL is_complex_root; - BOOL is_lost; + + unsigned int flags;
/* Surface description, for GetAttachedSurface */ DDSURFACEDESC2 surface_desc; diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index 20143891d3..0a681caf07 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -35,7 +35,7 @@ static inline struct ddraw_surface *impl_from_IDirectDrawGammaControl(IDirectDra
static BOOL ddraw_surface_is_lost(const struct ddraw_surface *surface) { - return surface->ddraw->device_state != DDRAW_DEVICE_STATE_OK || surface->is_lost; + return surface->ddraw->device_state != DDRAW_DEVICE_STATE_OK || surface->flags & DDRAW_SURFACE_LOST; }
/* This is slow, of course. Also, in case of locks, we can't prevent other @@ -528,7 +528,7 @@ static void ddraw_surface_cleanup(struct ddraw_surface *surface)
surf = surface->complex_array[i]; surface->complex_array[i] = NULL; - if (!surf->is_complex_root) + if (!(surf->flags & DDRAW_SURFACE_COMPLEX_ROOT)) { struct ddraw_texture *texture = wined3d_texture_get_parent(surf->wined3d_texture); struct wined3d_device *wined3d_device = texture->wined3d_device; @@ -558,33 +558,33 @@ static void ddraw_surface_cleanup(struct ddraw_surface *surface) wined3d_texture_decref(surface->wined3d_texture); }
-static ULONG ddraw_surface_release_iface(struct ddraw_surface *This) +static ULONG ddraw_surface_release_iface(struct ddraw_surface *surface) { ULONG iface_count;
/* Prevent the surface from being destroyed if it's still attached to * another surface. It will be destroyed when the root is destroyed. */ - if (This->iface_count == 1 && This->attached_iface) - IUnknown_AddRef(This->attached_iface); - iface_count = InterlockedDecrement(&This->iface_count); + if (surface->iface_count == 1 && surface->attached_iface) + IUnknown_AddRef(surface->attached_iface); + iface_count = InterlockedDecrement(&surface->iface_count);
- TRACE("%p decreasing iface count to %u.\n", This, iface_count); + TRACE("%p decreasing iface count to %u.\n", surface, iface_count);
if (iface_count == 0) { - struct ddraw_texture *texture = wined3d_texture_get_parent(This->wined3d_texture); + struct ddraw_texture *texture = wined3d_texture_get_parent(surface->wined3d_texture); struct wined3d_device *wined3d_device = texture->wined3d_device; - IUnknown *release_iface = This->ifaceToRelease; + IUnknown *release_iface = surface->ifaceToRelease;
/* Complex attached surfaces are destroyed implicitly when the root is released */ wined3d_mutex_lock(); - if(!This->is_complex_root) + if(!(surface->flags & DDRAW_SURFACE_COMPLEX_ROOT)) { - WARN("(%p) Attempt to destroy a surface that is not a complex root\n", This); + WARN("(%p) Attempt to destroy a surface that is not a complex root\n", surface); wined3d_mutex_unlock(); return iface_count; } - ddraw_surface_cleanup(This); + ddraw_surface_cleanup(surface); wined3d_mutex_unlock();
if (release_iface) @@ -2565,7 +2565,7 @@ static HRESULT WINAPI ddraw_surface7_GetPriority(IDirectDrawSurface7 *iface, DWO WARN("Called on offscreenplain surface, returning DDERR_INVALIDOBJECT.\n"); hr = DDERR_INVALIDOBJECT; } - else if (!(surface->surface_desc.ddsCaps.dwCaps2 & managed) || !surface->is_complex_root) + else if (!(surface->surface_desc.ddsCaps.dwCaps2 & managed) || !(surface->flags & DDRAW_SURFACE_COMPLEX_ROOT)) { WARN("Called on non-managed texture or non-root surface, returning DDERR_INVALIDPARAMS.\n"); hr = DDERR_INVALIDPARAMS; @@ -3780,12 +3780,12 @@ static HRESULT WINAPI ddraw_surface7_Restore(IDirectDrawSurface7 *iface) }
ddraw_update_lost_surfaces(surface->ddraw); - surface->is_lost = FALSE; + surface->flags &= ~DDRAW_SURFACE_LOST;
for(i = 0; i < MAX_COMPLEX_ATTACHED; i++) { if (surface->complex_array[i]) - surface->complex_array[i]->is_lost = FALSE; + surface->complex_array[i]->flags &= ~DDRAW_SURFACE_LOST; }
return DD_OK; @@ -4910,7 +4910,7 @@ static HRESULT ddraw_surface_set_color_key(struct ddraw_surface *surface, DWORD } }
- if (surface->is_complex_root) + if (surface->flags & DDRAW_SURFACE_COMPLEX_ROOT) hr = wined3d_texture_set_color_key(surface->wined3d_texture, flags, color_key ? (struct wined3d_color_key *)&fixed_color_key : NULL);
@@ -6388,7 +6388,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_
root = wined3d_texture_get_sub_resource_parent(wined3d_texture, 0); wined3d_texture_decref(wined3d_texture); - root->is_complex_root = TRUE; + root->flags |= DDRAW_SURFACE_COMPLEX_ROOT; texture->root = root; wined3d_device_incref(texture->wined3d_device = ddraw->wined3d_device);
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48923
Fixes a regression triggered by 530a3d94de949030f8d74bacd6c20986b32f1a31.
Signed-off-by: Paul Gofman pgofman@codeweavers.com --- v3: - move flag to ddraw_surface; - always treat primary surfaces and zbuffer as lostable.
dlls/ddraw/ddraw.c | 3 ++- dlls/ddraw/ddraw_private.h | 14 ++++++++++ dlls/ddraw/surface.c | 19 +++++++++++++- dlls/ddraw/tests/ddraw7.c | 54 +++++++++++++++++++++++++++++++++++--- 4 files changed, 84 insertions(+), 6 deletions(-)
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c index 0a916048bc..a3845d8b62 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c @@ -4899,7 +4899,8 @@ void ddraw_update_lost_surfaces(struct ddraw *ddraw)
LIST_FOR_EACH_ENTRY(surface, &ddraw->surface_list, struct ddraw_surface, surface_list_entry) { - surface->flags |= DDRAW_SURFACE_LOST; + if (ddraw_surface_can_be_lost(surface)) + surface->flags |= DDRAW_SURFACE_LOST; } ddraw->device_state = DDRAW_DEVICE_STATE_OK; } diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h index b99ad1f805..615636404a 100644 --- a/dlls/ddraw/ddraw_private.h +++ b/dlls/ddraw/ddraw_private.h @@ -156,6 +156,7 @@ struct wined3d_vertex_declaration *ddraw_find_decl(struct ddraw *ddraw, DWORD fv
#define DDRAW_SURFACE_COMPLEX_ROOT 0x00000001 #define DDRAW_SURFACE_LOST 0x00000002 +#define DDRAW_SURFACE_SYSMEM_FALLBACK 0x00000004
struct ddraw_surface { @@ -640,6 +641,19 @@ static inline BOOL format_is_paletteindexed(const DDPIXELFORMAT *fmt) return !!(fmt->dwFlags & flags); }
+static inline BOOL ddraw_surface_can_be_lost(const struct ddraw_surface *surface) +{ + DWORD caps = surface->surface_desc.ddsCaps.dwCaps; + + /* Testing with DDCREATE_EMULATIONONLY showed that primary surfaces and Z buffers can + * be lost even if created with explicit DDCAPS_SYSTEMMEMORY. Textures can or cannot be lost + * depending on whether _SYSTEMMEMORY was given explicitly by the application. */ + if (!(caps & DDSCAPS_SYSTEMMEMORY) || caps & (DDSCAPS_PRIMARYSURFACE | DDSCAPS_ZBUFFER)) + return TRUE; + + return surface->flags & DDRAW_SURFACE_SYSMEM_FALLBACK; +} + /* Used for generic dumping */ struct flag_info { diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index 0a681caf07..5fe8ae0f27 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -35,7 +35,8 @@ static inline struct ddraw_surface *impl_from_IDirectDrawGammaControl(IDirectDra
static BOOL ddraw_surface_is_lost(const struct ddraw_surface *surface) { - return surface->ddraw->device_state != DDRAW_DEVICE_STATE_OK || surface->flags & DDRAW_SURFACE_LOST; + return ddraw_surface_can_be_lost(surface) + && (surface->ddraw->device_state != DDRAW_DEVICE_STATE_OK || surface->flags & DDRAW_SURFACE_LOST); }
/* This is slow, of course. Also, in case of locks, we can't prevent other @@ -5891,6 +5892,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ struct wined3d_display_mode mode; DDSURFACEDESC2 *desc, *mip_desc; struct ddraw_texture *texture; + BOOL sysmem_fallback = FALSE; unsigned int layers = 1; unsigned int pitch = 0; BOOL reserve_memory; @@ -6213,9 +6215,14 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ if (!(ddraw->flags & DDRAW_NO3D) && SUCCEEDED(hr = wined3d_check_device_format(ddraw->wined3d, ddraw->wined3d_adapter, WINED3D_DEVICE_TYPE_HAL, mode.format_id, usage, bind_flags, WINED3D_RTYPE_TEXTURE_2D, wined3d_desc.format))) + { desc->ddsCaps.dwCaps |= DDSCAPS_VIDEOMEMORY; + } else + { desc->ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; + sysmem_fallback = TRUE; + } } else if (!(desc->ddsCaps.dwCaps & DDSCAPS_TEXTURE)) { @@ -6389,6 +6396,8 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ root = wined3d_texture_get_sub_resource_parent(wined3d_texture, 0); wined3d_texture_decref(wined3d_texture); root->flags |= DDRAW_SURFACE_COMPLEX_ROOT; + if (sysmem_fallback) + root->flags |= DDRAW_SURFACE_SYSMEM_FALLBACK; texture->root = root; wined3d_device_incref(texture->wined3d_device = ddraw->wined3d_device);
@@ -6412,6 +6421,10 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ for (j = 0; j < levels; ++j) { mip = wined3d_texture_get_sub_resource_parent(wined3d_texture, i * levels + j); + + if (sysmem_fallback) + mip->flags |= DDRAW_SURFACE_SYSMEM_FALLBACK; + mip_desc = &mip->surface_desc; if (desc->ddsCaps.dwCaps & DDSCAPS_MIPMAP) mip_desc->u2.dwMipMapCount = levels - j; @@ -6520,6 +6533,10 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ }
last = wined3d_texture_get_sub_resource_parent(wined3d_texture, 0); + + if (sysmem_fallback) + last->flags |= DDRAW_SURFACE_SYSMEM_FALLBACK; + wined3d_texture_decref(wined3d_texture); texture->root = last; wined3d_device_incref(texture->wined3d_device = ddraw->wined3d_device); diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index e44308761b..d3ea36e980 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -9269,6 +9269,7 @@ static void test_vb_writeonly(void) static void test_lost_device(void) { IDirectDrawSurface7 *surface, *back_buffer; + IDirectDrawSurface7 *sysmem_surface; DDSURFACEDESC2 surface_desc; HWND window1, window2; IDirectDraw7 *ddraw; @@ -9284,7 +9285,7 @@ static void test_lost_device(void) ddraw = create_ddraw(); ok(!!ddraw, "Failed to create a ddraw object.\n"); hr = IDirectDraw7_SetCooperativeLevel(ddraw, window1, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); - ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
memset(&surface_desc, 0, sizeof(surface_desc)); surface_desc.dwSize = sizeof(surface_desc); @@ -9292,7 +9293,16 @@ static void test_lost_device(void) surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP; U5(surface_desc).dwBackBufferCount = 1; hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL); - ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + + memset(&surface_desc, 0, sizeof(surface_desc)); + surface_desc.dwSize = sizeof(surface_desc); + surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; + surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY; + surface_desc.dwWidth = 100; + surface_desc.dwHeight = 100; + hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &sysmem_surface, NULL); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw7_TestCooperativeLevel(ddraw); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9300,6 +9310,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
ret = SetForegroundWindow(GetDesktopWindow()); ok(ret, "Failed to set foreground window.\n"); @@ -9309,6 +9321,8 @@ static void test_lost_device(void) ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
ret = SetForegroundWindow(window1); ok(ret, "Failed to set foreground window.\n"); @@ -9318,6 +9332,8 @@ static void test_lost_device(void) ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw7_RestoreAllSurfaces(ddraw); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9327,6 +9343,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9336,6 +9354,8 @@ static void test_lost_device(void) todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_Flip(surface, NULL, DDFLIP_WAIT); todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
/* Trying to restore the primary will crash, probably because flippable * surfaces can't exist in DDSCL_NORMAL. */ @@ -9345,12 +9365,16 @@ static void test_lost_device(void) surface_desc.dwFlags = DDSD_CAPS; surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL); - ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw7_TestCooperativeLevel(ddraw); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
ret = SetForegroundWindow(GetDesktopWindow()); ok(ret, "Failed to set foreground window.\n"); @@ -9358,6 +9382,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
ret = SetForegroundWindow(window1); ok(ret, "Failed to set foreground window.\n"); @@ -9365,6 +9391,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window1, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9372,6 +9400,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_IsLost(surface); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw7_RestoreAllSurfaces(ddraw); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9379,6 +9409,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
IDirectDrawSurface7_Release(surface); memset(&surface_desc, 0, sizeof(surface_desc)); @@ -9387,7 +9419,7 @@ static void test_lost_device(void) surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP; U5(surface_desc).dwBackBufferCount = 1; hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL); - ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window1, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9397,6 +9429,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9406,6 +9440,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9415,6 +9451,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9424,6 +9462,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9433,6 +9473,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window2, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9442,6 +9484,8 @@ static void test_lost_device(void) ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface7_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
memset(&caps, 0, sizeof(caps)); caps.dwCaps = DDSCAPS_FLIP; @@ -9454,8 +9498,10 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface7_IsLost(back_buffer); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + IDirectDrawSurface7_Release(back_buffer);
+ IDirectDrawSurface7_Release(sysmem_surface); IDirectDrawSurface7_Release(surface); refcount = IDirectDraw7_Release(ddraw); ok(!refcount, "Got unexpected refcount %u.\n", refcount);
From: Paul Gofman gofmanp@gmail.com
Signed-off-by: Paul Gofman pgofman@codeweavers.com --- v3: - no changes.
dlls/ddraw/tests/ddraw4.c | 51 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 4 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index 57b51eef45..c38c0b3ce5 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -9514,6 +9514,7 @@ static void test_vb_writeonly(void) static void test_lost_device(void) { IDirectDrawSurface4 *surface, *back_buffer; + IDirectDrawSurface4 *sysmem_surface; DDSURFACEDESC2 surface_desc; HWND window1, window2; IDirectDraw4 *ddraw; @@ -9529,7 +9530,7 @@ static void test_lost_device(void) ddraw = create_ddraw(); ok(!!ddraw, "Failed to create a ddraw object.\n"); hr = IDirectDraw4_SetCooperativeLevel(ddraw, window1, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); - ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
memset(&surface_desc, 0, sizeof(surface_desc)); surface_desc.dwSize = sizeof(surface_desc); @@ -9537,7 +9538,16 @@ static void test_lost_device(void) surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP; U5(surface_desc).dwBackBufferCount = 1; hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL); - ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + + memset(&surface_desc, 0, sizeof(surface_desc)); + surface_desc.dwSize = sizeof(surface_desc); + surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; + surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY; + surface_desc.dwWidth = 100; + surface_desc.dwHeight = 100; + hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &sysmem_surface, NULL); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw4_TestCooperativeLevel(ddraw); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9545,6 +9555,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
ret = SetForegroundWindow(GetDesktopWindow()); ok(ret, "Failed to set foreground window.\n"); @@ -9554,6 +9566,8 @@ static void test_lost_device(void) ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
ret = SetForegroundWindow(window1); ok(ret, "Failed to set foreground window.\n"); @@ -9563,6 +9577,8 @@ static void test_lost_device(void) ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw4_RestoreAllSurfaces(ddraw); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9572,6 +9588,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9581,6 +9599,8 @@ static void test_lost_device(void) todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT); todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
/* Trying to restore the primary will crash, probably because flippable * surfaces can't exist in DDSCL_NORMAL. */ @@ -9590,12 +9610,14 @@ static void test_lost_device(void) surface_desc.dwFlags = DDSD_CAPS; surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL); - ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw4_TestCooperativeLevel(ddraw); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
ret = SetForegroundWindow(GetDesktopWindow()); ok(ret, "Failed to set foreground window.\n"); @@ -9603,6 +9625,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
ret = SetForegroundWindow(window1); ok(ret, "Failed to set foreground window.\n"); @@ -9610,6 +9634,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window1, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9617,6 +9643,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(surface); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw4_RestoreAllSurfaces(ddraw); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9624,6 +9652,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
IDirectDrawSurface4_Release(surface); memset(&surface_desc, 0, sizeof(surface_desc)); @@ -9632,7 +9662,7 @@ static void test_lost_device(void) surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP; U5(surface_desc).dwBackBufferCount = 1; hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL); - ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window1, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9642,6 +9672,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9651,6 +9683,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9660,6 +9694,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9669,6 +9705,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9678,6 +9716,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window2, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -9685,6 +9725,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface4_IsLost(surface); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface4_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); @@ -9702,6 +9744,7 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); IDirectDrawSurface4_Release(back_buffer);
+ IDirectDrawSurface4_Release(sysmem_surface); IDirectDrawSurface4_Release(surface); refcount = IDirectDraw4_Release(ddraw); ok(!refcount, "Got unexpected refcount %u.\n", refcount);
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Paul Gofman gofmanp@gmail.com
Signed-off-by: Paul Gofman pgofman@codeweavers.com --- v3: - no changes.
dlls/ddraw/tests/ddraw2.c | 49 +++++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 4 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c index efa9195c09..7c25b2be55 100644 --- a/dlls/ddraw/tests/ddraw2.c +++ b/dlls/ddraw/tests/ddraw2.c @@ -8150,6 +8150,7 @@ static void test_palette_alpha(void) static void test_lost_device(void) { IDirectDrawSurface *surface, *back_buffer; + IDirectDrawSurface *sysmem_surface; DDSURFACEDESC surface_desc; HWND window1, window2; IDirectDraw2 *ddraw; @@ -8165,7 +8166,7 @@ static void test_lost_device(void) ddraw = create_ddraw(); ok(!!ddraw, "Failed to create a ddraw object.\n"); hr = IDirectDraw2_SetCooperativeLevel(ddraw, window1, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); - ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
memset(&surface_desc, 0, sizeof(surface_desc)); surface_desc.dwSize = sizeof(surface_desc); @@ -8173,12 +8174,23 @@ static void test_lost_device(void) surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP; surface_desc.dwBackBufferCount = 1; hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL); - ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + + memset(&surface_desc, 0, sizeof(surface_desc)); + surface_desc.dwSize = sizeof(surface_desc); + surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; + surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY; + surface_desc.dwWidth = 100; + surface_desc.dwHeight = 100; + hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &sysmem_surface, NULL); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
ret = SetForegroundWindow(GetDesktopWindow()); ok(ret, "Failed to set foreground window.\n"); @@ -8186,6 +8198,8 @@ static void test_lost_device(void) ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
ret = SetForegroundWindow(window1); ok(ret, "Failed to set foreground window.\n"); @@ -8193,6 +8207,8 @@ static void test_lost_device(void) ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = restore_surfaces(ddraw); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -8200,6 +8216,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -8207,6 +8225,8 @@ static void test_lost_device(void) todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT); todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
/* Trying to restore the primary will crash, probably because flippable * surfaces can't exist in DDSCL_NORMAL. */ @@ -8216,7 +8236,7 @@ static void test_lost_device(void) surface_desc.dwFlags = DDSD_CAPS; surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL); - ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -8225,21 +8245,29 @@ static void test_lost_device(void) ok(ret, "Failed to set foreground window.\n"); hr = IDirectDrawSurface_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
ret = SetForegroundWindow(window1); ok(ret, "Failed to set foreground window.\n"); hr = IDirectDrawSurface_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window1, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(surface); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = restore_surfaces(ddraw); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
IDirectDrawSurface_Release(surface); memset(&surface_desc, 0, sizeof(surface_desc)); @@ -8248,7 +8276,7 @@ static void test_lost_device(void) surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP; surface_desc.dwBackBufferCount = 1; hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL); - ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window1, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -8256,6 +8284,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -8263,6 +8293,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -8270,6 +8302,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -8277,6 +8311,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -8284,6 +8320,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window2, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -8291,6 +8329,8 @@ static void test_lost_device(void) ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
memset(&caps, 0, sizeof(caps)); caps.dwCaps = DDSCAPS_FLIP; @@ -8305,6 +8345,7 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); IDirectDrawSurface_Release(back_buffer);
+ IDirectDrawSurface_Release(sysmem_surface); IDirectDrawSurface_Release(surface); refcount = IDirectDraw2_Release(ddraw); ok(!refcount, "Got unexpected refcount %u.\n", refcount);
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Paul Gofman gofmanp@gmail.com
Signed-off-by: Paul Gofman pgofman@codeweavers.com --- v3: - no changes.
dlls/ddraw/tests/ddraw1.c | 49 +++++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 4 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c index 62cc87b697..0e1f4ce85c 100644 --- a/dlls/ddraw/tests/ddraw1.c +++ b/dlls/ddraw/tests/ddraw1.c @@ -7310,6 +7310,7 @@ static void test_palette_alpha(void) static void test_lost_device(void) { IDirectDrawSurface *surface, *back_buffer; + IDirectDrawSurface *sysmem_surface; DDSURFACEDESC surface_desc; HWND window1, window2; IDirectDraw *ddraw; @@ -7325,7 +7326,7 @@ static void test_lost_device(void) ddraw = create_ddraw(); ok(!!ddraw, "Failed to create a ddraw object.\n"); hr = IDirectDraw_SetCooperativeLevel(ddraw, window1, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); - ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
memset(&surface_desc, 0, sizeof(surface_desc)); surface_desc.dwSize = sizeof(surface_desc); @@ -7333,12 +7334,23 @@ static void test_lost_device(void) surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP; surface_desc.dwBackBufferCount = 1; hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL); - ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + + memset(&surface_desc, 0, sizeof(surface_desc)); + surface_desc.dwSize = sizeof(surface_desc); + surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; + surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY; + surface_desc.dwWidth = 100; + surface_desc.dwHeight = 100; + hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &sysmem_surface, NULL); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
ret = SetForegroundWindow(GetDesktopWindow()); ok(ret, "Failed to set foreground window.\n"); @@ -7346,6 +7358,8 @@ static void test_lost_device(void) ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
ret = SetForegroundWindow(window1); ok(ret, "Failed to set foreground window.\n"); @@ -7353,6 +7367,8 @@ static void test_lost_device(void) ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = restore_surfaces(ddraw); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -7360,6 +7376,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -7368,6 +7386,8 @@ static void test_lost_device(void) hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE || broken(ddraw_is_warp(ddraw) && hr == DDERR_SURFACELOST), "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
/* Trying to restore the primary will crash, probably because flippable * surfaces can't exist in DDSCL_NORMAL. */ @@ -7377,7 +7397,7 @@ static void test_lost_device(void) surface_desc.dwFlags = DDSD_CAPS; surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL); - ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -7386,21 +7406,29 @@ static void test_lost_device(void) ok(ret, "Failed to set foreground window.\n"); hr = IDirectDrawSurface_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
ret = SetForegroundWindow(window1); ok(ret, "Failed to set foreground window.\n"); hr = IDirectDrawSurface_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw_SetCooperativeLevel(ddraw, window1, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(surface); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = restore_surfaces(ddraw); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_IsLost(surface); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
IDirectDrawSurface_Release(surface); memset(&surface_desc, 0, sizeof(surface_desc)); @@ -7409,7 +7437,7 @@ static void test_lost_device(void) surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP; surface_desc.dwBackBufferCount = 1; hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL); - ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw_SetCooperativeLevel(ddraw, window1, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -7417,6 +7445,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -7424,6 +7454,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -7431,6 +7463,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -7438,6 +7472,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -7445,6 +7481,8 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw_SetCooperativeLevel(ddraw, window2, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); @@ -7452,6 +7490,8 @@ static void test_lost_device(void) ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT); ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr); + hr = IDirectDrawSurface_IsLost(sysmem_surface); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
memset(&caps, 0, sizeof(caps)); caps.dwCaps = DDSCAPS_FLIP; @@ -7466,6 +7506,7 @@ static void test_lost_device(void) ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); IDirectDrawSurface_Release(back_buffer);
+ IDirectDrawSurface_Release(sysmem_surface); IDirectDrawSurface_Release(surface); refcount = IDirectDraw_Release(ddraw); ok(!refcount, "Got unexpected refcount %u.\n", refcount);
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com