Commit 60a71045 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Try to evict the surface's sysmem copy in surface_load_location().

The memory may not be freed until surface destruction otherwise. The PBO creation code in surface_prepare_system_memory() also depends on the SYSMEM location being recreated regularly, although arguably that's just a symptom of the resource location management being somewhat broken.
parent b1e03b32
......@@ -1275,6 +1275,17 @@ static BOOL surface_convert_color_to_float(IWineD3DSurfaceImpl *surface, DWORD c
return TRUE;
}
static void surface_evict_sysmem(IWineD3DSurfaceImpl *surface)
{
if (surface->flags & SFLAG_DONOTFREE)
return;
HeapFree(GetProcessHeap(), 0, surface->resource.heapMemory);
surface->resource.allocatedMemory = NULL;
surface->resource.heapMemory = NULL;
surface_modify_location(surface, SFLAG_INSYSMEM, FALSE);
}
HRESULT surface_load(IWineD3DSurfaceImpl *surface, BOOL srgb)
{
DWORD flag = srgb ? SFLAG_INSRGBTEX : SFLAG_INTEXTURE;
......@@ -1316,14 +1327,7 @@ HRESULT surface_load(IWineD3DSurfaceImpl *surface, BOOL srgb)
/* No partial locking for textures yet. */
surface_load_location(surface, flag, NULL);
if (!(surface->flags & SFLAG_DONOTFREE))
{
HeapFree(GetProcessHeap(), 0, surface->resource.heapMemory);
surface->resource.allocatedMemory = NULL;
surface->resource.heapMemory = NULL;
surface_modify_location(surface, SFLAG_INSYSMEM, FALSE);
}
surface_evict_sysmem(surface);
return WINED3D_OK;
}
......@@ -2071,7 +2075,10 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_Unmap(IWineD3DSurface *iface)
* merged again in the drawable. The sysmem copy is not fully up to
* date because only a subrectangle was read in Map(). */
if (!fullsurface)
{
surface_modify_location(This, SFLAG_INDRAWABLE, TRUE);
surface_evict_sysmem(This);
}
This->dirtyRect.left = This->currentDesc.Width;
This->dirtyRect.top = This->currentDesc.Height;
......@@ -4652,7 +4659,13 @@ HRESULT surface_load_location(IWineD3DSurfaceImpl *surface, DWORD flag, const RE
}
}
if (!rect) surface->flags |= flag;
if (!rect)
{
surface->flags |= flag;
if (flag != SFLAG_INSYSMEM && (surface->flags & SFLAG_INSYSMEM))
surface_evict_sysmem(surface);
}
if (in_fbo && (surface->flags & (SFLAG_INTEXTURE | SFLAG_INDRAWABLE)))
{
......
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