zink: fixup boolean queries
authorErik Faye-Lund <erik.faye-lund@collabora.com>
Mon, 15 Jul 2019 17:24:15 +0000 (19:24 +0200)
committerErik Faye-Lund <erik.faye-lund@collabora.com>
Mon, 28 Oct 2019 08:51:47 +0000 (08:51 +0000)
Acked-by: Jordan Justen <jordan.l.justen@intel.com>
src/gallium/drivers/zink/zink_query.c

index 3d83d76d88e79a1c1cd02f1e65aa92216cad2ba5..ee9837332ba916118d3469e60abc7b742642aead 100644 (file)
@@ -6,6 +6,7 @@
 #include "util/u_dump.h"
 
 struct zink_query {
+   enum pipe_query_type type;
    VkQueryPool queryPool;
    VkQueryType vkqtype;
    bool use_64bit;
@@ -47,6 +48,7 @@ zink_create_query(struct pipe_context *pctx,
    if (!query)
       return NULL;
 
+   query->type = query_type;
    query->vkqtype = convert_query_type(query_type, &query->use_64bit, &query->precise);
    if (query->vkqtype == -1)
       return NULL;
@@ -127,10 +129,25 @@ zink_get_query_result(struct pipe_context *pctx,
    if (query->use_64bit)
       flags |= VK_QUERY_RESULT_64_BIT;
 
-   VkResult status = vkGetQueryPoolResults(screen->dev, query->queryPool,
-                                           0, 1, sizeof(*result), result,
-                                           0, flags);
-   return status == VK_SUCCESS;
+   if (vkGetQueryPoolResults(screen->dev, query->queryPool,
+                             0, 1, sizeof(*result), result,
+                             0, flags) != VK_SUCCESS)
+      return false;
+
+   switch (query->type) {
+   case PIPE_QUERY_OCCLUSION_PREDICATE:
+   case PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE:
+   case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
+   case PIPE_QUERY_SO_OVERFLOW_ANY_PREDICATE:
+   case PIPE_QUERY_GPU_FINISHED:
+      /* fixup bool-queries */
+      result->b = result->u32 != 0;
+      break;
+   default:
+      ; /* nothing */
+   }
+
+   return TRUE;
 }
 
 void