From a12d64fba10807375f5cb7b900a213816cb291b4 Mon Sep 17 00:00:00 2001 From: Giovanni Mascellani Date: Wed, 16 Jul 2025 22:08:15 +0200 Subject: [PATCH] vkd3d-shader/ir: Use the iterator in vsir_program_lower_texkill(). --- libs/vkd3d-shader/ir.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/libs/vkd3d-shader/ir.c b/libs/vkd3d-shader/ir.c index 02b55e2be..6fdc6864a 100644 --- a/libs/vkd3d-shader/ir.c +++ b/libs/vkd3d-shader/ir.c @@ -1024,24 +1024,22 @@ static enum vkd3d_result vsir_program_lower_ifc(struct vsir_program *program, } static enum vkd3d_result vsir_program_lower_texkill(struct vsir_program *program, - struct vkd3d_shader_instruction *texkill, unsigned int *tmp_idx) + struct vsir_program_iterator *it, unsigned int *tmp_idx) { const unsigned int components_read = 3 + (program->shader_version.major >= 2); - struct vkd3d_shader_instruction_array *instructions = &program->instructions; - size_t pos = texkill - instructions->elements; - struct vkd3d_shader_instruction *ins; + struct vkd3d_shader_instruction *ins, *texkill; unsigned int j; - if (!shader_instruction_array_insert_at(instructions, pos + 1, components_read + 1)) + if (!vsir_program_iterator_insert_after(it, components_read + 1)) return VKD3D_ERROR_OUT_OF_MEMORY; - texkill = &instructions->elements[pos]; + texkill = vsir_program_iterator_current(it); if (*tmp_idx == ~0u) *tmp_idx = program->temp_count++; /* tmp = ins->src[0] < 0 */ - ins = &instructions->elements[pos + 1]; + ins = vsir_program_iterator_next(it); if (!vsir_instruction_init_with_params(program, ins, &texkill->location, VSIR_OP_LTO, 1, 2)) return VKD3D_ERROR_OUT_OF_MEMORY; @@ -1065,7 +1063,7 @@ static enum vkd3d_result vsir_program_lower_texkill(struct vsir_program *program for (j = 1; j < components_read; ++j) { - ins = &instructions->elements[pos + 1 + j]; + ins = vsir_program_iterator_next(it); if (!(vsir_instruction_init_with_params(program, ins, &texkill->location, VSIR_OP_OR, 1, 2))) return VKD3D_ERROR_OUT_OF_MEMORY; @@ -1086,7 +1084,7 @@ static enum vkd3d_result vsir_program_lower_texkill(struct vsir_program *program /* discard_nz tmp.x */ - ins = &instructions->elements[pos + 1 + components_read]; + ins = vsir_program_iterator_next(it); if (!(vsir_instruction_init_with_params(program, ins, &texkill->location, VSIR_OP_DISCARD, 0, 1))) return VKD3D_ERROR_OUT_OF_MEMORY; ins->flags = VKD3D_SHADER_CONDITIONAL_OP_NZ; @@ -1595,7 +1593,7 @@ static enum vkd3d_result vsir_program_lower_instructions(struct vsir_program *pr break; case VSIR_OP_TEXKILL: - if ((ret = vsir_program_lower_texkill(program, ins, &tmp_idx)) < 0) + if ((ret = vsir_program_lower_texkill(program, &it, &tmp_idx)) < 0) return ret; break;