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

Alexandre Julliard julliard at winehq.org
Mon Mar 7 12:22:45 CST 2011


Module: wine
Branch: master
Commit: 60a710455ef8dd4ac38901a8741189defa427e1f
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=60a710455ef8dd4ac38901a8741189defa427e1f

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Mon Mar  7 01:30:34 2011 +0100

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.

---

 dlls/wined3d/surface.c |   31 ++++++++++++++++++++++---------
 1 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 03d597c..2c9aa48 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -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)))
     {




More information about the wine-cvs mailing list