mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-16 07:38:14 +02:00
freedreno/ir3: add NIR compiler
The NIR compiler frontend is an alternative to the TGSI f/e, producing the same ir3 IR and using the same backend passes for scheduling, etc. It is not enabled by default yet, as there are still some regressions. To enable, use 'FD_MESA_DEBUG=nir'. It is enough to use with, for example, xonotic or supertuxkart. With the NIR f/e, scalarizing and a number of other lowering steps happen in NIR, so we don't have to do them in ir3. Which simplifies the f/e and allows the lowered instructions to pass through other optimization stages. Signed-off-by: Rob Clark <robclark@freedesktop.org>
This commit is contained in:
parent
700d949ea1
commit
8b0b81339b
7 changed files with 1762 additions and 5 deletions
|
|
@ -121,6 +121,7 @@ ir3_SOURCES := \
|
|||
ir3/instr-a3xx.h \
|
||||
ir3/ir3.c \
|
||||
ir3/ir3_compiler.c \
|
||||
ir3/ir3_compiler_nir.c \
|
||||
ir3/ir3_compiler.h \
|
||||
ir3/ir3_cp.c \
|
||||
ir3/ir3_depth.c \
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ static const struct debug_named_value debug_options[] = {
|
|||
{"optdump", FD_DBG_OPTDUMP,"Dump shader DAG to .dot files"},
|
||||
{"glsl120", FD_DBG_GLSL120,"Temporary flag to force GLSL 120 (rather than 130) on a3xx+"},
|
||||
{"nocp", FD_DBG_NOCP, "Disable copy-propagation"},
|
||||
{"nir", FD_DBG_NIR, "Enable experimental NIR compiler"},
|
||||
DEBUG_NAMED_VALUE_END
|
||||
};
|
||||
|
||||
|
|
@ -345,6 +346,10 @@ fd_screen_get_shader_param(struct pipe_screen *pscreen, unsigned shader,
|
|||
case PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS:
|
||||
return 16384;
|
||||
case PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH:
|
||||
/* for now, let someone else flatten if/else when using NIR: */
|
||||
if ((fd_mesa_debug & FD_DBG_NIR) &&
|
||||
(is_a3xx(screen) || is_a4xx(screen)))
|
||||
return 0;
|
||||
return 8; /* XXX */
|
||||
case PIPE_SHADER_CAP_MAX_INPUTS:
|
||||
case PIPE_SHADER_CAP_MAX_OUTPUTS:
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ enum adreno_stencil_op fd_stencil_op(unsigned op);
|
|||
#define FD_DBG_OPTDUMP 0x0800
|
||||
#define FD_DBG_GLSL120 0x1000
|
||||
#define FD_DBG_NOCP 0x2000
|
||||
#define FD_DBG_NIR 0x4000
|
||||
|
||||
extern int fd_mesa_debug;
|
||||
extern bool fd_binning_enabled;
|
||||
|
|
|
|||
|
|
@ -215,6 +215,7 @@ static void print_usage(void)
|
|||
printf(" --saturate-t MASK - bitmask of samplers to saturate T coord\n");
|
||||
printf(" --saturate-r MASK - bitmask of samplers to saturate R coord\n");
|
||||
printf(" --nocp - disable copy propagation\n");
|
||||
printf(" --nir - use NIR compiler\n");
|
||||
printf(" --help - show this message\n");
|
||||
}
|
||||
|
||||
|
|
@ -229,6 +230,7 @@ int main(int argc, char **argv)
|
|||
const char *info;
|
||||
void *ptr;
|
||||
size_t size;
|
||||
int use_nir = 0;
|
||||
|
||||
fd_mesa_debug |= FD_DBG_DISASM;
|
||||
|
||||
|
|
@ -293,6 +295,11 @@ int main(int argc, char **argv)
|
|||
n++;
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(argv[n], "--nir")) {
|
||||
use_nir = true;
|
||||
n++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!strcmp(argv[n], "--help")) {
|
||||
print_usage();
|
||||
|
|
@ -333,8 +340,13 @@ int main(int argc, char **argv)
|
|||
break;
|
||||
}
|
||||
|
||||
info = "compiler";
|
||||
ret = ir3_compile_shader(&v, toks, key, true);
|
||||
if (use_nir) {
|
||||
info = "NIR compiler";
|
||||
ret = ir3_compile_shader_nir(&v, toks, key);
|
||||
} else {
|
||||
info = "TGSI compiler";
|
||||
ret = ir3_compile_shader(&v, toks, key, true);
|
||||
}
|
||||
|
||||
if (ret) {
|
||||
reset_variant(&v, "compiler failed, trying without copy propagation!");
|
||||
|
|
@ -348,3 +360,11 @@ int main(int argc, char **argv)
|
|||
}
|
||||
dump_info(&v, info);
|
||||
}
|
||||
|
||||
void _mesa_error_no_memory(const char *caller);
|
||||
|
||||
void
|
||||
_mesa_error_no_memory(const char *caller)
|
||||
{
|
||||
fprintf(stderr, "Mesa error: out of memory in %s", caller);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,9 @@
|
|||
#include "ir3_shader.h"
|
||||
|
||||
|
||||
int ir3_compile_shader_nir(struct ir3_shader_variant *so,
|
||||
const struct tgsi_token *tokens, struct ir3_shader_key key);
|
||||
|
||||
int ir3_compile_shader(struct ir3_shader_variant *so,
|
||||
const struct tgsi_token *tokens,
|
||||
struct ir3_shader_key key, bool cp);
|
||||
|
|
|
|||
1717
src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c
Normal file
1717
src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -177,10 +177,20 @@ create_variant(struct ir3_shader *shader, struct ir3_shader_key key)
|
|||
tgsi_dump(tokens, 0);
|
||||
}
|
||||
|
||||
ret = ir3_compile_shader(v, tokens, key, true);
|
||||
if (fd_mesa_debug & FD_DBG_NIR) {
|
||||
ret = ir3_compile_shader_nir(v, tokens, key);
|
||||
if (ret)
|
||||
reset_variant(v, "NIR compiler failed, fallback to TGSI!");
|
||||
} else {
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
if (ret) {
|
||||
reset_variant(v, "new compiler failed, trying without copy propagation!");
|
||||
ret = ir3_compile_shader(v, tokens, key, false);
|
||||
ret = ir3_compile_shader(v, tokens, key, true);
|
||||
if (ret) {
|
||||
reset_variant(v, "new compiler failed, trying without copy propagation!");
|
||||
ret = ir3_compile_shader(v, tokens, key, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (ret) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue