From da4d5ef3390cca6d71ba1bb81dea8bbdb4327301 Mon Sep 17 00:00:00 2001 From: Francisco Casas Date: Tue, 30 Sep 2025 09:26:08 -0300 Subject: [PATCH] vkd3d-shader/dxil: Get rid of sm6_parser_require_space(). It's not obvious what this last remaining use of sm6_parser_require_space() is preallocating space for, and that's as good of a reason as any to get rid of it. --- libs/vkd3d-shader/dxil.c | 25 ------------------------ libs/vkd3d-shader/ir.c | 2 +- libs/vkd3d-shader/vkd3d_shader_private.h | 1 - 3 files changed, 1 insertion(+), 27 deletions(-) diff --git a/libs/vkd3d-shader/dxil.c b/libs/vkd3d-shader/dxil.c index fa39da255..6059e3bd4 100644 --- a/libs/vkd3d-shader/dxil.c +++ b/libs/vkd3d-shader/dxil.c @@ -3681,18 +3681,6 @@ static bool bitcode_parse_alignment(uint64_t encoded_alignment, unsigned int *al return true; } -static struct vkd3d_shader_instruction *sm6_parser_require_space(struct sm6_parser *sm6, size_t extra) -{ - struct vkd3d_shader_instruction_array *instructions = &sm6->program->instructions; - - if (!shader_instruction_array_reserve(instructions, instructions->count + extra)) - { - ERR("Failed to allocate instruction.\n"); - return NULL; - } - return &instructions->elements[instructions->count]; -} - static struct vkd3d_shader_instruction *sm6_parser_add_instruction(struct sm6_parser *sm6, enum vkd3d_shader_opcode op) { @@ -10723,7 +10711,6 @@ static enum vkd3d_result sm6_parser_init(struct sm6_parser *sm6, struct vsir_pro { size_t count, length, function_count, expected_function_count, byte_code_size = dxbc_desc->byte_code_size; const struct vkd3d_shader_location location = {.source_name = compile_info->source_name}; - struct shader_signature *patch_constant_signature, *output_signature, *input_signature; uint32_t version_token, dxil_version, token_count, magic; const uint32_t *byte_code = dxbc_desc->byte_code; unsigned int chunk_offset, chunk_size; @@ -10837,9 +10824,6 @@ static enum vkd3d_result sm6_parser_init(struct sm6_parser *sm6, struct vsir_pro break; } - input_signature = &program->input_signature; - output_signature = &program->output_signature; - patch_constant_signature = &program->patch_constant_signature; program->features = dxbc_desc->features; memset(dxbc_desc, 0, sizeof(*dxbc_desc)); @@ -10981,15 +10965,6 @@ static enum vkd3d_result sm6_parser_init(struct sm6_parser *sm6, struct vsir_pro goto fail; } - if (!sm6_parser_require_space(sm6, output_signature->element_count + input_signature->element_count - + patch_constant_signature->element_count)) - { - vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_OUT_OF_MEMORY, - "Out of memory emitting shader signature declarations."); - ret = VKD3D_ERROR_OUT_OF_MEMORY; - goto fail; - } - program->ssa_count = sm6->ssa_next_id; if (!(fn = sm6_parser_get_function(sm6, sm6->entry_point))) diff --git a/libs/vkd3d-shader/ir.c b/libs/vkd3d-shader/ir.c index cc951e8ac..d650dc42c 100644 --- a/libs/vkd3d-shader/ir.c +++ b/libs/vkd3d-shader/ir.c @@ -477,7 +477,7 @@ void *shader_param_allocator_get(struct vkd3d_shader_param_allocator *allocator, return params; } -bool shader_instruction_array_reserve(struct vkd3d_shader_instruction_array *array, size_t reserve) +static bool shader_instruction_array_reserve(struct vkd3d_shader_instruction_array *array, size_t reserve) { if (!vkd3d_array_reserve((void **)&array->elements, &array->capacity, reserve, sizeof(*array->elements))) { diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 047300651..75a1e1f1c 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -1438,7 +1438,6 @@ struct vkd3d_shader_instruction_array struct vkd3d_shader_instruction *shader_instruction_array_append(struct vkd3d_shader_instruction_array *array); bool shader_instruction_array_insert_at(struct vkd3d_shader_instruction_array *instructions, size_t idx, size_t count); -bool shader_instruction_array_reserve(struct vkd3d_shader_instruction_array *instructions, size_t reserve); struct vsir_program_iterator {