diff --git a/src/gallium/drivers/r600/r600_asm.c b/src/gallium/drivers/r600/r600_asm.c index c416346a0e0..6a9690f699c 100644 --- a/src/gallium/drivers/r600/r600_asm.c +++ b/src/gallium/drivers/r600/r600_asm.c @@ -2632,7 +2632,8 @@ void *r600_create_vertex_fetch_shader(struct pipe_context *ctx, uint32_t *bytecode; int i, j, r, fs_size; struct r600_fetch_shader *shader; - unsigned no_sb = rctx->screen->b.debug_flags & DBG_NO_SB; + unsigned no_sb = rctx->screen->b.debug_flags & DBG_NO_SB || + (rctx->screen->b.debug_flags & DBG_NIR); unsigned sb_disasm = !no_sb || (rctx->screen->b.debug_flags & DBG_SB_DISASM); assert(count < 32); diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c index 09b89ab1787..fa5fea3cb28 100644 --- a/src/gallium/drivers/r600/r600_pipe.c +++ b/src/gallium/drivers/r600/r600_pipe.c @@ -55,6 +55,7 @@ static const struct debug_named_value r600_debug_options[] = { { "sbnofallback", DBG_SB_NO_FALLBACK, "Abort on errors instead of fallback" }, { "sbdisasm", DBG_SB_DISASM, "Use sb disassembler for shader dumps" }, { "sbsafemath", DBG_SB_SAFEMATH, "Disable unsafe math optimizations" }, + { "nirsb", DBG_NIR_SB, "Enable NIR with SB optimizer"}, DEBUG_NAMED_VALUE_END /* must be last */ }; @@ -245,7 +246,7 @@ fail: } static bool is_nir_enabled(struct r600_common_screen *screen) { - return (screen->debug_flags & DBG_NIR && + return ((screen->debug_flags & DBG_NIR_PREFERRED) && screen->family >= CHIP_CEDAR && screen->family < CHIP_CAYMAN); } diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h index a4821002297..3cb171a0d53 100644 --- a/src/gallium/drivers/r600/r600_pipe.h +++ b/src/gallium/drivers/r600/r600_pipe.h @@ -268,6 +268,9 @@ struct r600_gs_rings_state { #define DBG_SB_NO_FALLBACK (1 << 26) #define DBG_SB_DISASM (1 << 27) #define DBG_SB_SAFEMATH (1 << 28) +#define DBG_NIR_SB (1 << 28) + +#define DBG_NIR_PREFERRED (DBG_NIR_SB | DBG_NIR) struct r600_screen { struct r600_common_screen b; diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c index 2391561ecbc..31570a387d0 100644 --- a/src/gallium/drivers/r600/r600_shader.c +++ b/src/gallium/drivers/r600/r600_shader.c @@ -179,14 +179,14 @@ int r600_pipe_shader_create(struct pipe_context *ctx, pipe_shader_type_from_mesa(sel->nir->info.stage); bool dump = r600_can_dump_shader(&rctx->screen->b, processor); - unsigned use_sb = !(rctx->screen->b.debug_flags & DBG_NO_SB) /*&& - !(rscreen->b.debug_flags & DBG_NIR)*/; + unsigned use_sb = !(rctx->screen->b.debug_flags & (DBG_NO_SB | DBG_NIR)) || + (rctx->screen->b.debug_flags & DBG_NIR_SB); unsigned sb_disasm; unsigned export_shader; shader->shader.bc.isa = rctx->isa; - if (!(rscreen->b.debug_flags & DBG_NIR)) { + if (!(rscreen->b.debug_flags & DBG_NIR_PREFERRED)) { assert(sel->ir_type == PIPE_SHADER_IR_TGSI); r = r600_shader_from_tgsi(rctx, shader, key); if (r) { @@ -221,7 +221,7 @@ int r600_pipe_shader_create(struct pipe_context *ctx, tgsi_dump(sel->tokens, 0); } - if (rscreen->b.debug_flags & DBG_NIR) { + if (rscreen->b.debug_flags & (DBG_NIR_PREFERRED)) { fprintf(stderr, "--NIR --------------------------------------------------------\n"); nir_print_shader(sel->nir, stderr); } @@ -286,7 +286,7 @@ int r600_pipe_shader_create(struct pipe_context *ctx, char fname[1024]; snprintf(fname, 1024, "shader_from_%s_%d.cpp", (sel->ir_type == PIPE_SHADER_IR_TGSI ? - (rscreen->b.debug_flags & DBG_NIR ? "tgsi-nir" : "tgsi") + (rscreen->b.debug_flags & DBG_NIR_PREFERRED ? "tgsi-nir" : "tgsi") : "nir"), nshader); f = fopen(fname, "w"); print_shader_info(f, nshader++, &shader->shader); @@ -297,7 +297,7 @@ int r600_pipe_shader_create(struct pipe_context *ctx, tgsi_dump_to_file(sel->tokens, 0, f); } - if (rscreen->b.debug_flags & DBG_NIR){ + if (rscreen->b.debug_flags & DBG_NIR_PREFERRED){ fprintf(f, "/****NIR **********************************\n"); nir_print_shader(sel->nir, f); } diff --git a/src/gallium/drivers/r600/sfn/sfn_nir.cpp b/src/gallium/drivers/r600/sfn/sfn_nir.cpp index 082de010512..8dcd6c0b22e 100644 --- a/src/gallium/drivers/r600/sfn/sfn_nir.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_nir.cpp @@ -995,7 +995,7 @@ int r600_shader_from_nir(struct r600_context *rctx, NIR_PASS_V(sh, nir_convert_from_ssa, true); NIR_PASS_V(sh, nir_opt_dce); - if ((rctx->screen->b.debug_flags & DBG_NIR) && + if ((rctx->screen->b.debug_flags & DBG_NIR_PREFERRED) && (rctx->screen->b.debug_flags & DBG_ALL_SHADERS)) { fprintf(stderr, "-- NIR --------------------------------------------------------\n"); struct nir_function *func = (struct nir_function *)exec_list_get_head(&sh->functions);