From: Marek Olšák Date: Sun, 26 Nov 2017 02:08:59 +0000 (+0100) Subject: radeonsi: move shader debug helpers out of r600_pipe_common.c X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2208b760f338fbd9176f4375e23f0ba20a05ce96;p=mesa.git radeonsi: move shader debug helpers out of r600_pipe_common.c Reviewed-by: Nicolai Hähnle --- diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c b/src/gallium/drivers/radeon/r600_pipe_common.c index 069594f9f22..e8ee79256b7 100644 --- a/src/gallium/drivers/radeon/r600_pipe_common.c +++ b/src/gallium/drivers/radeon/r600_pipe_common.c @@ -510,17 +510,6 @@ void si_common_context_cleanup(struct r600_common_context *rctx) r600_resource_reference(&rctx->eop_bug_scratch, NULL); } -bool si_can_dump_shader(struct r600_common_screen *rscreen, - unsigned processor) -{ - return rscreen->debug_flags & (1 << processor); -} - -bool si_extra_shader_checks(struct r600_common_screen *rscreen, unsigned processor) -{ - return (rscreen->debug_flags & DBG(CHECK_IR)) || - si_can_dump_shader(rscreen, processor); -} void si_screen_clear_buffer(struct r600_common_screen *rscreen, struct pipe_resource *dst, uint64_t offset, uint64_t size, unsigned value) diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h b/src/gallium/drivers/radeon/r600_pipe_common.h index 2f8dc9065ae..dea1d6f026a 100644 --- a/src/gallium/drivers/radeon/r600_pipe_common.h +++ b/src/gallium/drivers/radeon/r600_pipe_common.h @@ -643,10 +643,6 @@ bool si_common_context_init(struct r600_common_context *rctx, struct r600_common_screen *rscreen, unsigned context_flags); void si_common_context_cleanup(struct r600_common_context *rctx); -bool si_can_dump_shader(struct r600_common_screen *rscreen, - unsigned processor); -bool si_extra_shader_checks(struct r600_common_screen *rscreen, - unsigned processor); void si_screen_clear_buffer(struct r600_common_screen *rscreen, struct pipe_resource *dst, uint64_t offset, uint64_t size, unsigned value); void si_need_dma_space(struct r600_common_context *ctx, unsigned num_dw, diff --git a/src/gallium/drivers/radeonsi/si_compute.c b/src/gallium/drivers/radeonsi/si_compute.c index dc409895602..f3dce65e3dd 100644 --- a/src/gallium/drivers/radeonsi/si_compute.c +++ b/src/gallium/drivers/radeonsi/si_compute.c @@ -178,7 +178,7 @@ static void *si_create_compute_state( bool wait = (sctx->debug.debug_message && !sctx->debug.async) || sctx->is_debug || - si_can_dump_shader(&sscreen->b, PIPE_SHADER_COMPUTE); + si_can_dump_shader(sscreen, PIPE_SHADER_COMPUTE); if (wait) { u_async_debug_init(&async_debug); diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h index 3131a8bf24b..0c16cfb71b8 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.h +++ b/src/gallium/drivers/radeonsi/si_pipe.h @@ -750,6 +750,19 @@ static inline struct si_shader* si_get_vs_state(struct si_context *sctx) return vs->current ? vs->current : NULL; } +static inline bool si_can_dump_shader(struct si_screen *sscreen, + unsigned processor) +{ + return sscreen->b.debug_flags & (1 << processor); +} + +static inline bool si_extra_shader_checks(struct si_screen *sscreen, + unsigned processor) +{ + return (sscreen->b.debug_flags & DBG(CHECK_IR)) || + si_can_dump_shader(sscreen, processor); +} + static inline bool si_get_strmout_en(struct si_context *sctx) { return sctx->streamout.streamout_enabled || diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index 0340133a8af..e942d345dbc 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -5171,7 +5171,7 @@ static void si_shader_dump_stats(struct si_screen *sscreen, max_simd_waves = MIN2(max_simd_waves, 16384 / lds_per_wave); if (!check_debug_option || - si_can_dump_shader(&sscreen->b, processor)) { + si_can_dump_shader(sscreen, processor)) { if (processor == PIPE_SHADER_FRAGMENT) { fprintf(file, "*** SHADER CONFIG ***\n" "SPI_PS_INPUT_ADDR = 0x%04x\n" @@ -5243,7 +5243,7 @@ void si_shader_dump(struct si_screen *sscreen, const struct si_shader *shader, FILE *file, bool check_debug_option) { if (!check_debug_option || - si_can_dump_shader(&sscreen->b, processor)) + si_can_dump_shader(sscreen, processor)) si_dump_shader_key(processor, shader, file); if (!check_debug_option && shader->binary.llvm_ir_string) { @@ -5260,7 +5260,7 @@ void si_shader_dump(struct si_screen *sscreen, const struct si_shader *shader, } if (!check_debug_option || - (si_can_dump_shader(&sscreen->b, processor) && + (si_can_dump_shader(sscreen, processor) && !(sscreen->b.debug_flags & DBG(NO_ASM)))) { fprintf(file, "\n%s:\n", si_get_shader_name(shader, processor)); @@ -5298,7 +5298,7 @@ static int si_compile_llvm(struct si_screen *sscreen, int r = 0; unsigned count = p_atomic_inc_return(&sscreen->b.num_compilations); - if (si_can_dump_shader(&sscreen->b, processor)) { + if (si_can_dump_shader(sscreen, processor)) { fprintf(stderr, "radeonsi: Compiling shader %d\n", count); if (!(sscreen->b.debug_flags & (DBG(NO_IR) | DBG(PREOPT_IR)))) { @@ -5498,7 +5498,7 @@ si_generate_gs_copy_shader(struct si_screen *sscreen, debug, PIPE_SHADER_GEOMETRY, "GS Copy Shader"); if (!r) { - if (si_can_dump_shader(&sscreen->b, PIPE_SHADER_GEOMETRY)) + if (si_can_dump_shader(sscreen, PIPE_SHADER_GEOMETRY)) fprintf(stderr, "GS Copy Shader:\n"); si_shader_dump(sscreen, ctx.shader, debug, PIPE_SHADER_GEOMETRY, stderr, true); @@ -6416,7 +6416,7 @@ int si_compile_tgsi_shader(struct si_screen *sscreen, /* Dump TGSI code before doing TGSI->LLVM conversion in case the * conversion fails. */ - if (si_can_dump_shader(&sscreen->b, sel->info.processor) && + if (si_can_dump_shader(sscreen, sel->info.processor) && !(sscreen->b.debug_flags & DBG(NO_TGSI))) { if (sel->tokens) tgsi_dump(sel->tokens, 0); @@ -6625,7 +6625,7 @@ int si_compile_tgsi_shader(struct si_screen *sscreen, si_optimize_vs_outputs(&ctx); if ((debug && debug->debug_message) || - si_can_dump_shader(&sscreen->b, ctx.type)) + si_can_dump_shader(sscreen, ctx.type)) si_count_scratch_private_memory(&ctx); /* Compile to bytecode. */ diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c index 59d02605e9f..9c1ea91f06e 100644 --- a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c +++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c @@ -1359,7 +1359,7 @@ void si_llvm_optimize_module(struct si_shader_context *ctx) /* Dump LLVM IR before any optimization passes */ if (ctx->screen->b.debug_flags & DBG(PREOPT_IR) && - si_can_dump_shader(&ctx->screen->b, ctx->type)) + si_can_dump_shader(ctx->screen, ctx->type)) LLVMDumpModule(ctx->gallivm.module); /* Create the pass manager */ @@ -1368,7 +1368,7 @@ void si_llvm_optimize_module(struct si_shader_context *ctx) target_library_info = gallivm_create_target_library_info(triple); LLVMAddTargetLibraryInfo(target_library_info, gallivm->passmgr); - if (si_extra_shader_checks(&ctx->screen->b, ctx->type)) + if (si_extra_shader_checks(ctx->screen, ctx->type)) LLVMAddVerifierPass(gallivm->passmgr); LLVMAddAlwaysInlinerPass(gallivm->passmgr); diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c index 513e30b6abe..53955307b4f 100644 --- a/src/gallium/drivers/radeonsi/si_state_shaders.c +++ b/src/gallium/drivers/radeonsi/si_state_shaders.c @@ -2272,7 +2272,7 @@ static void *si_create_shader_selector(struct pipe_context *ctx, bool wait = (sctx->debug.debug_message && !sctx->debug.async) || sctx->is_debug || - si_can_dump_shader(&sscreen->b, sel->info.processor); + si_can_dump_shader(sscreen, sel->info.processor); if (wait) { u_async_debug_init(&async_debug);