From c332adaa68fe7969c4cb2f5898c69e46e2ad814a Mon Sep 17 00:00:00 2001 From: Giovanni Mascellani Date: Tue, 8 Oct 2024 16:54:08 +0200 Subject: [PATCH] vkd3d-shader/d3d-asm: Dump signatures when tracing a VSIR program. --- libs/vkd3d-shader/d3d_asm.c | 45 +++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/libs/vkd3d-shader/d3d_asm.c b/libs/vkd3d-shader/d3d_asm.c index f0b7a099..38d566d9 100644 --- a/libs/vkd3d-shader/d3d_asm.c +++ b/libs/vkd3d-shader/d3d_asm.c @@ -2499,12 +2499,57 @@ enum vkd3d_result d3d_asm_compile(const struct vsir_program *program, return result; } +/* This is meant exclusively for development use. Therefore, differently from + * dump_dxbc_signature(), it doesn't try particularly hard to make the output + * nice or easily parsable, and it dumps all fields, not just the DXBC ones. + * This format isn't meant to be stable. */ +static void trace_signature(const struct shader_signature *signature, const char *signature_type) +{ + struct vkd3d_string_buffer buffer; + unsigned int i; + + TRACE("%s signature:%s\n", signature_type, signature->element_count == 0 ? " empty" : ""); + + vkd3d_string_buffer_init(&buffer); + + for (i = 0; i < signature->element_count; ++i) + { + const struct signature_element *element = &signature->elements[i]; + + vkd3d_string_buffer_clear(&buffer); + + vkd3d_string_buffer_printf(&buffer, "Element %u: %s %u-%u %s", i, + get_component_type_name(element->component_type), + element->register_index, element->register_index + element->register_count, + element->semantic_name); + if (element->semantic_index != -1) + vkd3d_string_buffer_printf(&buffer, "%u", element->semantic_index); + vkd3d_string_buffer_printf(&buffer, + " mask %#x used_mask %#x sysval %s min_precision %s interpolation %u stream %u", + element->mask, element->used_mask, get_sysval_semantic_name(element->sysval_semantic), + get_minimum_precision_name(element->min_precision), element->interpolation_mode, + element->stream_index); + if (element->target_location != -1) + vkd3d_string_buffer_printf(&buffer, " target %u", element->target_location); + else + vkd3d_string_buffer_printf(&buffer, " unused"); + + TRACE("%s\n", buffer.buffer); + } + + vkd3d_string_buffer_cleanup(&buffer); +} + void vsir_program_trace(const struct vsir_program *program) { const unsigned int flags = VSIR_ASM_FLAG_DUMP_TYPES | VSIR_ASM_FLAG_DUMP_ALL_INDICES; struct vkd3d_shader_code code; const char *p, *q, *end; + trace_signature(&program->input_signature, "Input"); + trace_signature(&program->output_signature, "Output"); + trace_signature(&program->patch_constant_signature, "Patch-constant"); + if (d3d_asm_compile(program, NULL, &code, flags) != VKD3D_OK) return;