[PATCH 5/5] wined3d: Send swapchain context destruction through the command stream.

Henri Verbeet hverbeet at codeweavers.com
Mon Feb 27 23:12:02 CST 2017


Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
 dlls/wined3d/swapchain.c | 23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index 3a3fc6d..1f31352 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -27,6 +27,11 @@
 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
 WINE_DECLARE_DEBUG_CHANNEL(fps);
 
+static void wined3d_swapchain_destroy_object(void *object)
+{
+    swapchain_destroy_contexts(object);
+}
+
 static void swapchain_cleanup(struct wined3d_swapchain *swapchain)
 {
     HRESULT hr;
@@ -60,11 +65,7 @@ static void swapchain_cleanup(struct wined3d_swapchain *swapchain)
         swapchain->back_buffers = NULL;
     }
 
-    for (i = 0; i < swapchain->num_contexts; ++i)
-    {
-        context_destroy(swapchain->device, swapchain->context[i]);
-    }
-    HeapFree(GetProcessHeap(), 0, swapchain->context);
+    wined3d_cs_destroy_object(swapchain->device->cs, wined3d_swapchain_destroy_object, swapchain);
 
     /* Restore the screen resolution if we rendered in fullscreen.
      * This will restore the screen resolution to what it was before creating
@@ -925,7 +926,6 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3
             hr = E_OUTOFMEMORY;
             goto err;
         }
-        swapchain->num_contexts = 1;
 
         /* In WGL both color, depth and stencil are features of a pixel format. In case of D3D they are separate.
          * You are able to add a depth + stencil surface at a later stage when you need it.
@@ -953,6 +953,7 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3
             hr = WINED3DERR_NOTAVAILABLE;
             goto err;
         }
+        swapchain->num_contexts = 1;
 
         if (wined3d_settings.offscreen_rendering_mode != ORM_FBO
                 && (!desc->enable_auto_depth_stencil
@@ -1051,15 +1052,7 @@ err:
         HeapFree(GetProcessHeap(), 0, swapchain->back_buffers);
     }
 
-    if (swapchain->context)
-    {
-        if (swapchain->context[0])
-        {
-            context_destroy(device, swapchain->context[0]);
-            swapchain->num_contexts = 0;
-        }
-        HeapFree(GetProcessHeap(), 0, swapchain->context);
-    }
+    wined3d_cs_destroy_object(swapchain->device->cs, wined3d_swapchain_destroy_object, swapchain);
 
     if (swapchain->front_buffer)
     {
-- 
2.1.4




More information about the wine-patches mailing list