From e18da57276b00295e08c5e5fa7863848803e9870 Mon Sep 17 00:00:00 2001 From: Yogesh Mohan Marimuthu Date: Tue, 1 Jul 2025 09:49:11 +0530 Subject: [PATCH] radeonsi: replace fprintf stderr using mesa_log helper functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit radeonsi driver error and warnings fprintf will only use mesa_log helper functions. Reviewed-by: Erik Faye-Lund Reviewed-by: Marek Olšák Part-of: --- src/gallium/drivers/radeonsi/radeon_vcn_dec.h | 2 +- src/gallium/drivers/radeonsi/radeon_vcn_enc.h | 2 +- src/gallium/drivers/radeonsi/radeon_video.h | 6 ++- src/gallium/drivers/radeonsi/si_blit.c | 8 ++-- src/gallium/drivers/radeonsi/si_compute.c | 2 +- .../drivers/radeonsi/si_cp_reg_shadowing.c | 4 +- src/gallium/drivers/radeonsi/si_debug.c | 14 +++--- src/gallium/drivers/radeonsi/si_perfcounter.c | 4 +- src/gallium/drivers/radeonsi/si_pipe.c | 44 +++++++++---------- src/gallium/drivers/radeonsi/si_pipe.h | 6 ++- src/gallium/drivers/radeonsi/si_shader.c | 13 +++--- src/gallium/drivers/radeonsi/si_shader_llvm.c | 6 +-- .../drivers/radeonsi/si_shader_llvm_ps.c | 2 +- src/gallium/drivers/radeonsi/si_sqtt.c | 29 ++++++------ src/gallium/drivers/radeonsi/si_state.c | 6 +-- .../drivers/radeonsi/si_state_draw.cpp | 12 ++--- .../drivers/radeonsi/si_state_shaders.cpp | 13 +++--- src/gallium/drivers/radeonsi/si_texture.c | 4 +- src/gallium/drivers/radeonsi/si_vpe.c | 2 +- 19 files changed, 91 insertions(+), 88 deletions(-) diff --git a/src/gallium/drivers/radeonsi/radeon_vcn_dec.h b/src/gallium/drivers/radeonsi/radeon_vcn_dec.h index dc899e04564..bb747711dcb 100644 --- a/src/gallium/drivers/radeonsi/radeon_vcn_dec.h +++ b/src/gallium/drivers/radeonsi/radeon_vcn_dec.h @@ -20,7 +20,7 @@ #define RADEON_DEC_ERR(fmt, args...) \ do { \ dec->error = true; \ - fprintf(stderr, "EE %s:%d %s VCN - " fmt, __FILE__, __LINE__, __func__, ##args); \ + mesa_loge("%s:%d %s VCN - " fmt, __FILE__, __LINE__, __func__, ##args); \ } while(0) struct rvcn_dec_dynamic_dpb_t2 { diff --git a/src/gallium/drivers/radeonsi/radeon_vcn_enc.h b/src/gallium/drivers/radeonsi/radeon_vcn_enc.h index ba262c33f9b..31e7331f55c 100644 --- a/src/gallium/drivers/radeonsi/radeon_vcn_enc.h +++ b/src/gallium/drivers/radeonsi/radeon_vcn_enc.h @@ -53,7 +53,7 @@ #define RADEON_ENC_ERR(fmt, args...) \ do { \ enc->error = true; \ - fprintf(stderr, "EE %s:%d %s VCN - " fmt, __FILE__, __LINE__, __func__, ##args); \ + mesa_loge("%s:%d %s VCN - " fmt, __FILE__, __LINE__, __func__, ##args); \ } while(0) typedef void (*radeon_enc_get_buffer)(struct pipe_resource *resource, struct pb_buffer_lean **handle, diff --git a/src/gallium/drivers/radeonsi/radeon_video.h b/src/gallium/drivers/radeonsi/radeon_video.h index 4093ae58baa..f470e3644b6 100644 --- a/src/gallium/drivers/radeonsi/radeon_video.h +++ b/src/gallium/drivers/radeonsi/radeon_video.h @@ -11,9 +11,13 @@ #include "winsys/radeon_winsys.h" #include "vl/vl_video_buffer.h" +#include "util/log.h" + +#undef MESA_LOG_TAG +#define MESA_LOG_TAG "radeonsi" #define RVID_ERR(fmt, args...) \ - fprintf(stderr, "EE %s:%d %s UVD - " fmt, __FILE__, __LINE__, __func__, ##args) + mesa_loge("%s:%d %s UVD - " fmt, __FILE__, __LINE__, __func__, ##args) #define UVD_FW_1_66_16 ((1 << 24) | (66 << 16) | (16 << 8)) diff --git a/src/gallium/drivers/radeonsi/si_blit.c b/src/gallium/drivers/radeonsi/si_blit.c index 76fe2805099..4c190e548c1 100644 --- a/src/gallium/drivers/radeonsi/si_blit.c +++ b/src/gallium/drivers/radeonsi/si_blit.c @@ -987,8 +987,8 @@ void si_gfx_copy_image(struct si_context *sctx, struct pipe_resource *dst, /* If the blitter isn't available fail here instead of crashing. */ if (!sctx->blitter) { - fprintf(stderr, "si_resource_copy_region failed src_format: %s dst_format: %s\n", - util_format_name(src->format), util_format_name(dst->format)); + mesa_loge("si_resource_copy_region failed src_format: %s dst_format: %s", + util_format_name(src->format), util_format_name(dst->format)); return; } @@ -1028,8 +1028,8 @@ void si_gfx_copy_image(struct si_context *sctx, struct pipe_resource *dst, dst_templ.format = src_templ.format = PIPE_FORMAT_R32G32B32A32_UINT; break; default: - fprintf(stderr, "Unhandled format %s with blocksize %u\n", - util_format_short_name(src->format), ssrc->surface.bpe); + mesa_loge("Unhandled format %s with blocksize %u", + util_format_short_name(src->format), ssrc->surface.bpe); assert(0); } } diff --git a/src/gallium/drivers/radeonsi/si_compute.c b/src/gallium/drivers/radeonsi/si_compute.c index 35b683dd098..734971f5942 100644 --- a/src/gallium/drivers/radeonsi/si_compute.c +++ b/src/gallium/drivers/radeonsi/si_compute.c @@ -263,7 +263,7 @@ static void si_set_global_binding(struct pipe_context *ctx, unsigned first, unsi sctx->global_buffers = realloc( sctx->global_buffers, sctx->max_global_buffers * sizeof(sctx->global_buffers[0])); if (!sctx->global_buffers) { - fprintf(stderr, "radeonsi: failed to allocate compute global_buffers\n"); + mesa_loge("failed to allocate compute global_buffers"); return; } diff --git a/src/gallium/drivers/radeonsi/si_cp_reg_shadowing.c b/src/gallium/drivers/radeonsi/si_cp_reg_shadowing.c index c9e0bbe49be..c731e4594ef 100644 --- a/src/gallium/drivers/radeonsi/si_cp_reg_shadowing.c +++ b/src/gallium/drivers/radeonsi/si_cp_reg_shadowing.c @@ -27,7 +27,7 @@ void si_init_cp_reg_shadowing(struct si_context *sctx) sctx->screen->info.fw_based_mcbp.csa_size, sctx->screen->info.fw_based_mcbp.csa_alignment); if (!sctx->shadowing.registers || !sctx->shadowing.csa) - fprintf(stderr, "radeonsi: cannot create register shadowing buffer(s)\n"); + mesa_loge("cannot create register shadowing buffer(s)"); else sctx->ws->cs_set_mcbp_reg_shadowing_va(&sctx->gfx_cs, sctx->shadowing.registers->gpu_address, @@ -40,7 +40,7 @@ void si_init_cp_reg_shadowing(struct si_context *sctx) SI_SHADOWED_REG_BUFFER_SIZE, 4096); if (!sctx->shadowing.registers) - fprintf(stderr, "radeonsi: cannot create a shadowed_regs buffer\n"); + mesa_loge("cannot create a shadowed_regs buffer"); } } diff --git a/src/gallium/drivers/radeonsi/si_debug.c b/src/gallium/drivers/radeonsi/si_debug.c index 640c2ccc8f9..37abdb17476 100644 --- a/src/gallium/drivers/radeonsi/si_debug.c +++ b/src/gallium/drivers/radeonsi/si_debug.c @@ -64,7 +64,7 @@ void si_save_cs(struct radeon_winsys *ws, struct radeon_cmdbuf *cs, struct radeo return; oom: - fprintf(stderr, "%s: out of memory\n", __func__); + mesa_loge("%s: out of memory", __func__); memset(saved, 0, sizeof(*saved)); } @@ -199,7 +199,7 @@ bool si_replace_shader(unsigned num, struct si_shader_binary *binary) p = endp; if (*p != ':') { - fprintf(stderr, "RADEON_REPLACE_SHADERS formatted badly.\n"); + mesa_loge("RADEON_REPLACE_SHADERS formatted badly."); exit(1); } ++p; @@ -219,12 +219,12 @@ bool si_replace_shader(unsigned num, struct si_shader_binary *binary) if (semicolon) { p = copy = strndup(p, semicolon - p); if (!copy) { - fprintf(stderr, "out of memory\n"); + mesa_loge("out of memory"); return false; } } - fprintf(stderr, "radeonsi: replace shader %u by %s\n", num, p); + mesa_logi("replace shader %u by %s", num, p); f = fopen(p, "r"); if (!f) { @@ -244,7 +244,7 @@ bool si_replace_shader(unsigned num, struct si_shader_binary *binary) binary->code_buffer = MALLOC(filesize); if (!binary->code_buffer) { - fprintf(stderr, "out of memory\n"); + mesa_loge("out of memory"); goto out_close; } @@ -496,7 +496,7 @@ void si_log_hw_flush(struct si_context *sctx) */ FILE *f = dd_get_debug_file(false); if (!f) { - fprintf(stderr, "radeonsi: error opening aux context dump file.\n"); + mesa_loge("error opening aux context dump file."); } else { dd_write_header(f, &sctx->screen->b, 0); @@ -1114,7 +1114,7 @@ void si_check_vm_faults(struct si_context *sctx, struct radeon_saved_cs *saved) fclose(f); - fprintf(stderr, "Detected a VM fault, exiting...\n"); + mesa_loge("Detected a VM fault, exiting..."); exit(0); } diff --git a/src/gallium/drivers/radeonsi/si_perfcounter.c b/src/gallium/drivers/radeonsi/si_perfcounter.c index 1ffdb8b98ac..bd1230631d8 100644 --- a/src/gallium/drivers/radeonsi/si_perfcounter.c +++ b/src/gallium/drivers/radeonsi/si_perfcounter.c @@ -493,7 +493,7 @@ static struct si_query_group *get_group_state(struct si_screen *screen, struct s query_shaders = query->shaders & ~AC_PC_SHADERS_WINDOWING; if (query_shaders && query_shaders != shaders) { - fprintf(stderr, "si_perfcounter: incompatible shader groups\n"); + mesa_loge("si_perfcounter: incompatible shader groups"); FREE(group); return NULL; } @@ -567,7 +567,7 @@ struct pipe_query *si_create_batch_query(struct pipe_context *ctx, unsigned num_ goto error; if (group->num_counters >= block->b->b->num_counters) { - fprintf(stderr, "perfcounter group %s: too many selected\n", block->b->b->name); + mesa_loge("perfcounter group %s: too many selected", block->b->b->name); goto error; } group->selectors[group->num_counters] = sub_index; diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index e324af79b9f..956bdc1a2b8 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -499,7 +499,7 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, unsign /* Don't create a context if it's not compute-only and hw is compute-only. */ if (!sscreen->info.has_graphics && !(flags & PIPE_CONTEXT_COMPUTE_ONLY)) { - mesa_loge("radeonsi: can't create a graphics context on a compute chip\n"); + mesa_loge("can't create a graphics context on a compute chip"); return NULL; } @@ -508,7 +508,7 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, unsign int shader, i; if (!sctx) { - mesa_loge("radeonsi: can't allocate a context\n"); + mesa_loge("can't allocate a context"); return NULL; } @@ -544,7 +544,7 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, unsign &sscreen->b, PIPE_RESOURCE_FLAG_UNMAPPABLE | SI_RESOURCE_FLAG_DRIVER_INTERNAL, PIPE_USAGE_DEFAULT, 16 * sscreen->info.max_render_backends, 256); if (!sctx->eop_bug_scratch) { - mesa_loge("radeonsi: can't create eop_bug_scratch\n"); + mesa_loge("can't create eop_bug_scratch"); goto fail; } } @@ -552,13 +552,13 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, unsign /* Initialize the context handle and the command stream. */ sctx->ctx = sctx->ws->ctx_create(sctx->ws, sctx->context_flags); if (!sctx->ctx) { - mesa_loge("radeonsi: can't create radeon_winsys_ctx\n"); + mesa_loge("can't create radeon_winsys_ctx"); goto fail; } if (!ws->cs_create(&sctx->gfx_cs, sctx->ctx, sctx->has_graphics ? AMD_IP_GFX : AMD_IP_COMPUTE, (void *)si_flush_gfx_cs, sctx)) { - mesa_loge("radeonsi: can't create gfx_cs\n"); + mesa_loge("can't create gfx_cs"); sctx->gfx_cs.priv = NULL; goto fail; } @@ -571,7 +571,7 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, unsign sctx->cached_gtt_allocator = u_upload_create(&sctx->b, 16 * 1024, 0, PIPE_USAGE_STAGING, 0); if (!sctx->cached_gtt_allocator) { - mesa_loge("radeonsi: can't create cached_gtt_allocator\n"); + mesa_loge("can't create cached_gtt_allocator"); goto fail; } @@ -586,7 +586,7 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, unsign : PIPE_USAGE_STREAM, SI_RESOURCE_FLAG_32BIT); /* same flags as const_uploader */ if (!sctx->b.stream_uploader) { - mesa_loge("radeonsi: can't create stream_uploader\n"); + mesa_loge("can't create stream_uploader"); goto fail; } @@ -597,7 +597,7 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, unsign u_upload_create(&sctx->b, 256 * 1024, 0, PIPE_USAGE_DEFAULT, SI_RESOURCE_FLAG_32BIT); if (!sctx->b.const_uploader) { - mesa_loge("radeonsi: can't create const_uploader\n"); + mesa_loge("can't create const_uploader"); goto fail; } } @@ -606,21 +606,21 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, unsign if (sscreen->info.has_3d_cube_border_color_mipmap) { sctx->border_color_table = malloc(SI_MAX_BORDER_COLORS * sizeof(*sctx->border_color_table)); if (!sctx->border_color_table) { - mesa_loge("radeonsi: can't create border_color_table\n"); + mesa_loge("can't create border_color_table"); goto fail; } sctx->border_color_buffer = si_resource(pipe_buffer_create( screen, 0, PIPE_USAGE_DEFAULT, SI_MAX_BORDER_COLORS * sizeof(*sctx->border_color_table))); if (!sctx->border_color_buffer) { - mesa_loge("radeonsi: can't create border_color_buffer\n"); + mesa_loge("can't create border_color_buffer"); goto fail; } sctx->border_color_map = ws->buffer_map(ws, sctx->border_color_buffer->buf, NULL, PIPE_MAP_WRITE); if (!sctx->border_color_map) { - mesa_loge("radeonsi: can't map border_color_buffer\n"); + mesa_loge("can't map border_color_buffer"); goto fail; } } @@ -668,7 +668,7 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, unsign sctx->blitter = util_blitter_create(&sctx->b); if (sctx->blitter == NULL) { - mesa_loge("radeonsi: can't create blitter\n"); + mesa_loge("can't create blitter"); goto fail; } sctx->blitter->skip_viewport_restore = true; @@ -744,7 +744,7 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, unsign PIPE_USAGE_DEFAULT, 16, sctx->screen->info.tcc_cache_line_size); if (!sctx->null_const_buf.buffer) { - mesa_loge("radeonsi: can't create null_const_buf\n"); + mesa_loge("can't create null_const_buf"); goto fail; } sctx->null_const_buf.buffer_size = sctx->null_const_buf.buffer->width0; @@ -774,7 +774,7 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, unsign sctx->dirty_implicit_resources = _mesa_pointer_hash_table_create(NULL); if (!sctx->dirty_implicit_resources) { - mesa_loge("radeonsi: can't create dirty_implicit_resources\n"); + mesa_loge("can't create dirty_implicit_resources"); goto fail; } @@ -808,7 +808,7 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, unsign PIPE_USAGE_DEFAULT, 4, sscreen->info.tcc_cache_line_size); if (!sctx->wait_mem_scratch) { - mesa_loge("radeonsi: can't create wait_mem_scratch\n"); + mesa_loge("can't create wait_mem_scratch"); goto fail; } @@ -882,7 +882,7 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, unsign return &sctx->b; fail: - mesa_loge("radeonsi: Failed to create a context.\n"); + mesa_loge("Failed to create a context."); si_destroy_context(&sctx->b); return NULL; } @@ -938,10 +938,10 @@ static struct pipe_context *si_pipe_create_context(struct pipe_screen *screen, v sscreen->ws->cs_set_pstate(&((struct si_context *)ctx)->gfx_cs, RADEON_CTX_PSTATE_PEAK); if (ac_check_profile_state(&sscreen->info)) { - fprintf(stderr, "radeonsi: Canceling RGP trace request as a hang condition has been " - "detected. Force the GPU into a profiling mode with e.g. " - "\"echo profile_peak > " - "/sys/class/drm/card0/device/power_dpm_force_performance_level\"\n"); + mesa_loge("Canceling RGP trace request as a hang condition has been " + "detected. Force the GPU into a profiling mode with e.g. " + "\"echo profile_peak > " + "/sys/class/drm/card0/device/power_dpm_force_performance_level\""); } else if (!si_init_sqtt((struct si_context *)ctx)) { FREE(ctx); return NULL; @@ -1227,7 +1227,7 @@ static void si_setup_force_shader_use_aco(struct si_screen *sscreen, bool suppor FILE *f = fopen(option, "r"); if (!f) { - fprintf(stderr, "radeonsi: invalid AMD_FORCE_SHADER_USE_ACO value\n"); + mesa_loge("invalid AMD_FORCE_SHADER_USE_ACO value"); return; } @@ -1315,7 +1315,7 @@ static struct pipe_screen *radeonsi_screen_create_impl(struct radeon_winsys *ws, #endif if (sscreen->use_aco && !support_aco) { - fprintf(stderr, "radeonsi: ACO does not support this chip yet\n"); + mesa_loge("ACO does not support this chip yet"); FREE(sscreen); return NULL; } diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h index 67e9d350528..2ca65bb2101 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.h +++ b/src/gallium/drivers/radeonsi/si_pipe.h @@ -17,6 +17,7 @@ #include "util/u_threaded_context.h" #include "util/u_vertex_state_cache.h" #include "util/perf/u_trace.h" +#include "util/log.h" #include "ac_descriptors.h" #include "ac_sqtt.h" #include "ac_spm.h" @@ -26,6 +27,9 @@ extern "C" { #endif +#undef MESA_LOG_TAG +#define MESA_LOG_TAG "radeonsi" + struct ac_llvm_compiler; #define SHADER_DEBUG_LOG 0 @@ -2248,7 +2252,7 @@ static inline bool si_vs_uses_vbos(struct si_shader_selector *sel) } #define PRINT_ERR(fmt, args...) \ - fprintf(stderr, "EE %s:%d %s - " fmt, __FILE__, __LINE__, __func__, ##args) + mesa_loge("%s:%d %s - " fmt, __FILE__, __LINE__, __func__, ##args) #ifdef __cplusplus } diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index 4bf5a23aee0..97ce245ccc9 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -2009,7 +2009,7 @@ bool si_compile_shader(struct si_screen *sscreen, struct ac_llvm_compiler *compi si_nir_generate_gs_copy_shader(sscreen, compiler, shader, nir, linked.consumer.gs_copy_shader, debug); if (!shader->gs_copy_shader) { - fprintf(stderr, "radeonsi: can't create GS copy shader\n"); + mesa_loge("can't create GS copy shader"); ret = false; goto out; } @@ -2065,10 +2065,9 @@ bool si_compile_shader(struct si_screen *sscreen, struct ac_llvm_compiler *compi max_sgprs = MIN2(max_sgprs / waves_per_simd, max_sgprs_per_wave); if (shader->config.num_sgprs > max_sgprs || shader->config.num_vgprs > max_vgprs) { - fprintf(stderr, - "LLVM failed to compile a shader correctly: " - "SGPR:VGPR usage is %u:%u, but the hw limit is %u:%u\n", - shader->config.num_sgprs, shader->config.num_vgprs, max_sgprs, max_vgprs); + mesa_loge("LLVM failed to compile a shader correctly: " + "SGPR:VGPR usage is %u:%u, but the hw limit is %u:%u", + shader->config.num_sgprs, shader->config.num_vgprs, max_sgprs, max_vgprs); /* Just terminate the process, because dependent * shaders can hang due to bad input data, but use @@ -2587,7 +2586,7 @@ bool si_create_shader_variant(struct si_screen *sscreen, struct ac_llvm_compiler if (sel->stage <= MESA_SHADER_GEOMETRY && shader->key.ge.as_ngg) { assert(!shader->key.ge.as_es && !shader->key.ge.as_ls); if (!gfx10_ngg_calculate_subgroup_info(shader)) { - fprintf(stderr, "Failed to compute subgroup info\n"); + mesa_loge("Failed to compute subgroup info"); return false; } } else if (sscreen->info.gfx_level >= GFX9 && sel->stage == MESA_SHADER_GEOMETRY) { @@ -2608,7 +2607,7 @@ bool si_create_shader_variant(struct si_screen *sscreen, struct ac_llvm_compiler si_shader_dump(sscreen, shader, debug, stderr, true); if (!ok) - fprintf(stderr, "LLVM failed to upload shader\n"); + mesa_loge("LLVM failed to upload shader"); return ok; } diff --git a/src/gallium/drivers/radeonsi/si_shader_llvm.c b/src/gallium/drivers/radeonsi/si_shader_llvm.c index 500eb368f5e..e601c841f2b 100644 --- a/src/gallium/drivers/radeonsi/si_shader_llvm.c +++ b/src/gallium/drivers/radeonsi/si_shader_llvm.c @@ -47,7 +47,7 @@ static void si_diagnostic_handler(LLVMDiagnosticInfoRef di, void *context) if (severity == LLVMDSError) { diag->retval = 1; - fprintf(stderr, "LLVM triggered Diagnostic Handler: %s\n", description); + mesa_loge("LLVM triggered Diagnostic Handler: %s", description); } LLVMDisposeMessage(description); @@ -693,7 +693,7 @@ static void assert_registers_equal(struct si_screen *sscreen, unsigned reg, unsi unsigned llvm_value, bool allow_zero) { if (nir_value != llvm_value) { - fprintf(stderr, "Error: Unexpected non-matching shader config:\n"); + mesa_loge("Unexpected non-matching shader config:"); fprintf(stderr, "From NIR:\n"); ac_dump_reg(stderr, sscreen->info.gfx_level, sscreen->info.family, reg, nir_value, ~0); fprintf(stderr, "From LLVM:\n"); @@ -771,7 +771,7 @@ bool si_llvm_compile_shader(struct si_screen *sscreen, struct ac_llvm_compiler * nir->info.stage, si_get_shader_name(shader)); si_llvm_dispose(&ctx); if (!success) { - fprintf(stderr, "LLVM failed to compile shader\n"); + mesa_loge("LLVM failed to compile shader"); return false; } diff --git a/src/gallium/drivers/radeonsi/si_shader_llvm_ps.c b/src/gallium/drivers/radeonsi/si_shader_llvm_ps.c index 7ca9aa7ff6c..030f4332731 100644 --- a/src/gallium/drivers/radeonsi/si_shader_llvm_ps.c +++ b/src/gallium/drivers/radeonsi/si_shader_llvm_ps.c @@ -388,7 +388,7 @@ void si_llvm_ps_build_end(struct si_shader_context *ctx) color[index][j] = result; } } else { - fprintf(stderr, "Warning: Unhandled fs output type:%d\n", semantic); + mesa_logw("Unhandled fs output type:%d", semantic); } break; } diff --git a/src/gallium/drivers/radeonsi/si_sqtt.c b/src/gallium/drivers/radeonsi/si_sqtt.c index e1fe2c21ac4..3a7fa7955ef 100644 --- a/src/gallium/drivers/radeonsi/si_sqtt.c +++ b/src/gallium/drivers/radeonsi/si_sqtt.c @@ -268,10 +268,9 @@ si_sqtt_resize_bo(struct si_context *sctx) /* Double the size of the thread trace buffer per SE. */ sctx->sqtt->buffer_size *= 2; - fprintf(stderr, - "Failed to get the thread trace because the buffer " - "was too small, resizing to %d KB\n", - sctx->sqtt->buffer_size / 1024); + mesa_loge("Failed to get the thread trace because the buffer " + "was too small, resizing to %d KB", + sctx->sqtt->buffer_size / 1024); /* Re-create the thread trace BO. */ return si_sqtt_init_bo(sctx); @@ -290,7 +289,7 @@ static bool si_get_sqtt_trace(struct si_context *sctx, if (!ac_sqtt_get_trace(sctx->sqtt, &sctx->screen->info, sqtt)) { if (!si_sqtt_resize_bo(sctx)) { - fprintf(stderr, "radeonsi: Failed to resize the SQTT buffer.\n"); + mesa_loge("Failed to resize the SQTT buffer."); } else { for (int i = 0; i < ARRAY_SIZE(sctx->sqtt->start_cs); i++) { sctx->screen->ws->cs_destroy(sctx->sqtt->start_cs[i]); @@ -307,24 +306,22 @@ bool si_init_sqtt(struct si_context *sctx) { static bool warn_once = true; if (warn_once) { - fprintf(stderr, "*************************************************\n"); - fprintf(stderr, "* WARNING: Thread trace support is experimental *\n"); - fprintf(stderr, "*************************************************\n"); + mesa_logw("Thread trace support is experimental *"); warn_once = false; } sctx->sqtt = CALLOC_STRUCT(ac_sqtt); if (sctx->gfx_level < GFX8) { - fprintf(stderr, "GPU hardware not supported: refer to " - "the RGP documentation for the list of " - "supported GPUs!\n"); + mesa_loge("GPU hardware not supported: refer to " + "the RGP documentation for the list of " + "supported GPUs!"); return false; } if (sctx->gfx_level > GFX12) { - fprintf(stderr, "radeonsi: Thread trace is not supported " - "for that GPU!\n"); + mesa_loge("Thread trace is not supported " + "for that GPU!"); return false; } @@ -445,8 +442,8 @@ void si_handle_sqtt(struct si_context *sctx, struct radeon_cmdbuf *rcs) /* Do not enable tracing if we cannot remove the file, * because by then we'll trace every frame. */ - fprintf(stderr, "radeonsi: could not remove thread " - "trace trigger file, ignoring\n"); + mesa_logw("could not remove thread " + "trace trigger file, ignoring"); } } @@ -494,7 +491,7 @@ void si_handle_sqtt(struct si_context *sctx, struct radeon_cmdbuf *rcs) if (sctx->spm.ptr) sctx->ws->buffer_unmap(sctx->ws, sctx->spm.bo); } else { - fprintf(stderr, "Failed to read the trace\n"); + mesa_loge("Failed to read the trace"); if (!sctx->sqtt->trigger_file) { sctx->sqtt->start_frame = num_frames + 10; } diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c index 6b5138f03e5..2d655d7ef98 100644 --- a/src/gallium/drivers/radeonsi/si_state.c +++ b/src/gallium/drivers/radeonsi/si_state.c @@ -4191,9 +4191,9 @@ static uint32_t si_translate_border_color(struct si_context *sctx, /* Getting 4096 unique border colors is very unlikely. */ static bool printed; if (!printed) { - fprintf(stderr, "radeonsi: The border color table is full. " - "Any new border colors will be just black. " - "This is a hardware limitation.\n"); + mesa_loge("The border color table is full. " + "Any new border colors will be just black. " + "This is a hardware limitation."); printed = true; } return V_008F3C_SQ_TEX_BORDER_COLOR_TRANS_BLACK; diff --git a/src/gallium/drivers/radeonsi/si_state_draw.cpp b/src/gallium/drivers/radeonsi/si_state_draw.cpp index 07b0171cb95..ce71fa368c4 100644 --- a/src/gallium/drivers/radeonsi/si_state_draw.cpp +++ b/src/gallium/drivers/radeonsi/si_state_draw.cpp @@ -2128,19 +2128,19 @@ static void si_draw(struct pipe_context *ctx, num_vertex_elements < vs->info.num_vs_inputs) { #ifndef NDEBUG if (!vs) - fprintf(stderr, "radeonsi: draw: missing vertex shader\n"); + mesa_loge("draw: missing vertex shader"); if (!sctx->shader.ps.cso) - fprintf(stderr, "radeonsi: draw: missing fragment shader\n"); + mesa_loge("draw: missing fragment shader"); if (HAS_TESS != (info->mode == MESA_PRIM_PATCHES)) { - fprintf(stderr, HAS_TESS ? "radeonsi: draw: invalid primitive type (expected PATCHES)\n" - : "radeonsi: draw: invalid primitive type (not expected PATCHES)\n"); + mesa_loge(HAS_TESS ? "draw: invalid primitive type (expected PATCHES)" + : "draw: invalid primitive type (not expected PATCHES)"); } if (num_vertex_elements < vs->info.num_vs_inputs) { - fprintf(stderr, "radeonsi: draw: not enough vertex elements for a vertex shader " - "(has: %u, need: %u)\n", num_vertex_elements, vs->info.num_vs_inputs); + mesa_loge("draw: not enough vertex elements for a vertex shader " + "(has: %u, need: %u)", num_vertex_elements, vs->info.num_vs_inputs); } #endif assert(0); diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.cpp b/src/gallium/drivers/radeonsi/si_state_shaders.cpp index ac6edd6c85a..52452c89695 100644 --- a/src/gallium/drivers/radeonsi/si_state_shaders.cpp +++ b/src/gallium/drivers/radeonsi/si_state_shaders.cpp @@ -294,7 +294,7 @@ static bool si_load_shader_binary(struct si_shader *shader, void *binary) uint32_t *ptr = (uint32_t *)binary + sizeof(*head) / 4; if (util_hash_crc32(ptr, head->size - sizeof(*head)) != head->crc32) { - fprintf(stderr, "radeonsi: binary shader has invalid CRC32\n"); + mesa_loge("binary shader has invalid CRC32"); return false; } @@ -3334,7 +3334,7 @@ static void si_init_shader_selector_async(void *job, void *gdata, int thread_ind unsigned char ir_sha1_cache_key[20]; if (!shader) { - fprintf(stderr, "radeonsi: can't allocate a main shader part\n"); + mesa_loge("can't allocate a main shader part"); return; } @@ -3376,11 +3376,10 @@ static void si_init_shader_selector_async(void *job, void *gdata, int thread_ind /* Compile the shader if it hasn't been loaded from the cache. */ if (!si_compile_shader(sscreen, *compiler, shader, debug)) { - fprintf(stderr, - "radeonsi: can't compile a main shader part (type: %s).\n" - "This is probably a driver bug, please report " - "it to https://gitlab.freedesktop.org/mesa/mesa/-/issues.\n", - gl_shader_stage_name(shader->selector->stage)); + mesa_loge("can't compile a main shader part (type: %s).\n" + "This is probably a driver bug, please report " + "it to https://gitlab.freedesktop.org/mesa/mesa/-/issues.", + gl_shader_stage_name(shader->selector->stage)); FREE(shader); return; } diff --git a/src/gallium/drivers/radeonsi/si_texture.c b/src/gallium/drivers/radeonsi/si_texture.c index b8abc3975a8..c7bd962e8c9 100644 --- a/src/gallium/drivers/radeonsi/si_texture.c +++ b/src/gallium/drivers/radeonsi/si_texture.c @@ -1744,8 +1744,8 @@ static struct pipe_resource *si_texture_from_winsys_buffer(struct si_screen *ssc modifier == DRM_FORMAT_MOD_INVALID && md_version >= 3 && md_flags & (1u << AC_SURF_METADATA_FLAG_FAMILY_OVERRIDEN_BIT)) { - fprintf(stderr, "si_texture_from_winsys_buffer: fail texture import due to " - "AC_SURF_METADATA_FLAG_FAMILY_OVERRIDEN_BIT being set.\n"); + mesa_loge("si_texture_from_winsys_buffer: fail texture import due to " + "AC_SURF_METADATA_FLAG_FAMILY_OVERRIDEN_BIT being set."); return NULL; } } else { diff --git a/src/gallium/drivers/radeonsi/si_vpe.c b/src/gallium/drivers/radeonsi/si_vpe.c index 9118c27afbb..04aa11c789c 100644 --- a/src/gallium/drivers/radeonsi/si_vpe.c +++ b/src/gallium/drivers/radeonsi/si_vpe.c @@ -56,7 +56,7 @@ } #define SIVPE_ERR(fmt, args...) \ - fprintf(stderr, "SIVPE ERROR %s:%d %s " fmt, __FILE__, __LINE__, __func__, ##args) + mesa_loge("SIVPE: %s:%d %s " fmt, __FILE__, __LINE__, __func__, ##args) #define SIVPE_PRINT(fmt, args...) \ printf("SIVPE %s: " fmt, __func__, ##args);