Module: Mesa
Branch: master
Commit: 726e2eb8f92c03625e2085dce6605e04c3187509
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=726e2eb8f92c03625e2085dce6605e04c3187509

Author: Mike Blumenkrantz <[email protected]>
Date:   Sun Mar 14 19:39:24 2021 -0400

zink: reorder availability handling for (user) qbos

if the shortcut method without a staging buffer fails, falling back
to the staging buffer is more sane than silently failing

Reviewed-by: Dave Airlie <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9811>

---

 src/gallium/drivers/zink/zink_query.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_query.c 
b/src/gallium/drivers/zink/zink_query.c
index ab277a7b664..dd9e6a28179 100644
--- a/src/gallium/drivers/zink/zink_query.c
+++ b/src/gallium/drivers/zink/zink_query.c
@@ -926,20 +926,18 @@ zink_get_query_result_resource(struct pipe_context *pctx,
        */
 
       VkQueryResultFlags flag = is_time_query(query) ? 0 : 
VK_QUERY_RESULT_PARTIAL_BIT;
-      if (fences) {
-         struct pipe_resource *staging = pipe_buffer_create(pctx->screen, 0, 
PIPE_USAGE_STAGING, result_size * 2);
-         copy_results_to_buffer(ctx, query, zink_resource(staging), 0, 1, 
size_flags | VK_QUERY_RESULT_WITH_AVAILABILITY_BIT | flag);
-         zink_copy_buffer(ctx, &ctx->batch, res, zink_resource(staging), 
offset, result_size, result_size);
-         pipe_resource_reference(&staging, NULL);
-      } else {
+      if (!fences) {
          uint64_t u64[2] = {0};
          if (vkGetQueryPoolResults(screen->dev, query->query_pool, query_id, 
1, 2 * result_size, u64,
-                                   0, size_flags | 
VK_QUERY_RESULT_WITH_AVAILABILITY_BIT | flag) != VK_SUCCESS) {
-            debug_printf("zink: getting query result failed\n");
+                                   0, size_flags | 
VK_QUERY_RESULT_WITH_AVAILABILITY_BIT | flag) == VK_SUCCESS) {
+            pipe_buffer_write(pctx, pres, offset, result_size, (unsigned 
char*)u64 + result_size);
             return;
          }
-         pipe_buffer_write(pctx, pres, offset, result_size, (unsigned 
char*)u64 + result_size);
       }
+      struct pipe_resource *staging = pipe_buffer_create(pctx->screen, 0, 
PIPE_USAGE_STAGING, result_size * 2);
+      copy_results_to_buffer(ctx, query, zink_resource(staging), 0, 1, 
size_flags | VK_QUERY_RESULT_WITH_AVAILABILITY_BIT | flag);
+      zink_copy_buffer(ctx, &ctx->batch, res, zink_resource(staging), offset, 
result_size, result_size);
+      pipe_resource_reference(&staging, NULL);
       return;
    }
 

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to