mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
vkd3d-shader/hlsl: Store SM4 SIN and COS in the vsir program.
This commit is contained in:
committed by
Henri Verbeet
parent
befba8e813
commit
3c4889add3
Notes:
Henri Verbeet
2024-11-06 23:02:23 +01:00
Approved-by: Elizabeth Figura (@zfigura) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1251
@@ -7988,6 +7988,36 @@ static bool sm4_generate_vsir_instr_expr_cast(struct hlsl_ctx *ctx,
|
||||
}
|
||||
}
|
||||
|
||||
static void sm4_generate_vsir_expr_with_two_destinations(struct hlsl_ctx *ctx, struct vsir_program *program,
|
||||
enum vkd3d_shader_opcode opcode, const struct hlsl_ir_expr *expr, unsigned int dst_idx)
|
||||
{
|
||||
struct vkd3d_shader_dst_param *dst_param, *null_param;
|
||||
const struct hlsl_ir_node *instr = &expr->node;
|
||||
struct vkd3d_shader_instruction *ins;
|
||||
unsigned int i, src_count;
|
||||
|
||||
VKD3D_ASSERT(instr->reg.allocated);
|
||||
|
||||
for (i = 0; i < HLSL_MAX_OPERANDS; ++i)
|
||||
{
|
||||
if (expr->operands[i].node)
|
||||
src_count = i + 1;
|
||||
}
|
||||
|
||||
if (!(ins = generate_vsir_add_program_instruction(ctx, program, &instr->loc, opcode, 2, src_count)))
|
||||
return;
|
||||
|
||||
dst_param = &ins->dst[dst_idx];
|
||||
vsir_dst_from_hlsl_node(dst_param, ctx, instr);
|
||||
|
||||
null_param = &ins->dst[1 - dst_idx];
|
||||
vsir_dst_param_init(null_param, VKD3DSPR_NULL, VKD3D_DATA_FLOAT, 0);
|
||||
null_param->reg.dimension = VSIR_DIMENSION_NONE;
|
||||
|
||||
for (i = 0; i < src_count; ++i)
|
||||
vsir_src_from_hlsl_node(&ins->src[i], ctx, expr->operands[i].node, dst_param->write_mask);
|
||||
}
|
||||
|
||||
static bool sm4_generate_vsir_instr_expr(struct hlsl_ctx *ctx,
|
||||
struct vsir_program *program, struct hlsl_ir_expr *expr, const char *dst_type_name)
|
||||
{
|
||||
@@ -8022,6 +8052,11 @@ static bool sm4_generate_vsir_instr_expr(struct hlsl_ctx *ctx,
|
||||
generate_vsir_instr_expr_single_instr_op(ctx, program, expr, VKD3DSIH_ROUND_PI, 0, 0, true);
|
||||
return true;
|
||||
|
||||
case HLSL_OP1_COS:
|
||||
VKD3D_ASSERT(type_is_float(dst_type));
|
||||
sm4_generate_vsir_expr_with_two_destinations(ctx, program, VKD3DSIH_SINCOS, expr, 1);
|
||||
return true;
|
||||
|
||||
case HLSL_OP1_DSX:
|
||||
VKD3D_ASSERT(type_is_float(dst_type));
|
||||
generate_vsir_instr_expr_single_instr_op(ctx, program, expr, VKD3DSIH_DSX, 0, 0, true);
|
||||
@@ -8120,6 +8155,11 @@ static bool sm4_generate_vsir_instr_expr(struct hlsl_ctx *ctx,
|
||||
generate_vsir_instr_expr_single_instr_op(ctx, program, expr, VKD3DSIH_RSQ, 0, 0, true);
|
||||
return true;
|
||||
|
||||
case HLSL_OP1_SIN:
|
||||
VKD3D_ASSERT(type_is_float(dst_type));
|
||||
sm4_generate_vsir_expr_with_two_destinations(ctx, program, VKD3DSIH_SINCOS, expr, 0);
|
||||
return true;
|
||||
|
||||
case HLSL_OP1_SQRT:
|
||||
VKD3D_ASSERT(type_is_float(dst_type));
|
||||
generate_vsir_instr_expr_single_instr_op(ctx, program, expr, VKD3DSIH_SQRT, 0, 0, true);
|
||||
|
Reference in New Issue
Block a user