mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-12-15 08:03:30 -08:00
vkd3d-shader/ir: Explicitly initialize instruction arrays.
Do not assume that zero initialization is enough, for uniformity of interface and also to support other data structures.
This commit is contained in:
committed by
Henri Verbeet
parent
f49aa3d272
commit
fc84f80c96
Notes:
Henri Verbeet
2025-09-30 17:26:34 +02:00
Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1760
@@ -4501,6 +4501,8 @@ static enum vkd3d_result vsir_program_flatten_control_flow_constructs(struct vsi
|
|||||||
|
|
||||||
VKD3D_ASSERT(program->cf_type == VSIR_CF_STRUCTURED);
|
VKD3D_ASSERT(program->cf_type == VSIR_CF_STRUCTURED);
|
||||||
|
|
||||||
|
shader_instruction_array_init(&flattener.instructions, 0);
|
||||||
|
|
||||||
if ((result = cf_flattener_iterate_instruction_array(&flattener, message_context)) >= 0)
|
if ((result = cf_flattener_iterate_instruction_array(&flattener, message_context)) >= 0)
|
||||||
{
|
{
|
||||||
vsir_program_replace_instructions(program, &flattener.instructions);
|
vsir_program_replace_instructions(program, &flattener.instructions);
|
||||||
@@ -4560,14 +4562,14 @@ static enum vkd3d_result vsir_program_lower_switch_to_selection_ladder(struct vs
|
|||||||
unsigned int block_count = program->block_count, ssa_count = program->ssa_count, current_label = 0, if_label;
|
unsigned int block_count = program->block_count, ssa_count = program->ssa_count, current_label = 0, if_label;
|
||||||
struct vsir_program_iterator it = vsir_program_iterator(&program->instructions);
|
struct vsir_program_iterator it = vsir_program_iterator(&program->instructions);
|
||||||
struct lower_switch_to_if_ladder_block_mapping *block_map = NULL;
|
struct lower_switch_to_if_ladder_block_mapping *block_map = NULL;
|
||||||
struct vkd3d_shader_instruction_array instructions = {0};
|
struct vkd3d_shader_instruction_array instructions;
|
||||||
struct vkd3d_shader_instruction *ins, *dst_ins;
|
struct vkd3d_shader_instruction *ins, *dst_ins;
|
||||||
size_t map_capacity = 0, map_count = 0;
|
size_t map_capacity = 0, map_count = 0;
|
||||||
|
|
||||||
VKD3D_ASSERT(program->cf_type == VSIR_CF_BLOCKS);
|
VKD3D_ASSERT(program->cf_type == VSIR_CF_BLOCKS);
|
||||||
|
|
||||||
if (!shader_instruction_array_reserve(&instructions, program->instructions.count))
|
if (!shader_instruction_array_init(&instructions, program->instructions.count))
|
||||||
goto fail;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
/* First subpass: convert SWITCH_MONOLITHIC instructions to
|
/* First subpass: convert SWITCH_MONOLITHIC instructions to
|
||||||
* selection ladders, keeping a map between blocks before and
|
* selection ladders, keeping a map between blocks before and
|
||||||
@@ -4757,7 +4759,7 @@ static enum vkd3d_result vsir_program_materialise_phi_ssas_to_temps(struct vsir_
|
|||||||
{
|
{
|
||||||
struct vsir_program_iterator it = vsir_program_iterator(&program->instructions);
|
struct vsir_program_iterator it = vsir_program_iterator(&program->instructions);
|
||||||
struct ssas_to_temps_block_info *info, *block_info = NULL;
|
struct ssas_to_temps_block_info *info, *block_info = NULL;
|
||||||
struct vkd3d_shader_instruction_array instructions = {0};
|
struct vkd3d_shader_instruction_array instructions;
|
||||||
struct vkd3d_shader_instruction *ins, *dst_ins;
|
struct vkd3d_shader_instruction *ins, *dst_ins;
|
||||||
struct ssas_to_temps_alloc alloc = {0};
|
struct ssas_to_temps_alloc alloc = {0};
|
||||||
size_t phi_count, incoming_count;
|
size_t phi_count, incoming_count;
|
||||||
@@ -4765,6 +4767,9 @@ static enum vkd3d_result vsir_program_materialise_phi_ssas_to_temps(struct vsir_
|
|||||||
|
|
||||||
VKD3D_ASSERT(program->cf_type == VSIR_CF_BLOCKS);
|
VKD3D_ASSERT(program->cf_type == VSIR_CF_BLOCKS);
|
||||||
|
|
||||||
|
if (!shader_instruction_array_init(&instructions, 0))
|
||||||
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
if (!(block_info = vkd3d_calloc(program->block_count, sizeof(*block_info))))
|
if (!(block_info = vkd3d_calloc(program->block_count, sizeof(*block_info))))
|
||||||
{
|
{
|
||||||
ERR("Failed to allocate block info array.\n");
|
ERR("Failed to allocate block info array.\n");
|
||||||
@@ -7033,7 +7038,7 @@ static enum vkd3d_result vsir_program_structurize(struct vsir_program *program,
|
|||||||
target.jump_target_temp_idx = program->temp_count;
|
target.jump_target_temp_idx = program->temp_count;
|
||||||
target.temp_count = program->temp_count + 1;
|
target.temp_count = program->temp_count + 1;
|
||||||
|
|
||||||
if (!shader_instruction_array_reserve(&target.instructions, target.instructions.count))
|
if (!shader_instruction_array_init(&target.instructions, 0))
|
||||||
return VKD3D_ERROR_OUT_OF_MEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
for (ins = vsir_program_iterator_head(&it); ins;)
|
for (ins = vsir_program_iterator_head(&it); ins;)
|
||||||
|
|||||||
Reference in New Issue
Block a user