panfrost: Handle writes_memory correctly
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tue, 2 Jun 2020 18:12:29 +0000 (14:12 -0400)
committerMarge Bot <eric+marge@anholt.net>
Wed, 3 Jun 2020 20:48:24 +0000 (20:48 +0000)
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 <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5300>

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

index 3bc384d49b401fc72bb38c18ac663878e343dc63..d569b26732e89b11238662b981d89cd778eca05d 100644 (file)
@@ -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);
index 6edc7a80ed7c0ed6936a02ef69eb67e16506d950..a40a1505817ac8caea38981298f3d78b89d4b3d5 100644 (file)
@@ -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);
index a4ea44a96b9b235506fee7007fd2da3a6a98749c..aafb6ad138f5efba57b6a3f51f6c8186053a8ff5 100644 (file)
@@ -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;