panfrost: Add quirks system to cmdstream
authorTomeu Vizoso <tomeu.vizoso@collabora.com>
Thu, 28 Nov 2019 09:21:06 +0000 (10:21 +0100)
committerTomeu Vizoso <tomeu.vizoso@collabora.co.uk>
Tue, 3 Dec 2019 04:25:04 +0000 (04:25 +0000)
Similarly to how it's already done in the compiler, add a way to express
differences between GPU models that need to be taken into account when
assembling the cmdstream.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
src/gallium/drivers/panfrost/pan_blend_cso.c
src/gallium/drivers/panfrost/pan_context.c
src/gallium/drivers/panfrost/pan_fragment.c
src/gallium/drivers/panfrost/pan_job.c
src/gallium/drivers/panfrost/pan_screen.c
src/gallium/drivers/panfrost/pan_screen.h
src/panfrost/include/panfrost-quirks.h [new file with mode: 0644]

index 48bd513ab6e5409db5c399ed89d6c26a101b65f8..69683098c6818a05e2a831d5e16523b0feff852b 100644 (file)
@@ -30,6 +30,7 @@
 #include "pan_blend_shaders.h"
 #include "pan_blending.h"
 #include "pan_bo.h"
+#include "panfrost-quirks.h"
 
 /* A given Gallium blend state can be encoded to the hardware in numerous,
  * dramatically divergent ways due to the interactions of blending with
@@ -149,7 +150,7 @@ panfrost_bind_blend_state(struct pipe_context *pipe,
         if (!blend)
                 return;
 
-        if (screen->require_sfbd) {
+        if (screen->quirks & MIDGARD_SFBD) {
                 SET_BIT(ctx->fragment_shader_core.unknown2_4, MALI_NO_DITHER, !blend->dither);
         }
 
index 0c95ea6631c3c77aa375d7812bba2c1d8639eaf2..af8f94354e9b275c6b3f3afa17b8d550c306d00f 100644 (file)
@@ -30,6 +30,7 @@
 #include "pan_bo.h"
 #include "pan_context.h"
 #include "pan_format.h"
+#include "panfrost-quirks.h"
 
 #include "util/macros.h"
 #include "util/format/u_format.h"
@@ -102,7 +103,7 @@ panfrost_emit_midg_tiler(struct panfrost_batch *batch, unsigned vertex_count)
                 /* Disable the tiler */
                 t.hierarchy_mask |= MALI_TILER_DISABLED;
 
