Henri Verbeet : wined3d: Make the adapter responsible for query creation and destruction.

Alexandre Julliard julliard at winehq.org
Thu Aug 15 14:50:47 CDT 2019


Module: wine
Branch: master
Commit: 1174c894e884154b212e3fe25e446cfaa4615156
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=1174c894e884154b212e3fe25e446cfaa4615156

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Thu Aug 15 14:38:00 2019 +0430

wined3d: Make the adapter responsible for query creation and destruction.

Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/wined3d/adapter_gl.c      | 38 ++++++++++++++++++++++++++++++++++++++
 dlls/wined3d/adapter_vk.c      | 16 ++++++++++++++++
 dlls/wined3d/directx.c         | 16 ++++++++++++++++
 dlls/wined3d/query.c           | 35 ++++++++++++++++-------------------
 dlls/wined3d/wined3d_private.h |  8 ++++++++
 5 files changed, 94 insertions(+), 19 deletions(-)

diff --git a/dlls/wined3d/adapter_gl.c b/dlls/wined3d/adapter_gl.c
index f8030bb..6537216 100644
--- a/dlls/wined3d/adapter_gl.c
+++ b/dlls/wined3d/adapter_gl.c
@@ -5069,6 +5069,42 @@ static void adapter_gl_destroy_sampler(struct wined3d_sampler *sampler)
     wined3d_cs_destroy_object(sampler->device->cs, wined3d_sampler_gl_destroy_object, sampler_gl);
 }
 
+static HRESULT adapter_gl_create_query(struct wined3d_device *device, enum wined3d_query_type type,
+        void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query)
+{
+    TRACE("device %p, type %#x, parent %p, parent_ops %p, query %p.\n",
+            device, type, parent, parent_ops, query);
+
+    return wined3d_query_gl_create(device, type, parent, parent_ops, query);
+}
+
+static void wined3d_query_gl_destroy_object(void *object)
+{
+    struct wined3d_query *query = object;
+
+    if (query->buffer_object)
+    {
+        struct wined3d_context *context;
+
+        context = context_acquire(query->device, NULL, 0);
+        wined3d_query_gl_destroy_buffer_object(wined3d_context_gl(context), query);
+        context_release(context);
+    }
+
+    /* Queries are specific to the GL context that created them. Not
+     * deleting the query will obviously leak it, but that's still better
+     * than potentially deleting a different query with the same id in this
+     * context, and (still) leaking the actual query. */
+    query->query_ops->query_destroy(query);
+}
+
+static void adapter_gl_destroy_query(struct wined3d_query *query)
+{
+    TRACE("query %p.\n", query);
+
+    wined3d_cs_destroy_object(query->device->cs, wined3d_query_gl_destroy_object, query);
+}
+
 static const struct wined3d_adapter_ops wined3d_adapter_gl_ops =
 {
     adapter_gl_destroy,
@@ -5094,6 +5130,8 @@ static const struct wined3d_adapter_ops wined3d_adapter_gl_ops =
     adapter_gl_destroy_unordered_access_view,
     adapter_gl_create_sampler,
     adapter_gl_destroy_sampler,
+    adapter_gl_create_query,
+    adapter_gl_destroy_query,
 };
 
 static BOOL wined3d_adapter_gl_init(struct wined3d_adapter_gl *adapter_gl,
diff --git a/dlls/wined3d/adapter_vk.c b/dlls/wined3d/adapter_vk.c
index afe222a..4e79a7a 100644
--- a/dlls/wined3d/adapter_vk.c
+++ b/dlls/wined3d/adapter_vk.c
@@ -759,6 +759,20 @@ static void adapter_vk_destroy_sampler(struct wined3d_sampler *sampler)
     wined3d_cs_destroy_object(sampler->device->cs, heap_free, sampler);
 }
 
+static HRESULT adapter_vk_create_query(struct wined3d_device *device, enum wined3d_query_type type,
+        void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query)
+{
+    TRACE("device %p, type %#x, parent %p, parent_ops %p, query %p.\n",
+            device, type, parent, parent_ops, query);
+
+    return WINED3DERR_NOTAVAILABLE;
+}
+
+static void adapter_vk_destroy_query(struct wined3d_query *query)
+{
+    TRACE("query %p.\n", query);
+}
+
 static const struct wined3d_adapter_ops wined3d_adapter_vk_ops =
 {
     adapter_vk_destroy,
@@ -784,6 +798,8 @@ static const struct wined3d_adapter_ops wined3d_adapter_vk_ops =
     adapter_vk_destroy_unordered_access_view,
     adapter_vk_create_sampler,
     adapter_vk_destroy_sampler,
+    adapter_vk_create_query,
+    adapter_vk_destroy_query,
 };
 
 static unsigned int wined3d_get_wine_vk_version(void)
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index 4c9773a..17c5181 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -2568,6 +2568,20 @@ static void adapter_no3d_destroy_sampler(struct wined3d_sampler *sampler)
     TRACE("sampler %p.\n", sampler);
 }
 
