panfrost: Don't force early-z with occlusion query
authorAlyssa Rosenzweig <alyssa@collabora.com>
Fri, 4 Jun 2021 18:50:53 +0000 (14:50 -0400)
committerMarge Bot <eric+marge@anholt.net>
Thu, 10 Jun 2021 18:06:10 +0000 (18:06 +0000)
..even if there is no z/s enabled. Fixes
dEQP-GLES31.functional.fbo.no_attachments.* on Midgard.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11123>

src/gallium/drivers/panfrost/pan_cmdstream.c
src/gallium/drivers/panfrost/pan_context.c

index f4628dc..9b970f9 100644 (file)
@@ -536,14 +536,16 @@ panfrost_prepare_fs_state(struct panfrost_context *ctx,
                                 else
                                         cfg.properties.midgard.work_register_count = fs->info.work_reg_count;
 
-                                /* Workaround a hardware errata where early-z cannot be enabled
-                                 * when discarding even when the depth buffer is read-only, by
-                                 * lying to the hardware about the discard and setting the
-                                 * reads tilebuffer? flag to compensate */
+                                /* Hardware quirks around early-zs forcing
+                                 * without a depth buffer. Note this breaks
+                                 * occlusion queries. */
+                                bool has_oq = ctx->occlusion_query && ctx->active_queries;
+                                bool force_ez_with_discard = !zsa->enabled && !has_oq;
+
                                 cfg.properties.midgard.shader_reads_tilebuffer =
-                                        !zsa->enabled && fs->info.fs.can_discard;
+                                        force_ez_with_discard && fs->info.fs.can_discard;
                                 cfg.properties.midgard.shader_contains_discard =
-                                        zsa->enabled && fs->info.fs.can_discard;
+                                        !force_ez_with_discard && fs->info.fs.can_discard;
                         }
 
                         if (dev->quirks & MIDGARD_SFBD && rt_count > 0) {
index 4d5d940..51ea2a2 100644 (file)
@@ -1699,6 +1699,7 @@ panfrost_set_active_query_state(struct pipe_context *pipe,
 {
         struct panfrost_context *ctx = pan_context(pipe);
         ctx->active_queries = enable;
+        ctx->dirty_shader[PIPE_SHADER_FRAGMENT] |= PAN_DIRTY_STAGE_RENDERER;
 }
 
 static void
@@ -1781,6 +1782,7 @@ panfrost_begin_query(struct pipe_context *pipe, struct pipe_query *q)
 
                 query->msaa = (ctx->pipe_framebuffer.samples > 1);
                 ctx->occlusion_query = query;
+                ctx->dirty_shader[PIPE_SHADER_FRAGMENT] |= PAN_DIRTY_STAGE_RENDERER;
                 break;
         }
 
@@ -1813,6 +1815,7 @@ panfrost_end_query(struct pipe_context *pipe, struct pipe_query *q)
         case PIPE_QUERY_OCCLUSION_PREDICATE:
         case PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE:
                 ctx->occlusion_query = NULL;
+                ctx->dirty_shader[PIPE_SHADER_FRAGMENT] |= PAN_DIRTY_STAGE_RENDERER;
                 break;
         case PIPE_QUERY_PRIMITIVES_GENERATED:
                 query->end = ctx->prims_generated;