diff options
author | Corentin Noël <corentin.noel@collabora.com> | 2022-09-21 12:14:06 +0200 |
---|---|---|
committer | Corentin Noël <corentin.noel@collabora.com> | 2023-09-14 10:43:31 +0200 |
commit | b0ffb67f6fd2e7758d0eaa3bdbaf889066faf244 (patch) | |
tree | eea66b456707f2e4147871a5786e0ccdc7a92fcc | |
parent | 8d821ed0a3803cb9b83c2ebbe8ececc7b809d2f7 (diff) |
renderer: Use tgsi_dump_with_logger to ensure complete dump
This allows to see the complete output of the TGSI shader instead of
a truncated one.
Signed-off-by: Corentin Noël <corentin.noel@collabora.com>
Part-of: <https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/934>
-rw-r--r-- | src/gallium/auxiliary/tgsi/tgsi_dump.c | 40 | ||||
-rw-r--r-- | src/gallium/auxiliary/tgsi/tgsi_dump.h | 10 | ||||
-rw-r--r-- | src/vrend_renderer.c | 16 |
3 files changed, 45 insertions, 21 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c b/src/gallium/auxiliary/tgsi/tgsi_dump.c index 29aa3b3..a8d447d 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_dump.c +++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c @@ -53,8 +53,8 @@ struct dump_ctx int indent; uint indentation; - FILE *file; tgsi_dump_callback_type logger; + void *user_data; void (*dump_printf)(struct dump_ctx *ctx, const char *format, ...); }; @@ -63,18 +63,25 @@ static void dump_ctx_printf(struct dump_ctx *ctx, const char *format, ...) { va_list ap; - (void)ctx; va_start(ap, format); if (ctx->logger) - ctx->logger(format, ap); - else if (ctx->file) - vfprintf(ctx->file, format, ap); + ctx->logger(format, ap, ctx->user_data); else _debug_vprintf(format, ap); va_end(ap); } static void +log_to_file(const char *fmt, va_list ap, void* user_data) +{ + FILE *file = user_data; + if (file) + vfprintf(file, fmt, ap); + else + _debug_vprintf(fmt, ap); +} + +static void dump_enum( struct dump_ctx *ctx, uint e, @@ -462,8 +469,8 @@ tgsi_dump_declaration( struct dump_ctx ctx; ctx.dump_printf = dump_ctx_printf; - ctx.file = NULL; ctx.logger = NULL; + ctx.user_data = NULL; iter_declaration( &ctx.iter, (struct tgsi_full_declaration *)decl ); } @@ -512,8 +519,8 @@ void tgsi_dump_property( struct dump_ctx ctx; ctx.dump_printf = dump_ctx_printf; - ctx.file = NULL; ctx.logger = NULL; + ctx.user_data = NULL; iter_property( &ctx.iter, (struct tgsi_full_property *)prop ); } @@ -546,8 +553,8 @@ tgsi_dump_immediate( struct dump_ctx ctx; ctx.dump_printf = dump_ctx_printf; - ctx.file = NULL; ctx.logger = NULL; + ctx.user_data = NULL; iter_immediate( &ctx.iter, (struct tgsi_full_immediate *)imm ); } @@ -698,8 +705,8 @@ tgsi_dump_instruction( ctx.indent = 0; ctx.dump_printf = dump_ctx_printf; ctx.indentation = 0; - ctx.file = NULL; ctx.logger = NULL; + ctx.user_data = NULL; iter_instruction( &ctx.iter, (struct tgsi_full_instruction *)inst ); } @@ -719,7 +726,8 @@ void tgsi_dump_with_logger( const struct tgsi_token *tokens, uint flags, - tgsi_dump_callback_type logger) + tgsi_dump_callback_type logger, + void *user_data) { struct dump_ctx ctx; @@ -735,8 +743,8 @@ tgsi_dump_with_logger( ctx.indent = 0; ctx.dump_printf = dump_ctx_printf; ctx.indentation = 0; - ctx.file = NULL; ctx.logger = logger; + ctx.user_data = user_data; if (flags & TGSI_DUMP_FLOAT_AS_HEX) ctx.dump_float_as_hex = TRUE; @@ -763,8 +771,8 @@ tgsi_dump_to_file(const struct tgsi_token *tokens, uint flags, FILE *file) ctx.indent = 0; ctx.dump_printf = dump_ctx_printf; ctx.indentation = 0; - ctx.file = file; - ctx.logger = NULL; + ctx.logger = log_to_file; + ctx.user_data = (void*)file; if (flags & TGSI_DUMP_FLOAT_AS_HEX) ctx.dump_float_as_hex = TRUE; @@ -834,7 +842,8 @@ tgsi_dump_str( ctx.base.indent = 0; ctx.base.dump_printf = &str_dump_ctx_printf; ctx.base.indentation = 0; - ctx.base.file = NULL; + ctx.base.logger = NULL; + ctx.base.user_data = NULL; ctx.str = str; ctx.str[0] = 0; @@ -866,7 +875,8 @@ tgsi_dump_instruction_str( ctx.base.indent = 0; ctx.base.dump_printf = &str_dump_ctx_printf; ctx.base.indentation = 0; - ctx.base.file = NULL; + ctx.base.logger = NULL; + ctx.base.user_data = NULL; ctx.str = str; ctx.str[0] = 0; diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.h b/src/gallium/auxiliary/tgsi/tgsi_dump.h index 01da78c..0a50a32 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_dump.h +++ b/src/gallium/auxiliary/tgsi/tgsi_dump.h @@ -40,7 +40,7 @@ extern "C" { #define TGSI_DUMP_FLOAT_AS_HEX (1 << 0) -typedef void (*tgsi_dump_callback_type)(const char *fmt, va_list ap); +typedef void (*tgsi_dump_callback_type)(const char *fmt, va_list ap, void *user_data); bool tgsi_dump_str( @@ -50,13 +50,17 @@ tgsi_dump_str( size_t size); void -tgsi_dump_to_file(const struct tgsi_token *tokens, uint flags, FILE *file); +tgsi_dump_to_file( + const struct tgsi_token *tokens, + uint flags, + FILE *file); void tgsi_dump_with_logger( const struct tgsi_token *tokens, uint flags, - tgsi_dump_callback_type logger ); + tgsi_dump_callback_type logger, + void *user_data ); void tgsi_dump( diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index 98391ad..8aed446 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -42,6 +42,7 @@ #include "util/u_thread.h" #include "util/u_format.h" +#include "tgsi/tgsi_dump.h" #include "tgsi/tgsi_parse.h" #include "vrend_object.h" @@ -1241,11 +1242,18 @@ vrend_so_target_reference(struct vrend_so_target **ptr, struct vrend_so_target * *ptr = target; } +static void vrend_shader_dump_to_debug(const char *fmt, va_list ap, UNUSED void *user_data) +{ + virgl_logv(VIRGL_LOG_LEVEL_DEBUG, fmt, ap); +} + static void vrend_shader_dump(struct vrend_shader *shader) { const char *prefix = pipe_shader_to_prefix(shader->sel->type); - if (shader->sel->tmp_buf) - virgl_debug("%s: %d TGSI:\n%s\n", prefix, shader->id, shader->sel->tmp_buf); + if (shader->sel->tokens) { + virgl_debug("%s: %d TGSI:\n", prefix, shader->id); + tgsi_dump_with_logger(shader->sel->tokens, 0, vrend_shader_dump_to_debug, NULL); + } virgl_debug("%s: %d GLSL:\n", prefix, shader->id); strarray_dump_with_line_numbers(&shader->glsl_strings); @@ -4223,7 +4231,9 @@ static int vrend_shader_create(struct vrend_context *ctx, if (shader->sel->tokens) { - VREND_DEBUG(dbg_shader_tgsi, ctx, "shader\n%s\n", shader->sel->tmp_buf); + VREND_DEBUG(dbg_shader_tgsi, ctx, "TGSI received:"); + VREND_DEBUG_EXT(dbg_shader_tgsi, ctx, tgsi_dump_with_logger(shader->sel->tokens, 0, vrend_shader_dump_to_debug, NULL)); + VREND_DEBUG(dbg_shader_tgsi, ctx, "\n"); bool ret = vrend_convert_shader(ctx, &ctx->shader_cfg, shader->sel->tokens, shader->sel->req_local_mem, key, &shader->sel->sinfo, |