[PATCH 4/5] wined3d: Remove surface_init_sysmem.

Stefan Dösinger stefan at codeweavers.com
Sat Nov 23 17:18:59 CST 2013


---
 dlls/wined3d/surface.c | 49 +++++++++++++------------------------------------
 1 file changed, 13 insertions(+), 36 deletions(-)

diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index f6aa7ee..1be985b 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -1145,37 +1145,6 @@ HRESULT CDECL wined3d_surface_get_render_target_data(struct wined3d_surface *sur
     return wined3d_surface_blt(surface, NULL, render_target, NULL, 0, NULL, WINED3D_TEXF_POINT);
 }
 
-static BOOL surface_init_sysmem(struct wined3d_surface *surface)
-{
-    if (!surface->resource.allocatedMemory)
-    {
-        if (!surface->resource.heap_memory)
-        {
-            if (!wined3d_resource_allocate_sysmem(&surface->resource))
-            {
-                ERR("Failed to allocate system memory.\n");
-                return FALSE;
-            }
-        }
-        else if (!(surface->flags & SFLAG_CLIENT))
-        {
-            ERR("Surface %p has heap_memory %p and flags %#x.\n",
-                    surface, surface->resource.heap_memory, surface->flags);
-        }
-
-        surface->resource.allocatedMemory = surface->resource.heap_memory;
-    }
-    else
-    {
-        memset(surface->resource.allocatedMemory, 0, surface->resource.size);
-    }
-
-    surface_validate_location(surface, SFLAG_INSYSMEM);
-    surface_invalidate_location(surface, ~SFLAG_INSYSMEM);
-
-    return TRUE;
-}
-
 static void surface_unload(struct wined3d_resource *resource)
 {
     struct wined3d_surface *surface = surface_from_resource(resource);
@@ -1196,9 +1165,15 @@ static void surface_unload(struct wined3d_resource *resource)
          * Put the surfaces into sysmem, and reset the content. The D3D content is undefined,
          * but we can't set the sysmem INDRAWABLE because when we're rendering the swapchain
          * or the depth stencil into an FBO the texture or render buffer will be removed
-         * and all flags get lost
-         */
-        surface_init_sysmem(surface);
+         * and all flags get lost.
+         *
+         * TODO: Setting SFLAG_DISCARDED is be a better solution, but it only works for
+         * depth stencils so far. */
+
+        surface_prepare_system_memory(surface);
+        memset(surface->resource.allocatedMemory, 0, surface->resource.size);
+        surface_validate_location(surface, SFLAG_INSYSMEM);
+        surface_invalidate_location(surface, ~SFLAG_INSYSMEM);
 
         /* We also get here when the ddraw swapchain is destroyed, for example
          * for a mode switch. In this case this surface won't necessarily be
@@ -2703,8 +2678,10 @@ HRESULT CDECL wined3d_surface_update_desc(struct wined3d_surface *surface,
     surface->resource.multisample_quality = multisample_quality;
     surface->resource.size = resource_size;
 
-    if (!surface_init_sysmem(surface))
-        return E_OUTOFMEMORY;
+    surface_prepare_system_memory(surface);
+    memset(surface->resource.allocatedMemory, 0, surface->resource.size);
+    surface_validate_location(surface, SFLAG_INSYSMEM);
+    surface_invalidate_location(surface, ~SFLAG_INSYSMEM);
 
     return WINED3D_OK;
 }
-- 
1.8.3.2




More information about the wine-patches mailing list