aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/panfrost/Makefile.sources1
-rw-r--r--src/panfrost/bifrost/bi_quirks.h60
-rw-r--r--src/panfrost/bifrost/bifrost_compile.c4
-rw-r--r--src/panfrost/bifrost/bifrost_compile.h2
-rw-r--r--src/panfrost/bifrost/cmdline.c4
-rw-r--r--src/panfrost/bifrost/compiler.h1
6 files changed, 69 insertions, 3 deletions
diff --git a/src/panfrost/Makefile.sources b/src/panfrost/Makefile.sources
index 1099ec528d2..58e72e38841 100644
--- a/src/panfrost/Makefile.sources
+++ b/src/panfrost/Makefile.sources
@@ -3,6 +3,7 @@ bifrost_FILES := \
bifrost/bifrost_compile.c \
bifrost/bifrost_compile.h \
bifrost/bifrost_tables.c \
+ bifrost/bi_quirks.c \
bifrost/compiler.h \
bifrost/cmdline.c \
bifrost/disassemble.c \
diff --git a/src/panfrost/bifrost/bi_quirks.h b/src/panfrost/bifrost/bi_quirks.h
new file mode 100644
index 00000000000..5ec8e021d83
--- /dev/null
+++ b/src/panfrost/bifrost/bi_quirks.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2019-2020 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 __BI_QUIRKS_H
+#define __BI_QUIRKS_H
+
+/* Model-specific quirks requiring compiler workarounds/etc. Quirks
+ * may be errata requiring a workaround, or features. We're trying to be
+ * quirk-positive here; quirky is the best! */
+
+/* Whether this GPU lacks support for the preload mechanism. New GPUs can have
+ * varyings and textures preloaded into the fragment shader to amortize the I/O
+ * cost; early Bifrost models lacked this feature. */
+
+#define BIFROST_NO_PRELOAD (1 << 0)
+
+/* Whether this GPU lacks support for the _FAST family of opcodes for fast
+ * computation of special functions requiring lookup tables. Early GPUs require
+ * rather unweildly lowering mechanisms for thesr things. */
+
+#define BIFROST_NO_FAST_OP (1 << 1)
+
+static inline unsigned
+bifrost_get_quirks(unsigned product_id)
+{
+ switch (product_id >> 12) {
+ case 6: /* 1st gen */
+ return BIFROST_NO_PRELOAD |
+ BIFROST_NO_FAST_OP;
+
+ case 7: /* 2nd gen */
+ case 8: /* 3rd gen */
+ return 0;
+
+ default:
+ unreachable("Unknown Bifrost GPU ID");
+ }
+}
+
+#endif
diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c
index f126123cfd8..754876f89ee 100644
--- a/src/panfrost/bifrost/bifrost_compile.c
+++ b/src/panfrost/bifrost/bifrost_compile.c
@@ -33,12 +33,14 @@
#include "disassemble.h"
#include "bifrost_compile.h"
#include "compiler.h"
+#include "bi_quirks.h"
void
-bifrost_compile_shader_nir(nir_shader *nir, bifrost_program *program)
+bifrost_compile_shader_nir(nir_shader *nir, bifrost_program *program, unsigned product_id)
{
bi_context *ctx = rzalloc(NULL, bi_context);
ctx->nir = nir;
+ ctx->quirks = bifrost_get_quirks(product_id);
nir_print_shader(nir, stdout);
diff --git a/src/panfrost/bifrost/bifrost_compile.h b/src/panfrost/bifrost/bifrost_compile.h
index 8b63af0dd40..f06e0b58700 100644
--- a/src/panfrost/bifrost/bifrost_compile.h
+++ b/src/panfrost/bifrost/bifrost_compile.h
@@ -31,7 +31,7 @@ typedef struct {
struct util_dynarray compiled;
} bifrost_program;
-void bifrost_compile_shader_nir(nir_shader *nir, bifrost_program *program);
+void bifrost_compile_shader_nir(nir_shader *nir, bifrost_program *program, unsigned product_id);
static const nir_shader_compiler_options bifrost_nir_options = {
.lower_ffma = true,
diff --git a/src/panfrost/bifrost/cmdline.c b/src/panfrost/bifrost/cmdline.c
index fdeab59e15c..bf55ded7df8 100644
--- a/src/panfrost/bifrost/cmdline.c
+++ b/src/panfrost/bifrost/cmdline.c
@@ -65,7 +65,9 @@ compile_shader(char **argv)
NIR_PASS_V(nir[i], gl_nir_lower_buffers, prog);
NIR_PASS_V(nir[i], nir_opt_constant_folding);
- bifrost_compile_shader_nir(nir[i], &compiled);
+
+ unsigned product_id = 0x7212; /* Mali G52 */
+ bifrost_compile_shader_nir(nir[i], &compiled, product_id);
}
}
diff --git a/src/panfrost/bifrost/compiler.h b/src/panfrost/bifrost/compiler.h
index 7ffe9e51a35..04a0c39ab97 100644
--- a/src/panfrost/bifrost/compiler.h
+++ b/src/panfrost/bifrost/compiler.h
@@ -318,6 +318,7 @@ typedef struct bi_block {
typedef struct {
nir_shader *nir;
struct list_head blocks; /* list of bi_block */
+ uint32_t quirks;
} bi_context;
/* So we can distinguish between SSA/reg/sentinel quickly */