Module: wine Branch: master Commit: be20ddc38b3f9e101460f5f8f04015b148d3e13d URL: http://source.winehq.org/git/wine.git/?a=commit;h=be20ddc38b3f9e101460f5f8f0...
Author: Józef Kucia jkucia@codeweavers.com Date: Fri May 26 10:48:03 2017 +0200
wined3d: Introduce query operation to destroy queries.
Signed-off-by: Józef Kucia jkucia@codeweavers.com Signed-off-by: Henri Verbeet hverbeet@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/wined3d/buffer.c | 12 +++--- dlls/wined3d/query.c | 92 +++++++++++++++++++++--------------------- dlls/wined3d/wined3d_private.h | 2 +- 3 files changed, 55 insertions(+), 51 deletions(-)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index ab2fea3..5740d65 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -187,7 +187,8 @@ static void buffer_destroy_buffer_object(struct wined3d_buffer *buffer, struct w
if (buffer->query) { - wined3d_event_query_destroy(buffer->query); + struct wined3d_query *query = &buffer->query->query; + query->query_ops->query_destroy(query); buffer->query = NULL; } buffer->flags &= ~WINED3D_BUFFER_APPLESYNC; @@ -827,7 +828,7 @@ static void buffer_sync_apple(struct wined3d_buffer *This, DWORD flags, const st return; }
- if(!This->query) + if (!This->query) { TRACE("Creating event query for buffer %p\n", This);
@@ -850,7 +851,7 @@ static void buffer_sync_apple(struct wined3d_buffer *This, DWORD flags, const st } TRACE("Synchronizing buffer %p\n", This); ret = wined3d_event_query_finish(This->query, This->resource.device); - switch(ret) + switch (ret) { case WINED3D_EVENT_QUERY_NOT_STARTED: case WINED3D_EVENT_QUERY_OK: @@ -867,9 +868,10 @@ static void buffer_sync_apple(struct wined3d_buffer *This, DWORD flags, const st }
drop_query: - if(This->query) + if (This->query) { - wined3d_event_query_destroy(This->query); + struct wined3d_query *query = &This->query->query; + query->query_ops->query_destroy(query); This->query = NULL; }
diff --git a/dlls/wined3d/query.c b/dlls/wined3d/query.c index 28db6be..5587113 100644 --- a/dlls/wined3d/query.c +++ b/dlls/wined3d/query.c @@ -66,12 +66,6 @@ BOOL wined3d_event_query_supported(const struct wined3d_gl_info *gl_info) return gl_info->supported[ARB_SYNC] || gl_info->supported[NV_FENCE] || gl_info->supported[APPLE_FENCE]; }
-void wined3d_event_query_destroy(struct wined3d_event_query *query) -{ - if (query->context) context_free_event_query(query); - HeapFree(GetProcessHeap(), 0, query); -} - static enum wined3d_event_query_result wined3d_event_query_test(const struct wined3d_event_query *query, const struct wined3d_device *device, DWORD flags) { @@ -274,45 +268,7 @@ static void wined3d_query_destroy_object(void *object) * 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. */ - if (query->type == WINED3D_QUERY_TYPE_EVENT) - { - wined3d_event_query_destroy(wined3d_event_query_from_query(query)); - } - else if (query->type == WINED3D_QUERY_TYPE_OCCLUSION) - { - struct wined3d_occlusion_query *oq = wined3d_occlusion_query_from_query(query); - - if (oq->context) - context_free_occlusion_query(oq); - HeapFree(GetProcessHeap(), 0, oq); - } - else if (query->type == WINED3D_QUERY_TYPE_TIMESTAMP) - { - struct wined3d_timestamp_query *tq = wined3d_timestamp_query_from_query(query); - - if (tq->context) - context_free_timestamp_query(tq); - HeapFree(GetProcessHeap(), 0, tq); - } - else if (query->type == WINED3D_QUERY_TYPE_TIMESTAMP_DISJOINT - || query->type == WINED3D_QUERY_TYPE_TIMESTAMP_FREQ) - { - HeapFree(GetProcessHeap(), 0, query); - } - else if (query->type == WINED3D_QUERY_TYPE_SO_STATISTICS_STREAM0 - || query->type == WINED3D_QUERY_TYPE_SO_STATISTICS_STREAM1 - || query->type == WINED3D_QUERY_TYPE_SO_STATISTICS_STREAM2 - || query->type == WINED3D_QUERY_TYPE_SO_STATISTICS_STREAM3) - { - struct wined3d_so_statistics_query *pq = wined3d_so_statistics_query_from_query(query); - if (pq->context) - context_free_so_statistics_query(pq); - HeapFree(GetProcessHeap(), 0, pq); - } - else - { - ERR("Query %p has invalid type %#x.\n", query, query->type); - } + query->query_ops->query_destroy(query); }
ULONG CDECL wined3d_query_decref(struct wined3d_query *query) @@ -773,10 +729,20 @@ static BOOL wined3d_so_statistics_query_ops_issue(struct wined3d_query *query, D return poll; }
+static void wined3d_event_query_ops_destroy(struct wined3d_query *query) +{ + struct wined3d_event_query *event_query = wined3d_event_query_from_query(query); + + if (event_query->context) + context_free_event_query(event_query); + HeapFree(GetProcessHeap(), 0, event_query); +} + static const struct wined3d_query_ops event_query_ops = { wined3d_event_query_ops_poll, wined3d_event_query_ops_issue, + wined3d_event_query_ops_destroy, };
static HRESULT wined3d_event_query_create(struct wined3d_device *device, @@ -807,10 +773,20 @@ static HRESULT wined3d_event_query_create(struct wined3d_device *device, return WINED3D_OK; }
+static void wined3d_occlusion_query_ops_destroy(struct wined3d_query *query) +{ + struct wined3d_occlusion_query *oq = wined3d_occlusion_query_from_query(query); + + if (oq->context) + context_free_occlusion_query(oq); + HeapFree(GetProcessHeap(), 0, oq); +} + static const struct wined3d_query_ops occlusion_query_ops = { wined3d_occlusion_query_ops_poll, wined3d_occlusion_query_ops_issue, + wined3d_occlusion_query_ops_destroy, };
static HRESULT wined3d_occlusion_query_create(struct wined3d_device *device, @@ -841,10 +817,20 @@ static HRESULT wined3d_occlusion_query_create(struct wined3d_device *device, return WINED3D_OK; }
+static void wined3d_timestamp_query_ops_destroy(struct wined3d_query *query) +{ + struct wined3d_timestamp_query *tq = wined3d_timestamp_query_from_query(query); + + if (tq->context) + context_free_timestamp_query(tq); + HeapFree(GetProcessHeap(), 0, tq); +} + static const struct wined3d_query_ops timestamp_query_ops = { wined3d_timestamp_query_ops_poll, wined3d_timestamp_query_ops_issue, + wined3d_timestamp_query_ops_destroy, };
static HRESULT wined3d_timestamp_query_create(struct wined3d_device *device, @@ -875,10 +861,16 @@ static HRESULT wined3d_timestamp_query_create(struct wined3d_device *device, return WINED3D_OK; }
+static void wined3d_timestamp_disjoint_query_ops_destroy(struct wined3d_query *query) +{ + HeapFree(GetProcessHeap(), 0, query); +} + static const struct wined3d_query_ops timestamp_disjoint_query_ops = { wined3d_timestamp_disjoint_query_ops_poll, wined3d_timestamp_disjoint_query_ops_issue, + wined3d_timestamp_disjoint_query_ops_destroy, };
static HRESULT wined3d_timestamp_disjoint_query_create(struct wined3d_device *device, @@ -921,10 +913,20 @@ static HRESULT wined3d_timestamp_disjoint_query_create(struct wined3d_device *de return WINED3D_OK; }
+static void wined3d_so_statistics_query_ops_destroy(struct wined3d_query *query) +{ + struct wined3d_so_statistics_query *pq = wined3d_so_statistics_query_from_query(query); + + if (pq->context) + context_free_so_statistics_query(pq); + HeapFree(GetProcessHeap(), 0, pq); +} + static const struct wined3d_query_ops so_statistics_query_ops = { wined3d_so_statistics_query_ops_poll, wined3d_so_statistics_query_ops_issue, + wined3d_so_statistics_query_ops_destroy, };
static HRESULT wined3d_so_statistics_query_create(struct wined3d_device *device, diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 6139c67..1810985 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1621,6 +1621,7 @@ struct wined3d_query_ops { BOOL (*query_poll)(struct wined3d_query *query, DWORD flags); BOOL (*query_issue)(struct wined3d_query *query, DWORD flags); + void (*query_destroy)(struct wined3d_query *query); };
struct wined3d_query @@ -1665,7 +1666,6 @@ enum wined3d_event_query_result WINED3D_EVENT_QUERY_ERROR };
-void wined3d_event_query_destroy(struct wined3d_event_query *query) DECLSPEC_HIDDEN; enum wined3d_event_query_result wined3d_event_query_finish(const struct wined3d_event_query *query, const struct wined3d_device *device) DECLSPEC_HIDDEN; void wined3d_event_query_issue(struct wined3d_event_query *query, const struct wined3d_device *device) DECLSPEC_HIDDEN;