Skip to content

vkd3d-shader: Use iterators everywhere, part 10/11.

After these patches, the only things required to change the data type used by vkd3d_shader_instruction_array are, besides changing the definition of the struct itself, changing the implementation of these functions:

shader_instruction_array_reserve()
shader_instruction_array_insert_at()
shader_instruction_array_clear_instructions()
shader_instruction_array_destroy()
shader_instruction_array_init()
shader_instruction_array_get_count()

And the vsir_program_iterator struct and related functions:

vsir_program_iterator()
vsir_program_iterator_current()
vsir_program_iterator_head()
vsir_program_iterator_tail()
vsir_program_iterator_next()
vsir_program_iterator_prev()
vsir_program_iterator_insert_after()
vsir_program_iterator_insert_before()
vsir_program_iterator_insert_before_and_move()

Currently we have 4 functions that create a plain array of instructions, then delete all instructions in program->instructions, and then replace them with the instructions in this array.

To abstract this from the data type used in the program->instructions vkd3d_shader_instruction_array, I introduced vsir_program_replace_instructions(), which basically used vsir_program_append() to introduce the plain array instructions one by one.

As per Giovanni's suggestion, it looks like a better idea to make these 4 functions create their own vkd3d_shader_instruction_array (instead of a plain array) and then replace the program->instructions with this one.

This requires some refactoring: it doesn't make sense to keep some fields, namely dst_params, src_params, the icbs and outpointid_param in the vkd3d_shader_instruction_array. They rather be in the vsir_program.

So this MR now takes care of this refactoring, and the next one will take care of the 4 functions creating a vkd3d_shader_instruction_array and replacing the program's one.

Edited by Francisco Casas

Merge request reports

Loading