[PATCH 4/5] wined3d: Send shader resource view destruction through the command stream.

Henri Verbeet hverbeet at codeweavers.com
Tue Jun 21 03:32:46 CDT 2016


Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
 dlls/wined3d/cs.c              | 28 ++++++++++++++++++++++++++++
 dlls/wined3d/view.c            | 34 ++++++++++++++++++++++------------
 dlls/wined3d/wined3d_private.h |  2 ++
 3 files changed, 52 insertions(+), 12 deletions(-)

diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index bbd5c0d..46f623a 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -52,6 +52,7 @@ enum wined3d_cs_op
     WINED3D_CS_OP_SET_COLOR_KEY,
     WINED3D_CS_OP_SET_MATERIAL,
     WINED3D_CS_OP_RESET_STATE,
+    WINED3D_CS_OP_DESTROY_OBJECT,
 };
 
 struct wined3d_cs_present
@@ -252,6 +253,13 @@ struct wined3d_cs_reset_state
     enum wined3d_cs_op opcode;
 };
 
+struct wined3d_cs_destroy_object
+{
+    enum wined3d_cs_op opcode;
+    void (*callback)(void *object);
+    void *object;
+};
+
 static void wined3d_cs_exec_present(struct wined3d_cs *cs, const void *data)
 {
     const struct wined3d_cs_present *op = data;
@@ -1029,6 +1037,25 @@ void wined3d_cs_emit_reset_state(struct wined3d_cs *cs)
     cs->ops->submit(cs);
 }
 
+static void wined3d_cs_exec_destroy_object(struct wined3d_cs *cs, const void *data)
+{
+    const struct wined3d_cs_destroy_object *op = data;
+
+    op->callback(op->object);
+}
+
+void wined3d_cs_emit_destroy_object(struct wined3d_cs *cs, void (*callback)(void *object), void *object)
+{
+    struct wined3d_cs_destroy_object *op;
+
+    op = cs->ops->require_space(cs, sizeof(*op));
+    op->opcode = WINED3D_CS_OP_DESTROY_OBJECT;
+    op->callback = callback;
+    op->object = object;
+
+    cs->ops->submit(cs);
+}
+
 static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void *data) =
 {
     /* WINED3D_CS_OP_PRESENT                    */ wined3d_cs_exec_present,
@@ -1057,6 +1084,7 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void
     /* WINED3D_CS_OP_SET_COLOR_KEY              */ wined3d_cs_exec_set_color_key,
     /* WINED3D_CS_OP_SET_MATERIAL               */ wined3d_cs_exec_set_material,
     /* WINED3D_CS_OP_RESET_STATE                */ wined3d_cs_exec_reset_state,
+    /* WINED3D_CS_OP_DESTROY_OBJECT             */ wined3d_cs_exec_destroy_object,
 };
 
 static void *wined3d_cs_st_require_space(struct wined3d_cs *cs, size_t size)
diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c
index 52e3f1e..329a0bb 100644
--- a/dlls/wined3d/view.c
+++ b/dlls/wined3d/view.c
@@ -194,6 +194,25 @@ ULONG CDECL wined3d_shader_resource_view_incref(struct wined3d_shader_resource_v
     return refcount;
 }
 
+static void wined3d_shader_resource_view_destroy_object(void *object)
+{
+    struct wined3d_shader_resource_view *view = object;
+
+    if (view->object)
+    {
+        const struct wined3d_gl_info *gl_info;
+        struct wined3d_context *context;
+
+        context = context_acquire(view->resource->device, NULL);
+        gl_info = context->gl_info;
+        gl_info->gl_ops.gl.p_glDeleteTextures(1, &view->object);
+        checkGLcall("glDeleteTextures");
+        context_release(context);
+    }
+
+    HeapFree(GetProcessHeap(), 0, view);
+}
+
 ULONG CDECL wined3d_shader_resource_view_decref(struct wined3d_shader_resource_view *view)
 {
     ULONG refcount = InterlockedDecrement(&view->refcount);
@@ -202,22 +221,13 @@ ULONG CDECL wined3d_shader_resource_view_decref(struct wined3d_shader_resource_v
 
     if (!refcount)
     {
-        if (view->object)
-        {
-            const struct wined3d_gl_info *gl_info;
-            struct wined3d_context *context;
-
-            context = context_acquire(view->resource->device, NULL);
-            gl_info = context->gl_info;
-            gl_info->gl_ops.gl.p_glDeleteTextures(1, &view->object);
-            checkGLcall("glDeleteTextures");
-            context_release(context);
-        }
+        struct wined3d_device *device = view->resource->device;
+
         /* Call wined3d_object_destroyed() before releasing the resource,
          * since releasing the resource may end up destroying the parent. */
         view->parent_ops->wined3d_object_destroyed(view->parent);
         wined3d_resource_decref(view->resource);
-        HeapFree(GetProcessHeap(), 0, view);
+        wined3d_cs_emit_destroy_object(device->cs, wined3d_shader_resource_view_destroy_object, view);
     }
 
     return refcount;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 76425e0..43714a8 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2916,6 +2916,8 @@ void wined3d_cs_destroy(struct wined3d_cs *cs) DECLSPEC_HIDDEN;
 
 void wined3d_cs_emit_clear(struct wined3d_cs *cs, DWORD rect_count, const RECT *rects,
         DWORD flags, const struct wined3d_color *color, float depth, DWORD stencil) DECLSPEC_HIDDEN;
+void wined3d_cs_emit_destroy_object(struct wined3d_cs *cs,
+        void (*callback)(void *object), void *object) DECLSPEC_HIDDEN;
 void wined3d_cs_emit_draw(struct wined3d_cs *cs, int base_vertex_idx, unsigned int start_idx, unsigned int index_count,
         unsigned int start_instance, unsigned int instance_count, BOOL indexed) DECLSPEC_HIDDEN;
 void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *swapchain,
-- 
2.1.4




More information about the wine-patches mailing list