From 844f33025eb4e3a188c5faaf0bca9dc87f065f2b Mon Sep 17 00:00:00 2001 From: Francisco Casas Date: Fri, 4 Jul 2025 01:55:23 -0400 Subject: [PATCH] vkd3d-shader/hlsl: Dump processed function bodies. --- libs/vkd3d-shader/hlsl.c | 9 ++++++--- libs/vkd3d-shader/hlsl.h | 3 ++- libs/vkd3d-shader/hlsl_codegen.c | 7 ++++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index 678ed3249..41cbc0aa8 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -4066,20 +4066,23 @@ static void dump_instr(struct hlsl_ctx *ctx, struct vkd3d_string_buffer *buffer, } } -void hlsl_dump_function(struct hlsl_ctx *ctx, const struct hlsl_ir_function_decl *func) +void hlsl_dump_function(struct hlsl_ctx *ctx, const struct hlsl_ir_function_decl *func, + const char *description, const struct hlsl_block *processed_block) { struct vkd3d_string_buffer buffer; size_t i; vkd3d_string_buffer_init(&buffer); - vkd3d_string_buffer_printf(&buffer, "Dumping function %s.\n", func->func->name); + vkd3d_string_buffer_printf(&buffer, "Dumping %s \"%s\".\n", description, func->func->name); vkd3d_string_buffer_printf(&buffer, "Function parameters:\n"); for (i = 0; i < func->parameters.count; ++i) { dump_ir_var(ctx, &buffer, func->parameters.vars[i]); vkd3d_string_buffer_printf(&buffer, "\n"); } - if (func->has_body) + if (processed_block) + dump_block(ctx, &buffer, processed_block); + else if (func->has_body) dump_block(ctx, &buffer, &func->body); vkd3d_string_buffer_trace(&buffer); diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 7c13a810b..7a4c23b1f 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -1615,7 +1615,8 @@ struct hlsl_ir_node *hlsl_block_add_unary_expr(struct hlsl_ctx *ctx, struct hlsl void hlsl_block_cleanup(struct hlsl_block *block); bool hlsl_clone_block(struct hlsl_ctx *ctx, struct hlsl_block *dst_block, const struct hlsl_block *src_block); -void hlsl_dump_function(struct hlsl_ctx *ctx, const struct hlsl_ir_function_decl *func); +void hlsl_dump_function(struct hlsl_ctx *ctx, const struct hlsl_ir_function_decl *func, + const char *description, const struct hlsl_block *processed_block); void hlsl_dump_ir_function_decl(struct hlsl_ctx *ctx, struct vkd3d_string_buffer *buffer, const struct hlsl_ir_function_decl *f); void hlsl_dump_var_default_values(const struct hlsl_ir_var *var); diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 050cf13a1..496be3dac 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -5294,7 +5294,7 @@ static void dump_function(struct rb_entry *entry, void *context) LIST_FOR_EACH_ENTRY(decl, &func->overloads, struct hlsl_ir_function_decl, entry) { if (decl->has_body) - hlsl_dump_function(ctx, decl); + hlsl_dump_function(ctx, decl, "function", NULL); } } @@ -13957,7 +13957,12 @@ int hlsl_emit_bytecode(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry } if (TRACE_ON()) + { rb_for_each_entry(&ctx->functions, dump_function, ctx); + hlsl_dump_function(ctx, entry_func, "processed entry point", &body); + if (profile->type == VKD3D_SHADER_TYPE_HULL) + hlsl_dump_function(ctx, ctx->patch_constant_func, "processed patch-constant function", &patch_body); + } if (ctx->result) return ctx->result;