From 80b2a2eb55b2a6453806370e420f9029a30854ee Mon Sep 17 00:00:00 2001 From: "Anna (navi) Figueiredo Gomes" Date: Fri, 9 Aug 2024 17:54:47 +0200 Subject: [PATCH] vkd3d-shader/ir: Periodically flush buffers when tracing blocks. Avoids overflowing the output buffer for the trace in cases where the output is too long, which raises an exception. --- libs/vkd3d-shader/ir.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/libs/vkd3d-shader/ir.c b/libs/vkd3d-shader/ir.c index c1b8582a..5c33c40e 100644 --- a/libs/vkd3d-shader/ir.c +++ b/libs/vkd3d-shader/ir.c @@ -3831,11 +3831,16 @@ static void vsir_cfg_compute_dominators(struct vsir_cfg *cfg) { struct vsir_block *block2 = &cfg->blocks[j]; - if (block2->label == 0) + if (block2->label == 0 || !vsir_block_dominates(block, block2)) continue; - if (vsir_block_dominates(block, block2)) - vkd3d_string_buffer_printf(&cfg->debug_buffer, " %u", block2->label); + if (cfg->debug_buffer.content_size > 512) + { + TRACE("%s...\n", cfg->debug_buffer.buffer); + vkd3d_string_buffer_clear(&cfg->debug_buffer); + vkd3d_string_buffer_printf(&cfg->debug_buffer, "Block %u dominates: ...", block->label); + } + vkd3d_string_buffer_printf(&cfg->debug_buffer, " %u", block2->label); } TRACE("%s\n", cfg->debug_buffer.buffer); vkd3d_string_buffer_clear(&cfg->debug_buffer); @@ -3927,7 +3932,16 @@ static enum vkd3d_result vsir_cfg_compute_loops(struct vsir_cfg *cfg) vkd3d_string_buffer_printf(&cfg->debug_buffer, "Back edge %u -> %u with loop:", block->label, header->label); for (k = 0; k < loop->count; ++k) + { + if (cfg->debug_buffer.content_size > 512) + { + TRACE("%s...\n", cfg->debug_buffer.buffer); + vkd3d_string_buffer_clear(&cfg->debug_buffer); + vkd3d_string_buffer_printf(&cfg->debug_buffer, "Back edge %u -> %u with loop: ...", + block->label, header->label); + } vkd3d_string_buffer_printf(&cfg->debug_buffer, " %u", loop->blocks[k]->label); + } TRACE("%s\n", cfg->debug_buffer.buffer); vkd3d_string_buffer_clear(&cfg->debug_buffer); @@ -4150,7 +4164,15 @@ static enum vkd3d_result vsir_cfg_sort_nodes(struct vsir_cfg *cfg) vkd3d_string_buffer_printf(&cfg->debug_buffer, "Block order:"); for (i = 0; i < cfg->order.count; ++i) + { + if (cfg->debug_buffer.content_size > 512) + { + TRACE("%s...\n", cfg->debug_buffer.buffer); + vkd3d_string_buffer_clear(&cfg->debug_buffer); + vkd3d_string_buffer_printf(&cfg->debug_buffer, "Block order: ..."); + } vkd3d_string_buffer_printf(&cfg->debug_buffer, " %u", cfg->order.blocks[i]->label); + } TRACE("%s\n", cfg->debug_buffer.buffer); vkd3d_string_buffer_clear(&cfg->debug_buffer);