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 <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4061>
This commit is contained in:
committed by
Marge Bot
parent
07228a6895
commit
0b26cb194c
@@ -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 \
|
||||
|
||||
@@ -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
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user