Henri Verbeet : wined3d: Pass GL_SYNC_FLUSH_COMMANDS_BIT to glClientWaitSync() if WINED3DGETDATA_FLUSH was specified.

Alexandre Julliard julliard at winehq.org
Wed Jan 4 15:15:15 CST 2017


Module: wine
Branch: master
Commit: 5d470a6e7f8847fdae939dde064566cc8a877e7b
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=5d470a6e7f8847fdae939dde064566cc8a877e7b

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Wed Jan  4 00:04:49 2017 +0100

wined3d: Pass GL_SYNC_FLUSH_COMMANDS_BIT to glClientWaitSync() if WINED3DGETDATA_FLUSH was specified.

Otherwise the application may keep spinning on wined3d_query_get_data() in
case the query wasn't submitted to the GPU yet when wined3d_query_get_data()
was called. This issue was exposed by commit
70889d68664c1211caf5a845014953dfee66c8f4. Note that this won't fix the issue
if the query was created in a different GL context.

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

---

 dlls/wined3d/query.c           | 27 ++++++++++++++-------------
 dlls/wined3d/wined3d_private.h |  2 +-
 2 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/dlls/wined3d/query.c b/dlls/wined3d/query.c
index 77dad45..9f75a49 100644
--- a/dlls/wined3d/query.c
+++ b/dlls/wined3d/query.c
@@ -66,14 +66,14 @@ void wined3d_event_query_destroy(struct wined3d_event_query *query)
 }
 
 static enum wined3d_event_query_result wined3d_event_query_test(const struct wined3d_event_query *query,
-        const struct wined3d_device *device)
+        const struct wined3d_device *device, DWORD flags)
 {
     struct wined3d_context *context;
     const struct wined3d_gl_info *gl_info;
     enum wined3d_event_query_result ret;
     BOOL fence_result;
 
-    TRACE("(%p) : device %p\n", query, device);
+    TRACE("query %p, device %p, flags %#x.\n", query, device, flags);
 
     if (!query->context)
     {
@@ -92,7 +92,8 @@ static enum wined3d_event_query_result wined3d_event_query_test(const struct win
 
     if (gl_info->supported[ARB_SYNC])
     {
-        GLenum gl_ret = GL_EXTCALL(glClientWaitSync(query->object.sync, 0, 0));
+        GLenum gl_ret = GL_EXTCALL(glClientWaitSync(query->object.sync,
+                (flags & WINED3DGETDATA_FLUSH) ? GL_SYNC_FLUSH_COMMANDS_BIT : 0, 0));
         checkGLcall("glClientWaitSync");
 
         switch (gl_ret)
@@ -330,7 +331,7 @@ HRESULT CDECL wined3d_query_get_data(struct wined3d_query *query,
 
     if (query->state == QUERY_CREATED)
         WARN("Query wasn't started yet.\n");
-    else if (!query->query_ops->query_poll(query))
+    else if (!query->query_ops->query_poll(query, flags))
         return S_FALSE;
 
     if (data)
@@ -360,7 +361,7 @@ HRESULT CDECL wined3d_query_issue(struct wined3d_query *query, DWORD flags)
     return WINED3D_OK;
 }
 
-static BOOL wined3d_occlusion_query_ops_poll(struct wined3d_query *query)
+static BOOL wined3d_occlusion_query_ops_poll(struct wined3d_query *query, DWORD flags)
 {
     struct wined3d_occlusion_query *oq = wined3d_occlusion_query_from_query(query);
     struct wined3d_device *device = query->device;
@@ -368,7 +369,7 @@ static BOOL wined3d_occlusion_query_ops_poll(struct wined3d_query *query)
     struct wined3d_context *context;
     GLuint available;
 
-    TRACE("query %p.\n", query);
+    TRACE("query %p, flags %#x.\n", query, flags);
 
     if (oq->context->tid != GetCurrentThreadId())
     {
@@ -408,14 +409,14 @@ static BOOL wined3d_occlusion_query_ops_poll(struct wined3d_query *query)
     return available;
 }
 
-static BOOL wined3d_event_query_ops_poll(struct wined3d_query *query)
+static BOOL wined3d_event_query_ops_poll(struct wined3d_query *query, DWORD flags)
 {
     struct wined3d_event_query *event_query = wined3d_event_query_from_query(query);
     enum wined3d_event_query_result ret;
 
-    TRACE("query %p.\n", query);
+    TRACE("query %p, flags %#x.\n", query, flags);
 
-    ret = wined3d_event_query_test(event_query, query->device);
+    ret = wined3d_event_query_test(event_query, query->device, flags);
     switch (ret)
     {
         case WINED3D_EVENT_QUERY_OK:
@@ -538,7 +539,7 @@ static void wined3d_occlusion_query_ops_issue(struct wined3d_query *query, DWORD
     }
 }
 
-static BOOL wined3d_timestamp_query_ops_poll(struct wined3d_query *query)
+static BOOL wined3d_timestamp_query_ops_poll(struct wined3d_query *query, DWORD flags)
 {
     struct wined3d_timestamp_query *tq = wined3d_timestamp_query_from_query(query);
     struct wined3d_device *device = query->device;
@@ -547,7 +548,7 @@ static BOOL wined3d_timestamp_query_ops_poll(struct wined3d_query *query)
     GLuint64 timestamp;
     GLuint available;
 
-    TRACE("query %p.\n", query);
+    TRACE("query %p, flags %#x.\n", query, flags);
 
     if (tq->context->tid != GetCurrentThreadId())
     {
@@ -601,9 +602,9 @@ static void wined3d_timestamp_query_ops_issue(struct wined3d_query *query, DWORD
     }
 }
 
-static BOOL wined3d_timestamp_disjoint_query_ops_poll(struct wined3d_query *query)
+static BOOL wined3d_timestamp_disjoint_query_ops_poll(struct wined3d_query *query, DWORD flags)
 {
-    TRACE("query %p.\n", query);
+    TRACE("query %p, flags %#x.\n", query, flags);
 
     return TRUE;
 }
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 35e60c6..09fbb70 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1437,7 +1437,7 @@ enum wined3d_query_state
 
 struct wined3d_query_ops
 {
-    BOOL (*query_poll)(struct wined3d_query *query);
+    BOOL (*query_poll)(struct wined3d_query *query, DWORD flags);
     void (*query_issue)(struct wined3d_query *query, DWORD flags);
 };
 




More information about the wine-cvs mailing list