Mesa (main): panfrost: Simplify format class selection

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jan 26 02:01:50 UTC 2022


Module: Mesa
Branch: main
Commit: 5a8d86f69efa4723f703d135a9cd27a982a62861
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=5a8d86f69efa4723f703d135a9cd27a982a62861

Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date:   Tue Jan 25 18:08:55 2022 -0500

panfrost: Simplify format class selection

This was made way more complicated than it needs to be for a Midgard-only pass.
The only caller doesn't care about the class, only if it's native or not.
Simplify it appropriately.

It really isn't that hard.

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

---

 src/panfrost/util/pan_lower_framebuffer.c | 51 +++++++------------------------
 src/panfrost/util/pan_lower_framebuffer.h |  9 ------
 2 files changed, 11 insertions(+), 49 deletions(-)

diff --git a/src/panfrost/util/pan_lower_framebuffer.c b/src/panfrost/util/pan_lower_framebuffer.c
index 72f2cb580c0..6baa9189b58 100644
--- a/src/panfrost/util/pan_lower_framebuffer.c
+++ b/src/panfrost/util/pan_lower_framebuffer.c
@@ -87,49 +87,23 @@ pan_unpacked_type_for_format(const struct util_format_description *desc)
         }
 }
 
-static enum pan_format_class
-pan_format_class_load(const struct util_format_description *desc, unsigned quirks)
+static bool
+pan_is_format_native(const struct util_format_description *desc, unsigned quirks, bool is_store)
 {
-        /* Pure integers can be loaded via EXT_framebuffer_fetch and should be
-         * handled as a raw load with a size conversion (it's cheap). Likewise,
-         * since float framebuffers are internally implemented as raw (i.e.
-         * integer) framebuffers with blend shaders to go back and forth, they
-         * should be s/w as well */
+        if (is_store)
+                return false;
 
         if (util_format_is_pure_integer(desc->format) || util_format_is_float(desc->format))
-                return PAN_FORMAT_SOFTWARE;
+                return false;
 
-        /* Check if we can do anything better than software architecturally */
-        if (quirks & MIDGARD_NO_TYPED_BLEND_LOADS) {
-                return (quirks & NO_BLEND_PACKS)
-                        ? PAN_FORMAT_SOFTWARE : PAN_FORMAT_PACK;
-        }
+        if (quirks & MIDGARD_NO_TYPED_BLEND_LOADS)
+                return false;
 
         /* Some formats are missing as typed but have unpacks */
-        switch (desc->format) {
-        case PIPE_FORMAT_R11G11B10_FLOAT:
-                return PAN_FORMAT_PACK;
-        default:
-                return PAN_FORMAT_NATIVE;
-        }
-}
+        if (desc->format == PIPE_FORMAT_R11G11B10_FLOAT)
+                return false;
 
-static enum pan_format_class
-pan_format_class_store(const struct util_format_description *desc, unsigned quirks)
-{
-        return (quirks & NO_BLEND_PACKS) ? PAN_FORMAT_SOFTWARE :
-                                           PAN_FORMAT_PACK;
-}
-
-/* Convenience method */
-
-static enum pan_format_class
-pan_format_class(const struct util_format_description *desc, unsigned quirks, bool is_store)
-{
-        if (is_store)
-                return pan_format_class_store(desc, quirks);
-        else
-                return pan_format_class_load(desc, quirks);
+        return true;
 }
 
 /* Software packs/unpacks, by format class. Packs take in the pixel value typed
@@ -619,11 +593,8 @@ pan_lower_framebuffer(nir_shader *shader, const enum pipe_format *rt_fmts,
                                 const struct util_format_description *desc =
                                    util_format_description(rt_fmts[rt]);
 
-                                enum pan_format_class fmt_class =
-                                        pan_format_class(desc, quirks, is_store);
-
                                 /* Don't lower */
-                                if (fmt_class == PAN_FORMAT_NATIVE)
+                                if (pan_is_format_native(desc, quirks, is_store))
                                         continue;
 
                                 /* EXT_shader_framebuffer_fetch requires
diff --git a/src/panfrost/util/pan_lower_framebuffer.h b/src/panfrost/util/pan_lower_framebuffer.h
index 93f448e34a6..23230b648d3 100644
--- a/src/panfrost/util/pan_lower_framebuffer.h
+++ b/src/panfrost/util/pan_lower_framebuffer.h
@@ -30,15 +30,6 @@
 #include "compiler/nir/nir.h"
 #include "util/format/u_format.h"
 
-/* NATIVE formats can use a typed load/store. PACK formats cannot but can use a
- * typed pack/unpack instruction. SOFTWARE formats are lowered */
-
-enum pan_format_class {
-        PAN_FORMAT_NATIVE,
-        PAN_FORMAT_PACK,
-        PAN_FORMAT_SOFTWARE
-};
-
 nir_alu_type pan_unpacked_type_for_format(const struct util_format_description *desc);
 
 bool pan_lower_framebuffer(nir_shader *shader,



More information about the mesa-commit mailing list