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_sm4_sincos().
This commit is contained in:
committed by
Henri Verbeet
parent
55b8002bf6
commit
5407c8b975
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
@@ -1310,13 +1310,13 @@ static enum vkd3d_result vsir_program_lower_sm1_sincos(struct vsir_program *prog
|
|||||||
}
|
}
|
||||||
|
|
||||||
static enum vkd3d_result vsir_program_lower_sm4_sincos(struct vsir_program *program,
|
static enum vkd3d_result vsir_program_lower_sm4_sincos(struct vsir_program *program,
|
||||||
struct vkd3d_shader_instruction *sincos, 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 *ins, *mov, *sincos;
|
||||||
size_t pos = sincos - instructions->elements;
|
|
||||||
struct vkd3d_shader_instruction *ins, *mov;
|
|
||||||
unsigned int count = 1;
|
unsigned int count = 1;
|
||||||
|
|
||||||
|
sincos = vsir_program_iterator_current(it);
|
||||||
|
|
||||||
if (sincos->dst_count != 2)
|
if (sincos->dst_count != 2)
|
||||||
{
|
{
|
||||||
vkd3d_shader_error(ctx->message_context, &sincos->location,
|
vkd3d_shader_error(ctx->message_context, &sincos->location,
|
||||||
@@ -1331,14 +1331,12 @@ static enum vkd3d_result vsir_program_lower_sm4_sincos(struct vsir_program *prog
|
|||||||
if (sincos->dst[1].reg.type != VKD3DSPR_NULL)
|
if (sincos->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;
|
||||||
sincos = &instructions->elements[pos];
|
sincos = vsir_program_iterator_current(it);
|
||||||
|
|
||||||
ins = &instructions->elements[pos + 1];
|
|
||||||
|
|
||||||
/* Save the source in a SSA in case a destination collides with the source. */
|
/* Save the source in a SSA in case a destination collides with the source. */
|
||||||
mov = ins++;
|
mov = vsir_program_iterator_next(it);
|
||||||
if (!(vsir_instruction_init_with_params(program, mov, &sincos->location, VSIR_OP_MOV, 1, 1)))
|
if (!(vsir_instruction_init_with_params(program, mov, &sincos->location, VSIR_OP_MOV, 1, 1)))
|
||||||
return VKD3D_ERROR_OUT_OF_MEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
@@ -1347,6 +1345,8 @@ static enum vkd3d_result vsir_program_lower_sm4_sincos(struct vsir_program *prog
|
|||||||
|
|
||||||
if (sincos->dst[0].reg.type != VKD3DSPR_NULL)
|
if (sincos->dst[0].reg.type != VKD3DSPR_NULL)
|
||||||
{
|
{
|
||||||
|
ins = vsir_program_iterator_next(it);
|
||||||
|
|
||||||
if (!(vsir_instruction_init_with_params(program, ins, &sincos->location, VSIR_OP_SIN, 1, 1)))
|
if (!(vsir_instruction_init_with_params(program, ins, &sincos->location, VSIR_OP_SIN, 1, 1)))
|
||||||
return VKD3D_ERROR_OUT_OF_MEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
@@ -1355,12 +1355,12 @@ static enum vkd3d_result vsir_program_lower_sm4_sincos(struct vsir_program *prog
|
|||||||
src_param_init_ssa(&ins->src[0], program->ssa_count,
|
src_param_init_ssa(&ins->src[0], program->ssa_count,
|
||||||
sincos->src[0].reg.data_type, sincos->src[0].reg.dimension);
|
sincos->src[0].reg.data_type, sincos->src[0].reg.dimension);
|
||||||
ins->dst[0] = sincos->dst[0];
|
ins->dst[0] = sincos->dst[0];
|
||||||
|
|
||||||
++ins;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sincos->dst[1].reg.type != VKD3DSPR_NULL)
|
if (sincos->dst[1].reg.type != VKD3DSPR_NULL)
|
||||||
{
|
{
|
||||||
|
ins = vsir_program_iterator_next(it);
|
||||||
|
|
||||||
if (!(vsir_instruction_init_with_params(program, ins, &sincos->location, VSIR_OP_COS, 1, 1)))
|
if (!(vsir_instruction_init_with_params(program, ins, &sincos->location, VSIR_OP_COS, 1, 1)))
|
||||||
return VKD3D_ERROR_OUT_OF_MEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
@@ -1369,8 +1369,6 @@ static enum vkd3d_result vsir_program_lower_sm4_sincos(struct vsir_program *prog
|
|||||||
src_param_init_ssa(&ins->src[0], program->ssa_count,
|
src_param_init_ssa(&ins->src[0], program->ssa_count,
|
||||||
sincos->src[0].reg.data_type, sincos->src[0].reg.dimension);
|
sincos->src[0].reg.data_type, sincos->src[0].reg.dimension);
|
||||||
ins->dst[0] = sincos->dst[1];
|
ins->dst[0] = sincos->dst[1];
|
||||||
|
|
||||||
++ins;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vkd3d_shader_instruction_make_nop(sincos);
|
vkd3d_shader_instruction_make_nop(sincos);
|
||||||
@@ -1646,7 +1644,7 @@ static enum vkd3d_result vsir_program_lower_instructions(struct vsir_program *pr
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((ret = vsir_program_lower_sm4_sincos(program, ins, ctx)) < 0)
|
if ((ret = vsir_program_lower_sm4_sincos(program, &it, ctx)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user