From 03a58d74b92a941fba733b6c71ea3eafc0fb72e0 Mon Sep 17 00:00:00 2001 From: Francisco Casas Date: Thu, 2 Oct 2025 08:58:49 -0300 Subject: [PATCH] vkd3d-shader/dxil: Don't preallocate instructions in sm6_function_emit_blocks(). --- libs/vkd3d-shader/dxil.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/libs/vkd3d-shader/dxil.c b/libs/vkd3d-shader/dxil.c index efd2a6d42..fa39da255 100644 --- a/libs/vkd3d-shader/dxil.c +++ b/libs/vkd3d-shader/dxil.c @@ -8671,25 +8671,23 @@ static enum vkd3d_result sm6_function_emit_blocks(const struct sm6_function *fun { const struct sm6_block *block = function->blocks[i]; - /* Space for the label and terminator. */ - if (!sm6_parser_require_space(sm6, block->instruction_count + block->phi_count + 2)) - { - vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_OUT_OF_MEMORY, - "Out of memory emitting shader instructions."); - return VKD3D_ERROR_OUT_OF_MEMORY; - } sm6_parser_emit_label(sm6, block->id); sm6_block_emit_phi(block, sm6); for (j = 0; j < block->instruction_count; ++j) { - ins = vsir_program_append(program); + if (!(ins = vsir_program_append(program))) + { + vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_OUT_OF_MEMORY, + "Out of memory emitting block instructions."); + return sm6->p.status; + } *ins = block->instructions[j]; } sm6_block_emit_terminator(block, sm6); } - return VKD3D_OK; + return sm6->p.status; } static bool sm6_parser_allocate_named_metadata(struct sm6_parser *sm6)