[PATCH 3/5] wined3d: Store FLUSH flag in the query object.

Matteo Bruni mbruni at codeweavers.com
Tue Sep 5 18:39:17 CDT 2017


So it can be used in the CS thread's query polling. Passing the
appropriate flag to glClientWaitSync() is potentially lighter on
performance than a separate, explicit glFlush(). More importantly,
this avoids queueing up CS packets on each wined3d_query_get_data()
call, which has been seen in some degenerate cases to starve other
client threads that are trying to submit actual work into the
CS (sort-of a livelock).

Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
---
 dlls/wined3d/cs.c              | 2 +-
 dlls/wined3d/query.c           | 4 ++--
 dlls/wined3d/wined3d_private.h | 1 +
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index 6ea2fd27a7..7c7cc37514 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -2532,7 +2532,7 @@ static void poll_queries(struct wined3d_cs *cs)
 
     LIST_FOR_EACH_ENTRY_SAFE(query, cursor, &cs->query_poll_list, struct wined3d_query, poll_list_entry)
     {
-        if (!query->query_ops->query_poll(query, 0))
+        if (!query->query_ops->query_poll(query, query->flags))
             continue;
 
         list_remove(&query->poll_list_entry);
diff --git a/dlls/wined3d/query.c b/dlls/wined3d/query.c
index 88f64bddc2..4a5f2f1b5c 100644
--- a/dlls/wined3d/query.c
+++ b/dlls/wined3d/query.c
@@ -389,8 +389,8 @@ HRESULT CDECL wined3d_query_get_data(struct wined3d_query *query,
     }
     else if (query->counter_main != query->counter_retrieved)
     {
-        if (flags & WINED3DGETDATA_FLUSH)
-            wined3d_cs_emit_flush(query->device->cs);
+        if (flags & WINED3DGETDATA_FLUSH && !(query->flags & WINED3DGETDATA_FLUSH))
+            InterlockedExchange((LONG *)&query->flags, flags);
         return S_FALSE;
     }
 
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 28560d4693..2fb7d36d2a 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1687,6 +1687,7 @@ struct wined3d_query
     enum wined3d_query_type type;
     const void *data;
     DWORD data_size;
+    DWORD flags;
     const struct wined3d_query_ops *query_ops;
 
     LONG counter_main, counter_retrieved;
-- 
2.13.5




More information about the wine-patches mailing list