Commit 3acc26dc authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

ddraw: Check surface flags when marking surface as lost.

parent e1a79d4d
......@@ -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->is_lost = ddraw_surface_can_be_lost(surface);
}
ddraw->device_state = DDRAW_DEVICE_STATE_OK;
}
......
......@@ -197,6 +197,7 @@ struct ddraw_surface
*/
unsigned int is_complex_root : 1;
unsigned int is_lost : 1;
unsigned int sysmem_fallback : 1;
/* Surface description, for GetAttachedSurface */
DDSURFACEDESC2 surface_desc;
......@@ -637,6 +638,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->sysmem_fallback;
}
/* Used for generic dumping */
struct flag_info
{
......
......@@ -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->is_lost;
return ddraw_surface_can_be_lost(surface)
&& (surface->ddraw->device_state != DDRAW_DEVICE_STATE_OK || surface->is_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,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->sysmem_fallback = sysmem_fallback;
texture->root = root;
wined3d_device_incref(texture->wined3d_device = ddraw->wined3d_device);
......@@ -6412,6 +6420,7 @@ 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);
mip->sysmem_fallback = sysmem_fallback;
mip_desc = &mip->surface_desc;
if (desc->ddsCaps.dwCaps & DDSCAPS_MIPMAP)
mip_desc->u2.dwMipMapCount = levels - j;
......@@ -6520,6 +6529,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_
}
last = wined3d_texture_get_sub_resource_parent(wined3d_texture, 0);
last->sysmem_fallback = sysmem_fallback;
wined3d_texture_decref(wined3d_texture);
texture->root = last;
wined3d_device_incref(texture->wined3d_device = ddraw->wined3d_device);
......
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