From: Alyssa Rosenzweig Date: Tue, 3 Mar 2020 19:27:05 +0000 (-0500) Subject: pan/bi: Add quirks system X-Git-Tag: upstream/20.1.8~2859 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0b26cb194cc433a9910247051024bd6468d9b05c;p=platform%2Fupstream%2Fmesa.git pan/bi: Add quirks system Modeled after the Midgard system. Already we know of two compiler-visible differences between G52 and G71, so let's keep track so we can eventually port the compiler to other Bifrost systems. Signed-off-by: Alyssa Rosenzweig Part-of: --- diff --git a/src/panfrost/Makefile.sources b/src/panfrost/Makefile.sources index 1099ec5..58e72e3 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 0000000..5ec8e02 --- /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 f126123..754876f 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 8b63af0..f06e0b5 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 fdeab59..bf55ded 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 7ffe9e5..04a0c39 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 */