From 0d4368b22aafef305bd85e2f4ba035b05d2c4479 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 4 Jun 2021 14:50:53 -0400 Subject: [PATCH] panfrost: Don't force early-z with occlusion query ..even if there is no z/s enabled. Fixes dEQP-GLES31.functional.fbo.no_attachments.* on Midgard. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/panfrost/pan_cmdstream.c | 14 ++++++++------ src/gallium/drivers/panfrost/pan_context.c | 3 +++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index f4628dc9f8b..9b970f9e7c1 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -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) { diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index 4d5d9408dff..51ea2a235c4 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -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;