From 9c678532a7452ae44057235a1543719d3bb5134c Mon Sep 17 00:00:00 2001 From: Giovanni Mascellani Date: Tue, 30 Jan 2024 15:07:50 +0100 Subject: [PATCH] vkd3d-shader/ir: Dump the domination relationship. --- libs/vkd3d-shader/ir.c | 26 +++++++++++++++++++++++- libs/vkd3d-shader/vkd3d_shader_main.c | 2 +- libs/vkd3d-shader/vkd3d_shader_private.h | 1 + 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/libs/vkd3d-shader/ir.c b/libs/vkd3d-shader/ir.c index 536b19e1..f0bd8533 100644 --- a/libs/vkd3d-shader/ir.c +++ b/libs/vkd3d-shader/ir.c @@ -3285,7 +3285,11 @@ static void vsir_cfg_compute_dominators_recurse(struct vsir_block *current, stru static void vsir_cfg_compute_dominators(struct vsir_cfg *cfg) { - size_t i; + struct vkd3d_string_buffer buf; + size_t i, j; + + if (TRACE_ON()) + vkd3d_string_buffer_init(&buf); for (i = 0; i < cfg->block_count; ++i) { @@ -3295,7 +3299,27 @@ static void vsir_cfg_compute_dominators(struct vsir_cfg *cfg) continue; vsir_cfg_compute_dominators_recurse(cfg->entry, block); + + if (TRACE_ON()) + { + vkd3d_string_buffer_printf(&buf, "Block %u dominates:", block->label); + for (j = 0; j < cfg->block_count; j++) + { + struct vsir_block *block2 = &cfg->blocks[j]; + + if (block2->label == 0) + continue; + + if (bitmap_is_set(block->dominates, j)) + vkd3d_string_buffer_printf(&buf, " %u", block2->label); + } + TRACE("%s\n", buf.buffer); + vkd3d_string_buffer_clear(&buf); + } } + + if (TRACE_ON()) + vkd3d_string_buffer_cleanup(&buf); } enum vkd3d_result vkd3d_shader_normalise(struct vkd3d_shader_parser *parser, diff --git a/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d-shader/vkd3d_shader_main.c index 20c4c2e2..462a5c25 100644 --- a/libs/vkd3d-shader/vkd3d_shader_main.c +++ b/libs/vkd3d-shader/vkd3d_shader_main.c @@ -71,7 +71,7 @@ void vkd3d_string_buffer_cleanup(struct vkd3d_string_buffer *buffer) vkd3d_free(buffer->buffer); } -static void vkd3d_string_buffer_clear(struct vkd3d_string_buffer *buffer) +void vkd3d_string_buffer_clear(struct vkd3d_string_buffer *buffer) { buffer->buffer[0] = '\0'; buffer->content_size = 0; diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 7239beaf..4b322b95 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -1399,6 +1399,7 @@ struct vkd3d_string_buffer *vkd3d_string_buffer_get(struct vkd3d_string_buffer_c void vkd3d_string_buffer_init(struct vkd3d_string_buffer *buffer); void vkd3d_string_buffer_cache_cleanup(struct vkd3d_string_buffer_cache *list); void vkd3d_string_buffer_cache_init(struct vkd3d_string_buffer_cache *list); +void vkd3d_string_buffer_clear(struct vkd3d_string_buffer *buffer); int vkd3d_string_buffer_print_f32(struct vkd3d_string_buffer *buffer, float f); int vkd3d_string_buffer_print_f64(struct vkd3d_string_buffer *buffer, double d); int vkd3d_string_buffer_printf(struct vkd3d_string_buffer *buffer, const char *format, ...) VKD3D_PRINTF_FUNC(2, 3);