panfrost: Handle untyped_color_outputs on Bifrost
authorAlyssa Rosenzweig <alyssa@collabora.com>
Fri, 19 Aug 2022 21:49:33 +0000 (17:49 -0400)
committerMarge Bot <emma+marge@anholt.net>
Sun, 21 Aug 2022 19:37:10 +0000 (19:37 +0000)
For untyped_color_outputs, we need to ignore the type of the colour output in
the shader and instead use the type from the format. We have all the information
to do this at blend descriptor pack time, but not at shader compile time. This
means we need a (somewhat expensive) fixup in this edge case to ingest
NIR-to-TGSI. This will prevent a regression from the rest of the series.

Although the register_format field is also present on Valhall blend descriptors,
it is ignored so we don't need the fixup there.

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

src/gallium/drivers/panfrost/pan_cmdstream.c
src/panfrost/lib/pan_shader.c
src/panfrost/lib/pan_shader.h
src/panfrost/util/pan_ir.h

index 4ac9a14..a6af6ce 100644 (file)
@@ -435,8 +435,6 @@ panfrost_emit_blend(struct panfrost_batch *batch, void *rts, mali_ptr *blend_sha
                                 cfg.fixed_function.num_comps = 4;
                                 cfg.fixed_function.conversion.memory_format =
                                         panfrost_format_to_bifrost_blend(dev, format, dithered);
-                                cfg.fixed_function.conversion.register_format =
-                                        fs->info.bifrost.blend[i].format;
                                 cfg.fixed_function.rt = i;
 
 #if PAN_ARCH <= 7
@@ -444,6 +442,14 @@ panfrost_emit_blend(struct panfrost_batch *batch, void *rts, mali_ptr *blend_sha
                                         cfg.fixed_function.alpha_zero_nop = info.alpha_zero_nop;
                                         cfg.fixed_function.alpha_one_store = info.alpha_one_store;
                                 }
+
+                                if (fs->info.fs.untyped_color_outputs) {
+                                        cfg.fixed_function.conversion.register_format =
+                                                GENX(pan_fixup_blend_type)(fs->info.bifrost.blend[i].type, format);
+                                } else {
+                                        cfg.fixed_function.conversion.register_format =
+                                                fs->info.bifrost.blend[i].format;
+                                }
 #endif
                         }
                 }
index e5e9550..a149c07 100644 (file)
@@ -184,6 +184,19 @@ bifrost_blend_type_from_nir(nir_alu_type nir_type)
                 return 0;
         }
 }
+
+#if PAN_ARCH <= 7
+enum mali_register_file_format
+GENX(pan_fixup_blend_type)(nir_alu_type T_size, enum pipe_format format)
+{
+        const struct util_format_description *desc = util_format_description(format);
+        unsigned size = nir_alu_type_get_type_size(T_size);
+        nir_alu_type T_format = pan_unpacked_type_for_format(desc);
+        nir_alu_type T = nir_alu_type_get_base_type(T_format) | size;
+
+        return bifrost_blend_type_from_nir(T);
+}
+#endif
 #endif
 
 void
@@ -253,6 +266,7 @@ GENX(pan_shader_compile)(nir_shader *s,
                 info->fs.outputs_read = s->info.outputs_read >> FRAG_RESULT_DATA0;
                 info->fs.outputs_written = s->info.outputs_written >> FRAG_RESULT_DATA0;
                 info->fs.sample_shading = s->info.fs.uses_sample_shading;
+                info->fs.untyped_color_outputs = s->info.fs.untyped_color_outputs;
 
                 info->fs.can_discard = s->info.fs.uses_discard;
                 info->fs.early_fragment_tests = s->info.fs.early_fragment_tests;
index dce72e5..223f52e 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "compiler/nir/nir.h"
 #include "panfrost/util/pan_ir.h"
+#include "panfrost/util/pan_lower_framebuffer.h"
 
 #include "pan_device.h"
 #include "genxml/gen_macros.h"
@@ -43,6 +44,11 @@ GENX(pan_shader_compile)(nir_shader *nir,
                          struct util_dynarray *binary,
                          struct pan_shader_info *info);
 
+#if PAN_ARCH >= 6 && PAN_ARCH <= 7
+enum mali_register_file_format
+GENX(pan_fixup_blend_type)(nir_alu_type T_size, enum pipe_format format);
+#endif
+
 #if PAN_ARCH >= 9
 static inline enum mali_shader_stage
 pan_shader_stage(const struct pan_shader_info *info)
index e3fb48e..f456f2d 100644 (file)
@@ -292,6 +292,7 @@ struct pan_shader_info {
                         bool sample_shading;
                         bool early_fragment_tests;
                         bool can_early_z, can_fpk;
+                        bool untyped_color_outputs;
                         BITSET_WORD outputs_read;
                         BITSET_WORD outputs_written;
                 } fs;