-                if (screen->require_sfbd) {
+                if (screen->quirks & MIDGARD_SFBD) {
                         t.hierarchy_mask = 0xFFF; /* TODO: What's this? */
                         t.polygon_list_size = 0x200;
 
@@ -217,7 +218,7 @@ panfrost_attach_vt_framebuffer(struct panfrost_context *ctx)
         struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
 
         if (!batch->framebuffer)
-                batch->framebuffer = screen->require_sfbd ?
+                batch->framebuffer = (screen->quirks & MIDGARD_SFBD) ?
                                      panfrost_attach_vt_sfbd(batch) :
                                      panfrost_attach_vt_mfbd(batch);
 
@@ -426,9 +427,8 @@ panfrost_default_shader_backend(struct panfrost_context *ctx)
          * these earlier chips (perhaps this is a chicken bit of some kind).
          * More investigation is needed. */
 
-       if (screen->require_sfbd) {
+       if (screen->quirks & MIDGARD_SFBD)
                shader.unknown2_4 |= 0x10;
-       }
 
         struct pipe_stencil_state default_stencil = {
                 .enabled = 0,
@@ -1068,7 +1068,7 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
                         ctx->fragment_shader_core.blend.shader = 0;
                 }
 
-                if (screen->require_sfbd) {
+                if (screen->quirks & MIDGARD_SFBD) {
                         /* When only a single render target platform is used, the blend
                          * information is inside the shader meta itself. We
                          * additionally need to signal CAN_DISCARD for nontrivial blend
@@ -1092,7 +1092,7 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
 
                 ctx->payloads[PIPE_SHADER_FRAGMENT].postfix.shader = transfer.gpu;
 
-                if (!screen->require_sfbd) {
+                if (!(screen->quirks & MIDGARD_SFBD)) {
                         /* Additional blend descriptor tacked on for jobs using MFBD */
 
                         struct midgard_blend_rt rts[4];
index 9fe39d7c1bba2cd5309b453de5cecfadf14ffca3..b6bbce391c4bbe54d4b8d1b185194533fc9f19e7 100644 (file)
@@ -25,6 +25,7 @@
 #include "pan_context.h"
 #include "pan_util.h"
 #include "pan_format.h"
+#include "panfrost-quirks.h"
 
 #include "util/format/u_format.h"
 
@@ -52,7 +53,7 @@ panfrost_fragment_job(struct panfrost_batch *batch, bool has_draws)
 {
         struct panfrost_screen *screen = pan_screen(batch->ctx->base.screen);
 
-        mali_ptr framebuffer = screen->require_sfbd ?
+        mali_ptr framebuffer = screen->quirks & MIDGARD_SFBD ?
                                panfrost_sfbd_fragment(batch, has_draws) :
                                panfrost_mfbd_fragment(batch, has_draws);
 
index ea6bd02251175437a2d7d32988389a8fc9cdc009..e2e54aff21670d6cac336b4641bbe82d6ab64731 100644 (file)
@@ -35,6 +35,7 @@
 #include "util/u_pack_color.h"
 #include "pan_util.h"
 #include "pandecode/decode.h"
+#include "panfrost-quirks.h"
 
 /* panfrost_bo_access is here to help us keep track of batch accesses to BOs
  * and build a proper dependency graph such that batches can be pipelined for
@@ -677,7 +678,7 @@ panfrost_batch_get_tiler_dummy(struct panfrost_batch *batch)
         if (batch->tiler_dummy)
                 return batch->tiler_dummy;
 
-        if (!screen->require_sfbd)
+        if (!(screen->quirks & MIDGARD_NO_HIER_TILING))
                 create_flags = PAN_BO_INVISIBLE;
 
         batch->tiler_dummy = panfrost_batch_create_bo(batch, 4096,
index 212bc5b02ac072d086b5966e62c922fadd7184d0..f0b9585e6581779f1bdd0e04d84292f17e499f7a 100644 (file)
@@ -52,6 +52,7 @@
 
 #include "pan_context.h"
 #include "midgard/midgard_compile.h"
+#include "panfrost-quirks.h"
 
 static const struct debug_named_value debug_options[] = {
         {"msgs",      PAN_DBG_MSGS,    "Print debug messages"},
@@ -732,7 +733,7 @@ panfrost_create_screen(int fd, struct renderonly *ro)
         screen->fd = fd;
 
         screen->gpu_id = panfrost_query_gpu_version(screen);
-        screen->require_sfbd = screen->gpu_id < 0x0750; /* T760 is the first to support MFBD */
+        screen->quirks = panfrost_get_quirks(screen->gpu_id);
         screen->kernel_version = drmGetVersion(fd);
 
         /* Check if we're loading against a supported GPU model. */
@@ -744,8 +745,7 @@ panfrost_create_screen(int fd, struct renderonly *ro)
                 break;
         default:
                 /* Fail to load against untested models */
-                debug_printf("panfrost: Unsupported model %X",
-                             screen->gpu_id);
+                debug_printf("panfrost: Unsupported model %X", screen->gpu_id);
                 return NULL;
         }
 
index c864629a3721bccd0ca129a103ad0fcf99538432..974010ae9946f84ea80981a57d074cb5f7e40042 100644 (file)
@@ -80,7 +80,7 @@ struct panfrost_screen {
 
         /* Properties of the GPU in use */
         unsigned gpu_id;
-        bool require_sfbd;
+        unsigned quirks;
 
         drmVersionPtr kernel_version;
 
diff --git a/src/panfrost/include/panfrost-quirks.h b/src/panfrost/include/panfrost-quirks.h
new file mode 100644 (file)
index 0000000..83c7c84
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2019 Collabora, Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef __PANFROST_QUIRKS_H
+#define __PANFROST_QUIRKS_H
+
+/* Model-specific quirks requiring workarounds/etc. Quirks may be errata
+ * requiring a workaround, or features. We're trying to be quirk-positive
+ * here; quirky is the best! */
+
+/* Whether the GPU lacks the capability for hierarchical tiling, without an
+ * "Advanced Tiling Unit", instead requiring a single bin size for the entire
+ * framebuffer be selected by the driver */
+
+#define MIDGARD_NO_HIER_TILING (1 << 0)
+
+/* Whether this GPU lacks native multiple render target support and accordingly
+ * needs SFBDs instead, with complex lowering with ES3 */
+
+#define MIDGARD_SFBD (1 << 1)
+
+static inline unsigned
+panfrost_get_quirks(unsigned gpu_id)
+{
+        switch (gpu_id) {
+        case 0x600:
+        case 0x620:
+                return MIDGARD_SFBD;
+
+        case 0x720:
+                return MIDGARD_SFBD | MIDGARD_NO_HIER_TILING;
+
+        case 0x820:
+        case 0x830:
+                return MIDGARD_NO_HIER_TILING;
+
+        case 0x750:
+        case 0x860:
+        case 0x880:
+                return 0;
+
+        default:
+                unreachable("Invalid Midgard GPU ID");
+        }
+}
+
+#endif