Mesa (master): zink: properly handle query pool overflows
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Jul 13 21:12:51 UTC 2020
Module: Mesa
Branch: master
Commit: 2c02ca21842c71162dbcce98d4b7357db5489348
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2c02ca21842c71162dbcce98d4b7357db5489348
Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date: Mon May 25 10:59:57 2020 -0400
zink: properly handle query pool overflows
inline a query result value to each query object so we can stash the partial
result just before we do a pool reset, which will always happen during the
suspend/resume query mechanism that swaps active queries from a flushed batch
to the next batch
once (or if) the "real" call to fetch query results is called, we can dump the
inlined value into the fetch value and return the full results
fixes mesa/mesa#3000
Reviewed-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5533>
---
src/gallium/drivers/zink/zink_query.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/gallium/drivers/zink/zink_query.c b/src/gallium/drivers/zink/zink_query.c
index 8c4e792eb89..96e05c830fd 100644
--- a/src/gallium/drivers/zink/zink_query.c
+++ b/src/gallium/drivers/zink/zink_query.c
@@ -30,6 +30,8 @@ struct zink_query {
unsigned fences;
struct list_head active_list;
+
+ union pipe_query_result accumulated_result;
};
static VkQueryType
@@ -183,6 +185,7 @@ zink_begin_query(struct pipe_context *pctx,
/* ignore begin_query for timestamps */
if (query->type == PIPE_QUERY_TIMESTAMP)
return true;
+ util_query_clear_result(&query->accumulated_result, query->type);
begin_query(zink_context(pctx), batch, query);
@@ -205,13 +208,20 @@ get_query_result(struct pipe_context *pctx,
if (query->use_64bit)
flags |= VK_QUERY_RESULT_64_BIT;
+ if (result != &query->accumulated_result) {
+ memcpy(result, &query->accumulated_result, sizeof(query->accumulated_result));
+ util_query_clear_result(&query->accumulated_result, query->type);
+ } else {
+ assert(query->vkqtype != VK_QUERY_TYPE_TIMESTAMP);
+ flags |= VK_QUERY_RESULT_PARTIAL_BIT;
+ }
+
// union pipe_query_result results[NUM_QUERIES * 2];
/* xfb queries return 2 results */
uint64_t results[NUM_QUERIES * 2];
memset(results, 0, sizeof(results));
int num_results = query->curr_query - query->last_checked_query;
if (query->vkqtype == VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT) {
- char tf_result[16] = {};
/* this query emits 2 values */
assert(query->curr_query <= ARRAY_SIZE(results) / 2);
VkResult status = vkGetQueryPoolResults(screen->dev, query->query_pool,
@@ -222,7 +232,6 @@ get_query_result(struct pipe_context *pctx,
flags);
if (status != VK_SUCCESS)
return false;
- memcpy(result, tf_result + (query->type == PIPE_QUERY_PRIMITIVES_GENERATED ? 8 : 0), 8);
/* multiply for correct looping behavior below */
num_results *= 2;
} else {
@@ -237,7 +246,6 @@ get_query_result(struct pipe_context *pctx,
return false;
}
- util_query_clear_result(result, query->type);
for (int i = 0; i < num_results; ++i) {
switch (query->type) {
case PIPE_QUERY_OCCLUSION_PREDICATE:
@@ -286,6 +294,7 @@ end_query(struct zink_context *ctx, struct zink_batch *batch, struct zink_query
else
vkCmdEndQuery(batch->cmdbuf, q->query_pool, q->curr_query);
if (++q->curr_query == q->num_queries) {
+ get_query_result(&ctx->base, (struct pipe_query*)q, false, &q->accumulated_result);
vkCmdResetQueryPool(batch->cmdbuf, q->query_pool, 0, q->num_queries);
q->last_checked_query = q->curr_query = 0;
}
More information about the mesa-commit
mailing list