From f2c204daf0924c636ae5b11f3c6935be12fabb81 Mon Sep 17 00:00:00 2001 From: Konstantin Seurer Date: Sun, 25 Aug 2024 14:17:24 +0200 Subject: [PATCH] nir: Add a first_line parameter to gather_debug_info MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Useful when the file contains multiple shaders. Reviewed-by: Timur Kristóf Part-of: --- src/compiler/nir/nir.h | 5 ++++- src/compiler/nir/nir_print.c | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 8acccc74d80..79a807278e1 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -5232,7 +5232,10 @@ char *nir_shader_as_str(nir_shader *nir, void *mem_ctx); char *nir_shader_as_str_annotated(nir_shader *nir, struct hash_table *annotations, void *mem_ctx); char *nir_instr_as_str(const nir_instr *instr, void *mem_ctx); -char *nir_shader_gather_debug_info(nir_shader *shader, const char *filename); +/** Adds debug information to the shader. The line numbers point to + * the corresponding lines in the printed NIR, starting first_line; + */ +char *nir_shader_gather_debug_info(nir_shader *shader, const char *filename, uint32_t first_line); /** Shallow clone of a single instruction. */ nir_instr *nir_instr_clone(nir_shader *s, const nir_instr *orig); diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c index 1758cfd0b76..08eef87b913 100644 --- a/src/compiler/nir/nir_print.c +++ b/src/compiler/nir/nir_print.c @@ -2832,7 +2832,7 @@ nir_log_shader_annotated_tagged(enum mesa_log_level level, const char *tag, } char * -nir_shader_gather_debug_info(nir_shader *shader, const char *filename) +nir_shader_gather_debug_info(nir_shader *shader, const char *filename, uint32_t first_line) { uint32_t instr_count = 0; nir_foreach_function_impl(impl, shader) { @@ -2869,7 +2869,7 @@ nir_shader_gather_debug_info(nir_shader *shader, const char *filename) char *str = _nir_shader_as_str_annotated(shader, NULL, NULL, debug_info); - uint32_t line = 1; + uint32_t line = first_line; uint32_t character_index = 0; for (uint32_t i = 0; i < instr_count; i++) {