[PATCH 4/6] wined3d: Introduce wined3d_context_gl_destroy().

Henri Verbeet hverbeet at codeweavers.com
Fri May 3 05:56:01 CDT 2019


Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
 dlls/wined3d/context.c         | 46 +++++++++++++++++++++++++-----------------
 dlls/wined3d/wined3d_private.h |  5 +++++
 2 files changed, 33 insertions(+), 18 deletions(-)

diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 148d69f5cf1..b239813d226 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -1482,6 +1482,32 @@ static void wined3d_context_cleanup(struct wined3d_context *context)
     heap_free(context->texture_type);
 }
 
+static void wined3d_context_gl_cleanup(struct wined3d_context_gl *context_gl)
+{
+    wined3d_context_cleanup(&context_gl->c);
+}
+
+static void wined3d_context_gl_destroy(struct wined3d_context_gl *context_gl)
+{
+    if (context_gl->c.current && context_gl->c.tid != GetCurrentThreadId())
+    {
+        struct wined3d_gl_info *gl_info;
+
+        /* Make a copy of gl_info for wined3d_context_gl_cleanup() use, the
+         * one in wined3d_adapter may go away in the meantime. */
+        gl_info = heap_alloc(sizeof(*gl_info));
+        *gl_info = *context_gl->c.gl_info;
+        context_gl->c.gl_info = gl_info;
+        context_gl->c.destroyed = 1;
+
+        return;
+    }
+
+    wined3d_context_gl_cleanup(context_gl);
+    TlsSetValue(wined3d_context_tls_idx, NULL);
+    heap_free(context_gl);
+}
+
 DWORD context_get_tls_idx(void)
 {
     return wined3d_context_tls_idx;
@@ -1512,7 +1538,7 @@ BOOL context_set_current(struct wined3d_context *ctx)
         if (old->destroyed)
         {
             TRACE("Switching away from destroyed context %p.\n", old);
-            wined3d_context_cleanup(old);
+            wined3d_context_gl_cleanup(wined3d_context_gl(old));
             heap_free((void *)old->gl_info);
             heap_free(old);
         }
@@ -2325,23 +2351,7 @@ void wined3d_context_destroy(struct wined3d_context *context)
     device->adapter->fragment_pipe->free_context_data(context);
     device_context_remove(device, context);
 
-    if (context->current && context->tid != GetCurrentThreadId())
-    {
-        struct wined3d_gl_info *gl_info;
-
-        /* Make a copy of gl_info for wined3d_context_cleanup() use, the
-         * one in wined3d_adapter may go away in the meantime. */
-        gl_info = heap_alloc(sizeof(*gl_info));
-        *gl_info = *context->gl_info;
-        context->gl_info = gl_info;
-        context->destroyed = 1;
-
-        return;
-    }
-
-    wined3d_context_cleanup(context);
-    TlsSetValue(wined3d_context_tls_idx, NULL);
-    heap_free(context);
+    wined3d_context_gl_destroy(wined3d_context_gl(context));
 }
 
 const DWORD *context_get_tex_unit_mapping(const struct wined3d_context *context,
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 138cefb5ffe..e698c792813 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2034,6 +2034,11 @@ struct wined3d_context_gl
     struct wined3d_context c;
 };
 
+static inline struct wined3d_context_gl *wined3d_context_gl(struct wined3d_context *context)
+{
+    return CONTAINING_RECORD(context, struct wined3d_context_gl, c);
+}
+
 struct wined3d_fb_state
 {
     struct wined3d_rendertarget_view *render_targets[MAX_RENDER_TARGET_VIEWS];
-- 
2.11.0




More information about the wine-devel mailing list