From 5a563ce05d73aadeea6f6bdcbea4e242d3393e76 Mon Sep 17 00:00:00 2001 From: Francisco Casas Date: Fri, 12 Sep 2025 15:11:31 -0300 Subject: [PATCH] vkd3d-shader/ir: Move icbs from struct vkd3d_shader_instruction_array to struct vsir_program. --- libs/vkd3d-shader/dxil.c | 2 +- libs/vkd3d-shader/ir.c | 20 +++++++++----------- libs/vkd3d-shader/tpf.c | 2 +- libs/vkd3d-shader/vkd3d_shader_private.h | 11 ++++++----- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/libs/vkd3d-shader/dxil.c b/libs/vkd3d-shader/dxil.c index 44d2b8b11..8c0ef8b8b 100644 --- a/libs/vkd3d-shader/dxil.c +++ b/libs/vkd3d-shader/dxil.c @@ -3246,7 +3246,7 @@ static enum vkd3d_result value_allocate_constant_array(struct sm6_value *dst, co "Out of memory allocating an immediate constant buffer of count %u.", count); return VKD3D_ERROR_OUT_OF_MEMORY; } - if (!shader_instruction_array_add_icb(&sm6->program->instructions, icb)) + if (!vsir_program_add_icb(sm6->program, icb)) { ERR("Failed to store icb object.\n"); vkd3d_free(icb); diff --git a/libs/vkd3d-shader/ir.c b/libs/vkd3d-shader/ir.c index f3b9717d3..29225fdfb 100644 --- a/libs/vkd3d-shader/ir.c +++ b/libs/vkd3d-shader/ir.c @@ -502,13 +502,13 @@ bool shader_instruction_array_insert_at(struct vkd3d_shader_instruction_array *a return true; } -bool shader_instruction_array_add_icb(struct vkd3d_shader_instruction_array *array, - struct vkd3d_shader_immediate_constant_buffer *icb) +bool vsir_program_add_icb(struct vsir_program *program, struct vkd3d_shader_immediate_constant_buffer *icb) { - if (!vkd3d_array_reserve((void **)&array->icbs, &array->icb_capacity, array->icb_count + 1, sizeof(*array->icbs))) + if (!vkd3d_array_reserve((void **)&program->icbs, &program->icb_capacity, + program->icb_count + 1, sizeof(*program->icbs))) return false; - array->icbs[array->icb_count++] = icb; + program->icbs[program->icb_count++] = icb; return true; } @@ -573,16 +573,9 @@ static struct vkd3d_shader_src_param *shader_instruction_array_clone_src_params( static void shader_instruction_array_destroy(struct vkd3d_shader_instruction_array *array) { - unsigned int i; - vkd3d_free(array->elements); shader_param_allocator_destroy(&array->dst_params); shader_param_allocator_destroy(&array->src_params); - for (i = 0; i < array->icb_count; ++i) - { - vkd3d_free(array->icbs[i]); - } - vkd3d_free(array->icbs); } static bool shader_instruction_array_init(struct vkd3d_shader_instruction_array *array, size_t reserve) @@ -694,6 +687,11 @@ void vsir_program_cleanup(struct vsir_program *program) shader_signature_cleanup(&program->output_signature); shader_signature_cleanup(&program->patch_constant_signature); vkd3d_shader_free_scan_descriptor_info1(&program->descriptors); + for (i = 0; i < program->icb_count; ++i) + { + vkd3d_free(program->icbs[i]); + } + vkd3d_free(program->icbs); } const struct vkd3d_shader_parameter1 *vsir_program_get_parameter( diff --git a/libs/vkd3d-shader/tpf.c b/libs/vkd3d-shader/tpf.c index ec1d8b91e..2541aef13 100644 --- a/libs/vkd3d-shader/tpf.c +++ b/libs/vkd3d-shader/tpf.c @@ -851,7 +851,7 @@ static void shader_sm4_read_shader_data(struct vkd3d_shader_instruction *ins, ui icb->element_count = icb_size / VKD3D_VEC4_SIZE; icb->is_null = false; memcpy(icb->data, tokens, sizeof(*tokens) * icb_size); - shader_instruction_array_add_icb(&priv->program->instructions, icb); + vsir_program_add_icb(priv->program, icb); ins->declaration.icb = icb; } diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index dbd2542a9..5bcdcb5bc 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -1443,9 +1443,6 @@ struct vkd3d_shader_instruction_array struct vkd3d_shader_param_allocator src_params; struct vkd3d_shader_param_allocator dst_params; - struct vkd3d_shader_immediate_constant_buffer **icbs; - size_t icb_capacity; - size_t icb_count; struct vkd3d_shader_src_param *outpointid_param; }; @@ -1453,8 +1450,6 @@ struct vkd3d_shader_instruction_array bool shader_instruction_array_reserve(struct vkd3d_shader_instruction_array *instructions, size_t reserve); bool shader_instruction_array_insert_at(struct vkd3d_shader_instruction_array *instructions, size_t idx, size_t count); -bool shader_instruction_array_add_icb(struct vkd3d_shader_instruction_array *instructions, - struct vkd3d_shader_immediate_constant_buffer *icb); struct vsir_program_iterator { @@ -1638,12 +1633,18 @@ struct vsir_program struct vkd3d_shader_source_list source_files; const char **block_names; size_t block_name_count; + + struct vkd3d_shader_immediate_constant_buffer **icbs; + size_t icb_capacity; + size_t icb_count; }; enum vkd3d_result vsir_allocate_temp_registers(struct vsir_program *program, struct vkd3d_shader_message_context *message_context); enum vkd3d_result vsir_update_dcl_temps(struct vsir_program *program, struct vkd3d_shader_message_context *message_context); + +bool vsir_program_add_icb(struct vsir_program *program, struct vkd3d_shader_immediate_constant_buffer *icb); void vsir_program_cleanup(struct vsir_program *program); const struct vkd3d_shader_parameter1 *vsir_program_get_parameter( const struct vsir_program *program, enum vkd3d_shader_parameter_name name);