From dce7722ef89100e5dea337064a9d6631bb18822a Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 2 Jun 2020 14:12:29 -0400 Subject: [PATCH] panfrost: Handle writes_memory correctly We need to pass it thru to EARLY_Z and WRITES_GLOBAL instead of ignoring and assuming respectively. Nontrivial performance fix. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/panfrost/pan_assemble.c | 2 ++ src/gallium/drivers/panfrost/pan_cmdstream.c | 8 +++++--- src/gallium/drivers/panfrost/pan_context.h | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_assemble.c b/src/gallium/drivers/panfrost/pan_assemble.c index 3bc384d49b4..d569b26732e 100644 --- a/src/gallium/drivers/panfrost/pan_assemble.c +++ b/src/gallium/drivers/panfrost/pan_assemble.c @@ -180,6 +180,8 @@ panfrost_shader_compile(struct panfrost_context *ctx, /* On Bifrost it's a sysval, on Midgard it's a varying */ state->reads_frag_coord = s->info.system_values_read & (1 << SYSTEM_VALUE_FRAG_COORD); + state->writes_global = s->info.writes_memory; + switch (stage) { case MESA_SHADER_VERTEX: state->attribute_count = util_bitcount64(s->info.inputs_read); diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index 6edc7a80ed7..a40a1505817 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -353,8 +353,10 @@ panfrost_shader_meta_init(struct panfrost_context *ctx, /* TODO: This is not conformant on ES3 */ meta->midgard1.flags_hi = MALI_SUPPRESS_INF_NAN; - meta->midgard1.flags_lo = MALI_WRITES_GLOBAL | 0x20; + meta->midgard1.flags_lo = 0x20; meta->midgard1.uniform_buffer_count = panfrost_ubo_count(ctx, st); + + SET_BIT(meta->midgard1.flags_hi, MALI_WRITES_GLOBAL, ss->writes_global); } } @@ -839,10 +841,10 @@ panfrost_frag_shader_meta_init(struct panfrost_context *ctx, /* TODO */ } else { /* Depending on whether it's legal to in the given shader, we try to - * enable early-z testing (or forward-pixel kill?) */ + * enable early-z testing. TODO: respect e-z force */ SET_BIT(fragmeta->midgard1.flags_lo, MALI_EARLY_Z, - !fs->can_discard && !fs->writes_depth); + !fs->can_discard && !fs->writes_depth && !fs->writes_global); /* Add the writes Z/S flags if needed. */ SET_BIT(fragmeta->midgard1.flags_lo, MALI_WRITES_Z, fs->writes_depth); diff --git a/src/gallium/drivers/panfrost/pan_context.h b/src/gallium/drivers/panfrost/pan_context.h index a4ea44a96b9..aafb6ad138f 100644 --- a/src/gallium/drivers/panfrost/pan_context.h +++ b/src/gallium/drivers/panfrost/pan_context.h @@ -192,6 +192,7 @@ struct panfrost_shader_state { bool reads_point_coord; bool reads_face; bool reads_frag_coord; + bool writes_global; unsigned stack_size; unsigned shared_size; -- 2.30.2