Poll with callbacks from application threads instead.
Signed-off-by: Jan Sikorski <jsikorski(a)codeweavers.com>
---
dlls/wined3d/cs.c | 73 ++-------
dlls/wined3d/query.c | 284 ++++++++++++++++++++++-----------
dlls/wined3d/wined3d_private.h | 6 +-
3 files changed, 212 insertions(+), 151 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index 9bdd2c8ed98..fff79a6b021 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -2388,44 +2388,26 @@ void wined3d_cs_init_object(struct wined3d_cs *cs, void (*callback)(void *object
wined3d_cs_emit_callback(cs, callback, object);
}
-static void wined3d_cs_exec_query_issue(struct wined3d_cs *cs, const void *data)
+void wined3d_cs_run_priority_callback(struct wined3d_cs *cs, void (*callback)(void *object), void *object)
{
- const struct wined3d_cs_query_issue *op = data;
- struct wined3d_query *query = op->query;
- BOOL poll;
+ struct wined3d_cs_callback *op;
- poll = query->query_ops->query_issue(query, op->flags);
+ op = wined3d_device_context_require_space(&cs->c, sizeof(*op), WINED3D_CS_QUEUE_MAP);
+ op->opcode = WINED3D_CS_OP_CALLBACK;
+ op->callback = callback;
+ op->object = object;
- if (!cs->thread)
- return;
+ wined3d_device_context_submit(&cs->c, WINED3D_CS_QUEUE_MAP);
+ wined3d_cs_finish(cs, WINED3D_CS_QUEUE_MAP);
+}
- if (poll && list_empty(&query->poll_list_entry))
- {
- if (query->buffer_object)
- InterlockedIncrement(&query->counter_retrieved);
- else
- list_add_tail(&cs->query_poll_list, &query->poll_list_entry);
- return;
- }
+static void 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;
- /* This can happen if occlusion queries are restarted. This discards the
- * old result, since polling it could result in a GL error. */
- if ((op->flags & WINED3DISSUE_BEGIN) && !poll && !list_empty(&query->poll_list_entry))
- {
- list_remove(&query->poll_list_entry);
- list_init(&query->poll_list_entry);
- InterlockedIncrement(&query->counter_retrieved);
- return;
- }
+ query->query_ops->query_issue(query, op->flags);
- /* This can happen when an occlusion query is ended without being started,
- * in which case we don't want to poll, but still have to counter-balance
- * the increment of the main counter.
- *
- * This can also happen if an event query is re-issued before the first
- * fence was reached. In this case the query is already in the list and
- * the poll function will check the new fence. We have to counter-balance
- * the discarded increment. */
if (op->flags & WINED3DISSUE_END)
InterlockedIncrement(&query->counter_retrieved);
}
@@ -3424,21 +3406,6 @@ static const struct wined3d_device_context_ops wined3d_cs_mt_ops =
wined3d_cs_acquire_samplers,
};
-static void poll_queries(struct wined3d_cs *cs)
-{
- struct wined3d_query *query, *cursor;
-
- 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))
- continue;
-
- list_remove(&query->poll_list_entry);
- list_init(&query->poll_list_entry);
- InterlockedIncrement(&query->counter_retrieved);
- }
-}
-
static void wined3d_cs_wait_event(struct wined3d_cs *cs)
{
InterlockedExchange(&cs->waiting_for_event, TRUE);
@@ -3478,7 +3445,6 @@ static DWORD WINAPI wined3d_cs_run(void *ctx)
struct wined3d_cs *cs = ctx;
enum wined3d_cs_op opcode;
HMODULE wined3d_module;
- unsigned int poll = 0;
LONG tail;
TRACE("Started.\n");
@@ -3487,25 +3453,16 @@ static DWORD WINAPI wined3d_cs_run(void *ctx)
* thread freeing "cs" before the FreeLibraryAndExitThread() call. */
wined3d_module = cs->wined3d_module;
- list_init(&cs->query_poll_list);
cs->thread_id = GetCurrentThreadId();
for (;;)
{
- if (++poll == WINED3D_CS_QUERY_POLL_INTERVAL)
- {
- wined3d_cs_command_lock(cs);
- poll_queries(cs);
- wined3d_cs_command_unlock(cs);
- poll = 0;
- }
-
queue = &cs->queue[WINED3D_CS_QUEUE_MAP];
if (wined3d_cs_queue_is_empty(cs, queue))
{
queue = &cs->queue[WINED3D_CS_QUEUE_DEFAULT];
if (wined3d_cs_queue_is_empty(cs, queue))
{
- if (++spin_count >= WINED3D_CS_SPIN_COUNT && list_empty(&cs->query_poll_list))
+ if (++spin_count >= WINED3D_CS_SPIN_COUNT)
wined3d_cs_wait_event(cs);
continue;
}
diff --git a/dlls/wined3d/query.c b/dlls/wined3d/query.c
index 1b38eb5e311..193f62cd265 100644
--- a/dlls/wined3d/query.c
+++ b/dlls/wined3d/query.c
@@ -472,23 +472,18 @@ HRESULT CDECL wined3d_query_get_data(struct wined3d_query *query,
return WINED3DERR_INVALIDCALL;
}
- if (query->device->cs->thread)
- {
- if (query->counter_main != query->counter_retrieved
- || (query->buffer_object && !wined3d_query_buffer_is_valid(query)))
- {
- if (flags & WINED3DGETDATA_FLUSH && !query->device->cs->queries_flushed)
- query->device->cs->c.ops->flush(&query->device->cs->c);
- return S_FALSE;
- }
- if (query->buffer_object)
- query->data = query->map_ptr;
- }
- else if (!query->query_ops->query_poll(query, flags))
+ if (query->counter_main != query->counter_retrieved
+ || (query->buffer_object && !wined3d_query_buffer_is_valid(query))
+ || !query->query_ops->query_poll(query, flags))
{
+ if (flags & WINED3DGETDATA_FLUSH && !query->device->cs->queries_flushed)
+ query->device->cs->c.ops->flush(&query->device->cs->c);
return S_FALSE;
}
+ if (query->buffer_object)
+ query->data = query->map_ptr;
+
if (data)
memcpy(data, query->data, min(data_size, query->data_size));
@@ -511,20 +506,33 @@ 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, DWORD flags)
+struct wined3d_poll_callback_data
{
- struct wined3d_occlusion_query *oq = wined3d_occlusion_query_from_query(query);
+ struct wined3d_query *query;
+ DWORD flags;
+ BOOL result;
+};
+
+static void wined3d_occlusion_query_ops_poll_cs(void *object)
+{
+ struct wined3d_poll_callback_data *data = object;
+ struct wined3d_query *query = data->query;
const struct wined3d_gl_info *gl_info;
struct wined3d_context_gl *context_gl;
+ struct wined3d_occlusion_query *oq;
+ DWORD flags = data->flags;
GLuint available;
TRACE("query %p, flags %#x.\n", query, flags);
+ oq = wined3d_occlusion_query_from_query(query);
+
if (!(context_gl = wined3d_context_gl_reacquire(oq->context_gl)))
{
FIXME("%p Wrong thread, returning 1.\n", query);
oq->samples = 1;
- return TRUE;
+ data->result = TRUE;
+ return;
}
gl_info = context_gl->gl_info;
@@ -540,40 +548,76 @@ static BOOL wined3d_occlusion_query_ops_poll(struct wined3d_query *query, DWORD
checkGLcall("poll occlusion query");
context_release(&context_gl->c);
- return available;
+ data->result = available;
}
-static BOOL wined3d_event_query_ops_poll(struct wined3d_query *query, DWORD flags)
+static BOOL wined3d_occlusion_query_ops_poll(struct wined3d_query *query, DWORD flags)
{
- struct wined3d_event_query *event_query = wined3d_event_query_from_query(query);
+ struct wined3d_cs *cs = query->device->cs;
+ struct wined3d_poll_callback_data data;
+
+ data.query = query;
+ data.flags = flags;
+
+ wined3d_cs_run_priority_callback(cs, wined3d_occlusion_query_ops_poll_cs, &data);
+
+ return data.result;
+}
+
+static void wined3d_event_query_ops_poll_cs(void *object)
+{
+ struct wined3d_poll_callback_data *data = object;
+ struct wined3d_query *query = data->query;
+ struct wined3d_event_query *event_query;
enum wined3d_fence_result ret;
+ DWORD flags = data->flags;
TRACE("query %p, flags %#x.\n", query, flags);
+ event_query = wined3d_event_query_from_query(query);
+
ret = wined3d_fence_test(&event_query->fence, query->device, flags);
switch (ret)
{
case WINED3D_FENCE_OK:
case WINED3D_FENCE_NOT_STARTED:
- return event_query->signalled = TRUE;
+ data->result = event_query->signalled = TRUE;
+ break;
case WINED3D_FENCE_WAITING:
- return event_query->signalled = FALSE;
+ data->result = event_query->signalled = FALSE;
+ break;
case WINED3D_FENCE_WRONG_THREAD:
FIXME("(%p) Wrong thread, reporting GPU idle.\n", query);
- return event_query->signalled = TRUE;
+ data->result = event_query->signalled = TRUE;
+ break;
case WINED3D_FENCE_ERROR:
ERR("The GL event query failed.\n");
- return event_query->signalled = TRUE;
+ data->result = event_query->signalled = TRUE;
+ break;
default:
ERR("Unexpected wined3d_event_query_test result %#x.\n", ret);
- return event_query->signalled = TRUE;
+ data->result = event_query->signalled = TRUE;
+ break;
}
}
+static BOOL wined3d_event_query_ops_poll(struct wined3d_query *query, DWORD flags)
+{
+ struct wined3d_cs *cs = query->device->cs;
+ struct wined3d_poll_callback_data data;
+
+ data.query = query;
+ data.flags = flags;
+
+ wined3d_cs_run_priority_callback(cs, wined3d_event_query_ops_poll_cs, &data);
+
+ return data.result;
+}
+
void * CDECL wined3d_query_get_parent(const struct wined3d_query *query)
{
TRACE("query %p.\n", query);
@@ -588,7 +632,7 @@ enum wined3d_query_type CDECL wined3d_query_get_type(const struct wined3d_query
return query->type;
}
-static BOOL wined3d_event_query_ops_issue(struct wined3d_query *query, DWORD flags)
+static void wined3d_event_query_ops_issue(struct wined3d_query *query, DWORD flags)
{
TRACE("query %p, flags %#x.\n", query, flags);
@@ -597,24 +641,20 @@ static BOOL wined3d_event_query_ops_issue(struct wined3d_query *query, DWORD fla
struct wined3d_event_query *event_query = wined3d_event_query_from_query(query);
wined3d_fence_issue(&event_query->fence, query->device);
- return TRUE;
}
else if (flags & WINED3DISSUE_BEGIN)
{
/* Started implicitly at query creation. */
ERR("Event query issued with START flag - what to do?\n");
}
-
- return FALSE;
}
-static BOOL wined3d_occlusion_query_ops_issue(struct wined3d_query *query, DWORD flags)
+static void wined3d_occlusion_query_ops_issue(struct wined3d_query *query, DWORD flags)
{
struct wined3d_occlusion_query *oq = wined3d_occlusion_query_from_query(query);
struct wined3d_device *device = query->device;
const struct wined3d_gl_info *gl_info;
struct wined3d_context_gl *context_gl;
- BOOL poll = FALSE;
TRACE("query %p, flags %#x.\n", query, flags);
@@ -668,7 +708,6 @@ static BOOL wined3d_occlusion_query_ops_issue(struct wined3d_query *query, DWORD
wined3d_query_buffer_queue_result(context_gl, query, oq->id);
context_release(&context_gl->c);
- poll = TRUE;
}
else
{
@@ -677,25 +716,29 @@ static BOOL wined3d_occlusion_query_ops_issue(struct wined3d_query *query, DWORD
}
oq->started = FALSE;
}
-
- return poll;
}
-static BOOL wined3d_timestamp_query_ops_poll(struct wined3d_query *query, DWORD flags)
+static void wined3d_timestamp_query_ops_poll_cs(void *object)
{
- struct wined3d_timestamp_query *tq = wined3d_timestamp_query_from_query(query);
- const struct wined3d_gl_info *gl_info;
+ struct wined3d_poll_callback_data *data = object;
+ struct wined3d_query *query = data->query;
struct wined3d_context_gl *context_gl;
+ const struct wined3d_gl_info *gl_info;
+ struct wined3d_timestamp_query *tq;
+ DWORD flags = data->flags;
GLuint64 timestamp;
GLuint available;
TRACE("query %p, flags %#x.\n", query, flags);
+ tq = wined3d_timestamp_query_from_query(query);
+
if (!(context_gl = wined3d_context_gl_reacquire(tq->context_gl)))
{
FIXME("%p Wrong thread, returning 1.\n", query);
tq->timestamp = 1;
- return TRUE;
+ data->result = TRUE;
+ return;
}
gl_info = context_gl->gl_info;
@@ -712,11 +755,23 @@ static BOOL wined3d_timestamp_query_ops_poll(struct wined3d_query *query, DWORD
}
context_release(&context_gl->c);
+ data->result = available;
+}
+
+static BOOL wined3d_timestamp_query_ops_poll(struct wined3d_query *query, DWORD flags)
+{
+ struct wined3d_cs *cs = query->device->cs;
+ struct wined3d_poll_callback_data data;
- return available;
+ data.query = query;
+ data.flags = flags;
+
+ wined3d_cs_run_priority_callback(cs, wined3d_timestamp_query_ops_poll_cs, &data);
+
+ return data.result;
}
-static BOOL wined3d_timestamp_query_ops_issue(struct wined3d_query *query, DWORD flags)
+static void wined3d_timestamp_query_ops_issue(struct wined3d_query *query, DWORD flags)
{
struct wined3d_timestamp_query *tq = wined3d_timestamp_query_from_query(query);
const struct wined3d_gl_info *gl_info;
@@ -738,11 +793,7 @@ static BOOL wined3d_timestamp_query_ops_issue(struct wined3d_query *query, DWORD
GL_EXTCALL(glQueryCounter(tq->id, GL_TIMESTAMP));
checkGLcall("glQueryCounter()");
context_release(&context_gl->c);
-
- return TRUE;
}
-
- return FALSE;
}
static BOOL wined3d_timestamp_disjoint_query_ops_poll(struct wined3d_query *query, DWORD flags)
@@ -752,27 +803,31 @@ static BOOL wined3d_timestamp_disjoint_query_ops_poll(struct wined3d_query *quer
return TRUE;
}
-static BOOL wined3d_timestamp_disjoint_query_ops_issue(struct wined3d_query *query, DWORD flags)
+static void wined3d_timestamp_disjoint_query_ops_issue(struct wined3d_query *query, DWORD flags)
{
TRACE("query %p, flags %#x.\n", query, flags);
-
- return FALSE;
}
-static BOOL wined3d_so_statistics_query_ops_poll(struct wined3d_query *query, DWORD flags)
+static void wined3d_so_statistics_query_ops_poll_cs(void *object)
{
- struct wined3d_so_statistics_query *pq = wined3d_so_statistics_query_from_query(query);
GLuint written_available, generated_available;
- const struct wined3d_gl_info *gl_info;
+ struct wined3d_poll_callback_data *data = object;
+ struct wined3d_query *query = data->query;
+ struct wined3d_so_statistics_query *pq;
struct wined3d_context_gl *context_gl;
+ const struct wined3d_gl_info *gl_info;
+ DWORD flags = data->flags;
TRACE("query %p, flags %#x.\n", query, flags);
+ pq = wined3d_so_statistics_query_from_query(query);
+
if (!(context_gl = wined3d_context_gl_reacquire(pq->context_gl)))
{
FIXME("%p Wrong thread, returning 0 primitives.\n", query);
memset(&pq->statistics, 0, sizeof(pq->statistics));
- return TRUE;
+ data->result = TRUE;
+ return;
}
gl_info = context_gl->gl_info;
@@ -794,7 +849,20 @@ static BOOL wined3d_so_statistics_query_ops_poll(struct wined3d_query *query, DW
checkGLcall("poll SO statistics query");
context_release(&context_gl->c);
- return written_available && generated_available;
+ data->result = written_available && generated_available;
+}
+
+static BOOL wined3d_so_statistics_query_ops_poll(struct wined3d_query *query, DWORD flags)
+{
+ struct wined3d_cs *cs = query->device->cs;
+ struct wined3d_poll_callback_data data;
+
+ data.query = query;
+ data.flags = flags;
+
+ wined3d_cs_run_priority_callback(cs, wined3d_so_statistics_query_ops_poll_cs, &data);
+
+ return data.result;
}
static void wined3d_so_statistics_query_end(struct wined3d_so_statistics_query *query,
@@ -815,13 +883,12 @@ static void wined3d_so_statistics_query_end(struct wined3d_so_statistics_query *
checkGLcall("end query");
}
-static BOOL wined3d_so_statistics_query_ops_issue(struct wined3d_query *query, DWORD flags)
+static void wined3d_so_statistics_query_ops_issue(struct wined3d_query *query, DWORD flags)
{
struct wined3d_so_statistics_query *pq = wined3d_so_statistics_query_from_query(query);
struct wined3d_device *device = query->device;
const struct wined3d_gl_info *gl_info;
struct wined3d_context_gl *context_gl;
- BOOL poll = FALSE;
TRACE("query %p, flags %#x.\n", query, flags);
@@ -878,7 +945,6 @@ static BOOL wined3d_so_statistics_query_ops_issue(struct wined3d_query *query, D
wined3d_so_statistics_query_end(pq, context_gl);
context_release(&context_gl->c);
- poll = TRUE;
}
else
{
@@ -887,25 +953,29 @@ static BOOL wined3d_so_statistics_query_ops_issue(struct wined3d_query *query, D
}
pq->started = FALSE;
}
-
- return poll;
}
-static BOOL wined3d_pipeline_query_ops_poll(struct wined3d_query *query, DWORD flags)
+static void wined3d_pipeline_query_ops_poll_cs(void *object)
{
- struct wined3d_pipeline_statistics_query *pq = wined3d_pipeline_statistics_query_from_query(query);
+ struct wined3d_pipeline_statistics_query *pq;
+ struct wined3d_poll_callback_data *data = object;
+ struct wined3d_query *query = data->query;
const struct wined3d_gl_info *gl_info;
struct wined3d_context_gl *context_gl;
+ DWORD flags = data->flags;
GLuint available;
int i;
TRACE("query %p, flags %#x.\n", query, flags);
+ pq = wined3d_pipeline_statistics_query_from_query(query);
+
if (!(context_gl = wined3d_context_gl_reacquire(pq->context_gl)))
{
FIXME("%p Wrong thread.\n", query);
memset(&pq->statistics, 0, sizeof(pq->statistics));
- return TRUE;
+ data->result = TRUE;
+ return;
}
gl_info = context_gl->gl_info;
@@ -933,7 +1003,20 @@ static BOOL wined3d_pipeline_query_ops_poll(struct wined3d_query *query, DWORD f
checkGLcall("poll pipeline statistics query");
context_release(&context_gl->c);
- return available;
+ data->result = available;
+}
+
+static BOOL wined3d_pipeline_query_ops_poll(struct wined3d_query *query, DWORD flags)
+{
+ struct wined3d_cs *cs = query->device->cs;
+ struct wined3d_poll_callback_data data;
+
+ data.query = query;
+ data.flags = flags;
+
+ wined3d_cs_run_priority_callback(cs, wined3d_pipeline_query_ops_poll_cs, &data);
+
+ return data.result;
}
static void wined3d_pipeline_statistics_query_end(struct wined3d_pipeline_statistics_query *query,
@@ -955,13 +1038,12 @@ static void wined3d_pipeline_statistics_query_end(struct wined3d_pipeline_statis
checkGLcall("end query");
}
-static BOOL wined3d_pipeline_query_ops_issue(struct wined3d_query *query, DWORD flags)
+static void wined3d_pipeline_query_ops_issue(struct wined3d_query *query, DWORD flags)
{
struct wined3d_pipeline_statistics_query *pq = wined3d_pipeline_statistics_query_from_query(query);
struct wined3d_device *device = query->device;
const struct wined3d_gl_info *gl_info;
struct wined3d_context_gl *context_gl;
- BOOL poll = FALSE;
TRACE("query %p, flags %#x.\n", query, flags);
@@ -1014,7 +1096,6 @@ static BOOL wined3d_pipeline_query_ops_issue(struct wined3d_query *query, DWORD
{
wined3d_pipeline_statistics_query_end(pq, context_gl);
context_release(&context_gl->c);
- poll = TRUE;
}
else
{
@@ -1023,8 +1104,6 @@ static BOOL wined3d_pipeline_query_ops_issue(struct wined3d_query *query, DWORD
}
pq->started = FALSE;
}
-
- return poll;
}
static void wined3d_event_query_ops_destroy(struct wined3d_query *query)
@@ -1612,10 +1691,15 @@ void wined3d_query_vk_suspend(struct wined3d_query_vk *query_vk, struct wined3d_
query_vk->flags &= ~WINED3D_QUERY_VK_FLAG_ACTIVE;
}
-static BOOL wined3d_query_vk_poll(struct wined3d_query *query, uint32_t flags)
+static void wined3d_query_vk_poll_cs(void *object)
{
- struct wined3d_query_vk *query_vk = wined3d_query_vk(query);
+ struct wined3d_poll_callback_data *data = object;
+ struct wined3d_query *query = data->query;
struct wined3d_context_vk *context_vk;
+ struct wined3d_query_vk *query_vk;
+ uint32_t flags = data->flags;
+
+ query_vk = wined3d_query_vk(query);
context_vk = wined3d_context_vk(context_acquire(query->device, NULL, 0));
@@ -1642,20 +1726,33 @@ static BOOL wined3d_query_vk_poll(struct wined3d_query *query, uint32_t flags)
query_vk->pool_idx.pool_vk = NULL;
context_release(&context_vk->c);
- return TRUE;
+ data->result = TRUE;
+ return;
unavailable:
context_release(&context_vk->c);
- return FALSE;
+ data->result = FALSE;
}
-static BOOL wined3d_query_vk_issue(struct wined3d_query *query, uint32_t flags)
+static BOOL wined3d_query_vk_poll(struct wined3d_query *query, uint32_t flags)
+{
+ struct wined3d_cs *cs = query->device->cs;
+ struct wined3d_poll_callback_data data;
+
+ data.query = query;
+ data.flags = flags;
+
+ wined3d_cs_run_priority_callback(cs, wined3d_query_vk_poll_cs, &data);
+
+ return data.result;
+}
+
+static void wined3d_query_vk_issue(struct wined3d_query *query, uint32_t flags)
{
struct wined3d_device_vk *device_vk = wined3d_device_vk(query->device);
struct wined3d_query_vk *query_vk = wined3d_query_vk(query);
struct wined3d_context_vk *context_vk;
VkCommandBuffer vk_command_buffer;
- bool poll = false;
TRACE("query %p, flags %#x.\n", query, flags);
@@ -1680,7 +1777,7 @@ static BOOL wined3d_query_vk_issue(struct wined3d_query *query, uint32_t flags)
if (!wined3d_context_vk_allocate_query(context_vk, query_vk->q.type, &query_vk->pool_idx))
{
ERR("Failed to allocate new query.\n");
- return false;
+ return;
}
/* A query needs to either begin and end inside a single render pass,
@@ -1730,12 +1827,9 @@ static BOOL wined3d_query_vk_issue(struct wined3d_query *query, uint32_t flags)
}
list_remove(&query_vk->entry);
query_vk->flags = 0;
- poll = true;
context_release(&context_vk->c);
}
-
- return poll;
}
static void wined3d_query_vk_destroy(struct wined3d_query *query)
@@ -1761,12 +1855,16 @@ static const struct wined3d_query_ops wined3d_query_vk_ops =
.query_destroy = wined3d_query_vk_destroy,
};
-static BOOL wined3d_query_event_vk_poll(struct wined3d_query *query, uint32_t flags)
+static void wined3d_query_event_vk_poll_cs(void *object)
{
- struct wined3d_query_vk *query_vk = wined3d_query_vk(query);
+ struct wined3d_poll_callback_data *data = object;
+ struct wined3d_query *query = data->query;
struct wined3d_context_vk *context_vk;
+ struct wined3d_query_vk *query_vk;
+ uint32_t flags = data->flags;
BOOL *signalled;
+ query_vk = wined3d_query_vk(query);
context_vk = wined3d_context_vk(context_acquire(query->device, NULL, 0));
signalled = (BOOL *)query->data;
@@ -1775,7 +1873,8 @@ static BOOL wined3d_query_event_vk_poll(struct wined3d_query *query, uint32_t fl
if (query_vk->command_buffer_id == context_vk->current_command_buffer.id)
{
context_release(&context_vk->c);
- return *signalled = FALSE;
+ data->result = *signalled = FALSE;
+ return;
}
if (query_vk->command_buffer_id > context_vk->completed_command_buffer_id)
@@ -1784,10 +1883,23 @@ static BOOL wined3d_query_event_vk_poll(struct wined3d_query *query, uint32_t fl
context_release(&context_vk->c);
- return *signalled;
+ data->result = *signalled;
+}
+
+static BOOL wined3d_query_event_vk_poll(struct wined3d_query *query, uint32_t flags)
+{
+ struct wined3d_cs *cs = query->device->cs;
+ struct wined3d_poll_callback_data data;
+
+ data.query = query;
+ data.flags = flags;
+
+ wined3d_cs_run_priority_callback(cs, wined3d_query_event_vk_poll_cs, &data);
+
+ return data.result;
}
-static BOOL wined3d_query_event_vk_issue(struct wined3d_query *query, uint32_t flags)
+static void wined3d_query_event_vk_issue(struct wined3d_query *query, uint32_t flags)
{
struct wined3d_device_vk *device_vk = wined3d_device_vk(query->device);
struct wined3d_query_vk *query_vk = wined3d_query_vk(query);
@@ -1808,11 +1920,7 @@ static BOOL wined3d_query_event_vk_issue(struct wined3d_query *query, uint32_t f
if (!context_vk->current_command_buffer.vk_command_buffer)
--query_vk->command_buffer_id;
context_release(&context_vk->c);
-
- return TRUE;
}
-
- return FALSE;
}
static const struct wined3d_query_ops wined3d_query_event_vk_ops =
@@ -1822,7 +1930,7 @@ static const struct wined3d_query_ops wined3d_query_event_vk_ops =
.query_destroy = wined3d_query_vk_destroy,
};
-static BOOL wined3d_query_timestamp_vk_issue(struct wined3d_query *query, uint32_t flags)
+static void wined3d_query_timestamp_vk_issue(struct wined3d_query *query, uint32_t flags)
{
struct wined3d_device_vk *device_vk = wined3d_device_vk(query->device);
struct wined3d_query_vk *query_vk = wined3d_query_vk(query);
@@ -1846,18 +1954,14 @@ static BOOL wined3d_query_timestamp_vk_issue(struct wined3d_query *query, uint32
if (!wined3d_context_vk_allocate_query(context_vk, query_vk->q.type, &query_vk->pool_idx))
{
ERR("Failed to allocate new query.\n");
- return FALSE;
+ return;
}
VK_CALL(vkCmdWriteTimestamp(command_buffer, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
query_vk->pool_idx.pool_vk->vk_query_pool, query_vk->pool_idx.idx));
wined3d_context_vk_reference_query(context_vk, query_vk);
context_release(&context_vk->c);
-
- return TRUE;
}
-
- return FALSE;
}
static const struct wined3d_query_ops wined3d_query_timestamp_vk_ops =
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 79b02c2448d..6b885036260 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1952,7 +1952,7 @@ enum wined3d_query_state
struct wined3d_query_ops
{
BOOL (*query_poll)(struct wined3d_query *query, DWORD flags);
- BOOL (*query_issue)(struct wined3d_query *query, DWORD flags);
+ void (*query_issue)(struct wined3d_query *query, DWORD flags);
void (*query_destroy)(struct wined3d_query *query);
};
@@ -4823,7 +4823,6 @@ enum wined3d_push_constants
WINED3D_PUSH_CONSTANTS_PS_B,
};
-#define WINED3D_CS_QUERY_POLL_INTERVAL 10u
#define WINED3D_CS_QUEUE_SIZE 0x100000u
#define WINED3D_CS_SPIN_COUNT 10000000u
@@ -4879,7 +4878,6 @@ struct wined3d_cs
struct wined3d_cs_queue queue[WINED3D_CS_QUEUE_COUNT];
size_t data_size, start, end;
void *data;
- struct list query_poll_list;
BOOL queries_flushed;
HANDLE event;
@@ -4920,6 +4918,8 @@ void wined3d_cs_emit_set_render_state(struct wined3d_cs *cs,
void wined3d_cs_emit_unload_resource(struct wined3d_cs *cs, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
void wined3d_cs_init_object(struct wined3d_cs *cs,
void (*callback)(void *object), void *object) DECLSPEC_HIDDEN;
+void wined3d_cs_run_priority_callback(struct wined3d_cs *cs, void (*callback)(void *object),
+ void *object) DECLSPEC_HIDDEN;
static inline void wined3d_cs_finish(struct wined3d_cs *cs, enum wined3d_cs_queue_id queue_id)
{
--
2.32.0