From 3ee3d46182ba5a4f968d2bed318a80e9380b1246 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20D=C3=B6singer?= <stefan@codeweavers.com>
Date: Wed, 24 Jul 2013 17:27:35 +0200
Subject: wined3d: Don't poll queries that failed to start

---
 dlls/wined3d/cs.c              |  5 +++--
 dlls/wined3d/query.c           | 21 +++++++++++++++------
 dlls/wined3d/wined3d_private.h |  2 +-
 3 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index b2af05b..4c0695a 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -1711,10 +1711,11 @@ static UINT wined3d_cs_exec_query_issue(struct wined3d_cs *cs, const void *data)
 {
     const struct wined3d_cs_query_issue *op = data;
     struct wined3d_query *query = op->query;
+    BOOL poll;
 
-    query->query_ops->query_issue(query, op->flags);
+    poll = query->query_ops->query_issue(query, op->flags);
 
-    if (wined3d_settings.cs_multithreaded && op->flags & WINED3DISSUE_END
+    if (wined3d_settings.cs_multithreaded && poll
             && list_empty(&query->poll_list_entry))
         list_add_tail(&cs->query_poll_list, &query->poll_list_entry);
 
diff --git a/dlls/wined3d/query.c b/dlls/wined3d/query.c
index 97483a2..a42a1bd 100644
--- a/dlls/wined3d/query.c
+++ b/dlls/wined3d/query.c
@@ -480,7 +480,7 @@ enum wined3d_query_type CDECL wined3d_query_get_type(const struct wined3d_query
     return query->type;
 }
 
-static void wined3d_event_query_ops_issue(struct wined3d_query *query, DWORD flags)
+static BOOL wined3d_event_query_ops_issue(struct wined3d_query *query, DWORD flags)
 {
     TRACE("query %p, flags %#x.\n", query, flags);
 
@@ -490,21 +490,24 @@ static void wined3d_event_query_ops_issue(struct wined3d_query *query, DWORD fla
         struct wined3d_event_query *event_query = query->extendedData;
 
         /* Faked event query support */
-        if (!event_query) return;
+        if (!event_query) return FALSE;
 
         wined3d_event_query_issue(event_query, query->device);
+        return TRUE;
     }
     else if (flags & WINED3DISSUE_BEGIN)
     {
         /* Started implicitly at device creation */
         ERR("Event query issued with START flag - what to do?\n");
     }
+    return FALSE;
 }
 
-static void wined3d_occlusion_query_ops_issue(struct wined3d_query *query, DWORD flags)
+static BOOL wined3d_occlusion_query_ops_issue(struct wined3d_query *query, DWORD flags)
 {
     struct wined3d_device *device = query->device;
     const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
+    BOOL poll = FALSE;
 
     TRACE("query %p, flags %#x.\n", query, flags);
 
@@ -570,6 +573,7 @@ static void wined3d_occlusion_query_ops_issue(struct wined3d_query *query, DWORD
                 }
             }
             oq->started = FALSE;
+            poll = TRUE;
         }
     }
     else
@@ -577,7 +581,7 @@ static void wined3d_occlusion_query_ops_issue(struct wined3d_query *query, DWORD
         FIXME("%p Occlusion queries not supported.\n", query);
     }
 
-    return;
+    return poll;
 }
 
 static HRESULT wined3d_timestamp_query_ops_get_data(struct wined3d_query *query,
@@ -661,7 +665,7 @@ static BOOL wined3d_timestamp_query_ops_poll(struct wined3d_query *query)
     return ret;
 }
 
-static void wined3d_timestamp_query_ops_issue(struct wined3d_query *query, DWORD flags)
+static BOOL wined3d_timestamp_query_ops_issue(struct wined3d_query *query, DWORD flags)
 {
     struct wined3d_device *device = query->device;
     const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
@@ -692,6 +696,10 @@ static void wined3d_timestamp_query_ops_issue(struct wined3d_query *query, DWORD
     {
         ERR("Timestamp queries not supported.\n");
     }
+
+    if (flags & WINED3DISSUE_END)
+        return TRUE;
+    return FALSE;
 }
 
 static HRESULT wined3d_timestamp_disjoint_query_ops_get_data(struct wined3d_query *query,
@@ -724,9 +732,10 @@ static BOOL wined3d_timestamp_disjoint_query_ops_poll(struct wined3d_query *quer
     return TRUE;
 }
 
-static void wined3d_timestamp_disjoint_query_ops_issue(struct wined3d_query *query, DWORD flags)
+static BOOL wined3d_timestamp_disjoint_query_ops_issue(struct wined3d_query *query, DWORD flags)
 {
     TRACE("query %p, flags %#x.\n", query, flags);
+    return FALSE;
 }
 
 static const struct wined3d_query_ops event_query_ops =
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index ec474dd..8dd9786 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2666,7 +2666,7 @@ struct wined3d_query_ops
 {
     HRESULT (*query_get_data)(struct wined3d_query *query, void *data, DWORD data_size, DWORD flags);
     BOOL (*query_poll)(struct wined3d_query *query);
-    void (*query_issue)(struct wined3d_query *query, DWORD flags);
+    BOOL (*query_issue)(struct wined3d_query *query, DWORD flags);
 };
 
 struct wined3d_query
-- 
2.1.3

