mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
vkd3d-shader/ir: Use the iterator in vsir_program_lower_udiv().
This commit is contained in:
committed by
Henri Verbeet
parent
0f18d25987
commit
c1f7720075
Notes:
Henri Verbeet
2025-07-21 12:35:10 +02:00
Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1624
@@ -1169,13 +1169,13 @@ static enum vkd3d_result vsir_program_lower_imul(struct vsir_program *program,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static enum vkd3d_result vsir_program_lower_udiv(struct vsir_program *program,
|
static enum vkd3d_result vsir_program_lower_udiv(struct vsir_program *program,
|
||||||
struct vkd3d_shader_instruction *udiv, struct vsir_transformation_context *ctx)
|
struct vsir_program_iterator *it, struct vsir_transformation_context *ctx)
|
||||||
{
|
{
|
||||||
struct vkd3d_shader_instruction_array *instructions = &program->instructions;
|
struct vkd3d_shader_instruction *udiv, *ins, *mov;
|
||||||
size_t pos = udiv - instructions->elements;
|
|
||||||
struct vkd3d_shader_instruction *ins, *mov;
|
|
||||||
unsigned int count = 2;
|
unsigned int count = 2;
|
||||||
|
|
||||||
|
udiv = vsir_program_iterator_current(it);
|
||||||
|
|
||||||
if (udiv->dst_count != 2)
|
if (udiv->dst_count != 2)
|
||||||
{
|
{
|
||||||
vkd3d_shader_error(ctx->message_context, &udiv->location,
|
vkd3d_shader_error(ctx->message_context, &udiv->location,
|
||||||
@@ -1190,21 +1190,19 @@ static enum vkd3d_result vsir_program_lower_udiv(struct vsir_program *program,
|
|||||||
if (udiv->dst[1].reg.type != VKD3DSPR_NULL)
|
if (udiv->dst[1].reg.type != VKD3DSPR_NULL)
|
||||||
++count;
|
++count;
|
||||||
|
|
||||||
if (!shader_instruction_array_insert_at(instructions, pos + 1, count))
|
if (!vsir_program_iterator_insert_after(it, count))
|
||||||
return VKD3D_ERROR_OUT_OF_MEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
udiv = &instructions->elements[pos];
|
udiv = vsir_program_iterator_current(it);
|
||||||
|
|
||||||
ins = &instructions->elements[pos + 1];
|
|
||||||
|
|
||||||
/* Save the sources in a SSA in case a destination collides with a source. */
|
/* Save the sources in a SSA in case a destination collides with a source. */
|
||||||
mov = ins++;
|
mov = vsir_program_iterator_next(it);
|
||||||
if (!(vsir_instruction_init_with_params(program, mov, &udiv->location, VSIR_OP_MOV, 1, 1)))
|
if (!(vsir_instruction_init_with_params(program, mov, &udiv->location, VSIR_OP_MOV, 1, 1)))
|
||||||
return VKD3D_ERROR_OUT_OF_MEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
mov->src[0] = udiv->src[0];
|
mov->src[0] = udiv->src[0];
|
||||||
dst_param_init_ssa(&mov->dst[0], program->ssa_count, udiv->src[0].reg.data_type, udiv->src[0].reg.dimension);
|
dst_param_init_ssa(&mov->dst[0], program->ssa_count, udiv->src[0].reg.data_type, udiv->src[0].reg.dimension);
|
||||||
|
|
||||||
mov = ins++;
|
mov = vsir_program_iterator_next(it);
|
||||||
if (!(vsir_instruction_init_with_params(program, mov, &udiv->location, VSIR_OP_MOV, 1, 1)))
|
if (!(vsir_instruction_init_with_params(program, mov, &udiv->location, VSIR_OP_MOV, 1, 1)))
|
||||||
return VKD3D_ERROR_OUT_OF_MEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
@@ -1213,6 +1211,8 @@ static enum vkd3d_result vsir_program_lower_udiv(struct vsir_program *program,
|
|||||||
|
|
||||||
if (udiv->dst[0].reg.type != VKD3DSPR_NULL)
|
if (udiv->dst[0].reg.type != VKD3DSPR_NULL)
|
||||||
{
|
{
|
||||||
|
ins = vsir_program_iterator_next(it);
|
||||||
|
|
||||||
if (!(vsir_instruction_init_with_params(program, ins, &udiv->location, VSIR_OP_UDIV_SIMPLE, 1, 2)))
|
if (!(vsir_instruction_init_with_params(program, ins, &udiv->location, VSIR_OP_UDIV_SIMPLE, 1, 2)))
|
||||||
return VKD3D_ERROR_OUT_OF_MEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
@@ -1223,12 +1223,12 @@ static enum vkd3d_result vsir_program_lower_udiv(struct vsir_program *program,
|
|||||||
src_param_init_ssa(&ins->src[1], program->ssa_count + 1,
|
src_param_init_ssa(&ins->src[1], program->ssa_count + 1,
|
||||||
udiv->src[1].reg.data_type, udiv->src[1].reg.dimension);
|
udiv->src[1].reg.data_type, udiv->src[1].reg.dimension);
|
||||||
ins->dst[0] = udiv->dst[0];
|
ins->dst[0] = udiv->dst[0];
|
||||||
|
|
||||||
++ins;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (udiv->dst[1].reg.type != VKD3DSPR_NULL)
|
if (udiv->dst[1].reg.type != VKD3DSPR_NULL)
|
||||||
{
|
{
|
||||||
|
ins = vsir_program_iterator_next(it);
|
||||||
|
|
||||||
if (!(vsir_instruction_init_with_params(program, ins, &udiv->location, VSIR_OP_UREM, 1, 2)))
|
if (!(vsir_instruction_init_with_params(program, ins, &udiv->location, VSIR_OP_UREM, 1, 2)))
|
||||||
return VKD3D_ERROR_OUT_OF_MEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
@@ -1239,8 +1239,6 @@ static enum vkd3d_result vsir_program_lower_udiv(struct vsir_program *program,
|
|||||||
src_param_init_ssa(&ins->src[1], program->ssa_count + 1,
|
src_param_init_ssa(&ins->src[1], program->ssa_count + 1,
|
||||||
udiv->src[1].reg.data_type, udiv->src[1].reg.dimension);
|
udiv->src[1].reg.data_type, udiv->src[1].reg.dimension);
|
||||||
ins->dst[0] = udiv->dst[1];
|
ins->dst[0] = udiv->dst[1];
|
||||||
|
|
||||||
++ins;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vkd3d_shader_instruction_make_nop(udiv);
|
vkd3d_shader_instruction_make_nop(udiv);
|
||||||
@@ -1639,7 +1637,7 @@ static enum vkd3d_result vsir_program_lower_instructions(struct vsir_program *pr
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case VSIR_OP_UDIV:
|
case VSIR_OP_UDIV:
|
||||||
if ((ret = vsir_program_lower_udiv(program, ins, ctx)) < 0)
|
if ((ret = vsir_program_lower_udiv(program, &it, ctx)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user