panfrost: Simplify format class selection
authorAlyssa Rosenzweig <alyssa@collabora.com>
Tue, 25 Jan 2022 23:08:55 +0000 (18:08 -0500)
committerMarge Bot <emma+marge@anholt.net>
Wed, 26 Jan 2022 01:45:09 +0000 (01:45 +0000)
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@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14724>

src/panfrost/util/pan_lower_framebuffer.c
src/panfrost/util/pan_lower_framebuffer.h

index 72f2cb5..6baa918 100644 (file)
@@ -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
index 93f448e..23230b6 100644 (file)
 #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,