+static HRESULT adapter_no3d_create_query(struct wined3d_device *device, enum wined3d_query_type type,
+        void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query)
+{
+    TRACE("device %p, type %#x, parent %p, parent_ops %p, query %p.\n",
+            device, type, parent, parent_ops, query);
+
+    return WINED3DERR_NOTAVAILABLE;
+}
+
+static void adapter_no3d_destroy_query(struct wined3d_query *query)
+{
+    TRACE("query %p.\n", query);
+}
+
 static const struct wined3d_adapter_ops wined3d_adapter_no3d_ops =
 {
     adapter_no3d_destroy,
@@ -2593,6 +2607,8 @@ static const struct wined3d_adapter_ops wined3d_adapter_no3d_ops =
     adapter_no3d_destroy_unordered_access_view,
     adapter_no3d_create_sampler,
     adapter_no3d_destroy_sampler,
+    adapter_no3d_create_query,
+    adapter_no3d_destroy_query,
 };
 
 static void wined3d_adapter_no3d_init_d3d_info(struct wined3d_adapter *adapter, unsigned int wined3d_creation_flags)
diff --git a/dlls/wined3d/query.c b/dlls/wined3d/query.c
index ec20a68..6696502 100644
--- a/dlls/wined3d/query.c
+++ b/dlls/wined3d/query.c
@@ -54,7 +54,7 @@ static void wined3d_query_create_buffer_object(struct wined3d_context_gl *contex
     query->buffer_object = buffer_object;
 }
 
-static void wined3d_query_destroy_buffer_object(struct wined3d_context_gl *context_gl, struct wined3d_query *query)
+void wined3d_query_gl_destroy_buffer_object(struct wined3d_context_gl *context_gl, struct wined3d_query *query)
 {
     const struct wined3d_gl_info *gl_info = context_gl->gl_info;
 
@@ -93,7 +93,7 @@ static BOOL wined3d_query_buffer_queue_result(struct wined3d_context_gl *context
         if (wined3d_query_buffer_is_valid(query))
             wined3d_query_buffer_invalidate(query);
         else
-            wined3d_query_destroy_buffer_object(context_gl, query);
+            wined3d_query_gl_destroy_buffer_object(context_gl, query);
     }
 
     if (!query->buffer_object)
@@ -430,21 +430,6 @@ static void wined3d_query_destroy_object(void *object)
 
     if (!list_empty(&query->poll_list_entry))
         list_remove(&query->poll_list_entry);
-
-    if (query->buffer_object)
-    {
-        struct wined3d_context *context;
-
-        context = context_acquire(query->device, NULL, 0);
-        wined3d_query_destroy_buffer_object(wined3d_context_gl(context), query);
-        context_release(context);
-    }
-
-    /* Queries are specific to the GL context that created them. Not
-     * deleting the query will obviously leak it, but that's still better
-     * than potentially deleting a different query with the same id in this
-     * context, and (still) leaking the actual query. */
-    query->query_ops->query_destroy(query);
 }
 
 ULONG CDECL wined3d_query_decref(struct wined3d_query *query)
@@ -455,8 +440,11 @@ ULONG CDECL wined3d_query_decref(struct wined3d_query *query)
 
     if (!refcount)
     {
+        struct wined3d_device *device = query->device;
+
         query->parent_ops->wined3d_object_destroyed(query->parent);
-        wined3d_cs_destroy_object(query->device->cs, wined3d_query_destroy_object, query);
+        wined3d_cs_destroy_object(device->cs, wined3d_query_destroy_object, query);
+        device->adapter->adapter_ops->adapter_destroy_query(query);
     }
 
     return refcount;
@@ -1332,7 +1320,7 @@ static HRESULT wined3d_pipeline_query_create(struct wined3d_device *device,
     return WINED3D_OK;
 }
 
-HRESULT CDECL wined3d_query_create(struct wined3d_device *device, enum wined3d_query_type type,
+HRESULT wined3d_query_gl_create(struct wined3d_device *device, enum wined3d_query_type type,
         void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query)
 {
     TRACE("device %p, type %#x, parent %p, parent_ops %p, query %p.\n",
@@ -1368,3 +1356,12 @@ HRESULT CDECL wined3d_query_create(struct wined3d_device *device, enum wined3d_q
             return WINED3DERR_NOTAVAILABLE;
     }
 }
+
+HRESULT CDECL wined3d_query_create(struct wined3d_device *device, enum wined3d_query_type type,
+        void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query)
+{
+    TRACE("device %p, type %#x, parent %p, parent_ops %p, query %p.\n",
+            device, type, parent, parent_ops, query);
+
+    return device->adapter->adapter_ops->adapter_create_query(device, type, parent, parent_ops, query);
+}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 0437924..07ac982 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1785,6 +1785,11 @@ struct wined3d_query
     UINT64 *map_ptr;
 };
 
+HRESULT wined3d_query_gl_create(struct wined3d_device *device, enum wined3d_query_type type, void *parent,
+        const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query) DECLSPEC_HIDDEN;
+void wined3d_query_gl_destroy_buffer_object(struct wined3d_context_gl *context_gl,
+        struct wined3d_query *query) DECLSPEC_HIDDEN;
+
 struct wined3d_event_query
 {
     struct wined3d_query query;
@@ -2808,6 +2813,9 @@ struct wined3d_adapter_ops
     HRESULT (*adapter_create_sampler)(struct wined3d_device *device, const struct wined3d_sampler_desc *desc,
             void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_sampler **sampler);
     void (*adapter_destroy_sampler)(struct wined3d_sampler *sampler);
+    HRESULT (*adapter_create_query)(struct wined3d_device *device, enum wined3d_query_type type,
+            void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query);
+    void (*adapter_destroy_query)(struct wined3d_query *query);
 };
 
 /* The adapter structure */




More information about the wine-cvs mailing list