panfrost: Determine load classes for formats
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 13 May 2020 16:22:22 +0000 (12:22 -0400)
committerMarge Bot <eric+marge@anholt.net>
Mon, 1 Jun 2020 15:46:23 +0000 (15:46 +0000)
Via quirks.

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

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

index 28c44f7b0cb1dad5244d3af605c8f822de5b2d78..33c1d5af75dca30db67589cc470c7a11184f05b8 100644 (file)
@@ -52,6 +52,7 @@
 #include "compiler/nir/nir_format_convert.h"
 #include "util/format/u_format.h"
 #include "pan_lower_framebuffer.h"
+#include "panfrost-quirks.h"
 
 /* Determines the unpacked type best suiting a given format, so the rest of the
  * pipeline may be adjusted accordingly */
@@ -84,3 +85,31 @@ pan_unpacked_type_for_format(const struct util_format_description *desc)
                 unreachable("Format not renderable");
         }
 }
+
+enum pan_format_class
+pan_format_class_load(const struct util_format_description *desc, unsigned quirks)
+{
+        /* 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;
+        }
+
+        /* Some formats are missing as typed on some GPUs but have unpacks */
+        if (quirks & MIDGARD_MISSING_LOADS) {
+                switch (desc->format) {
+                case PIPE_FORMAT_R11G11B10_FLOAT:
+                case PIPE_FORMAT_R10G10B10A2_UNORM:
+                case PIPE_FORMAT_B10G10R10A2_UNORM:
+                case PIPE_FORMAT_R10G10B10X2_UNORM:
+                case PIPE_FORMAT_B10G10R10X2_UNORM:
+                case PIPE_FORMAT_R10G10B10A2_UINT:
+                        return PAN_FORMAT_PACK;
+                default:
+                        return PAN_FORMAT_NATIVE;
+                }
+        }
+
+        /* Otherwise, we can do native */
+        return PAN_FORMAT_NATIVE;
+}
index b18660eb9b2d8c10a4e5f44a37952cda5afea865..7bca12f561a8e7ebfeaba590655e9da2a8cd8c06 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);
+enum pan_format_class pan_format_class_load(const struct util_format_description *desc, unsigned quirks);
 
 #endif