mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d-shader/hlsl: Add support for ddx(), ddy() intrinsics.
SPIR-V already handled DSX/DSY, so only D3DBC/TPF needed new case blocks. Signed-off-by: Ethan Lee <flibitijibibo@gmail.com>
This commit is contained in:
parent
af4bb03795
commit
138c32ce88
Notes:
Alexandre Julliard
2023-04-28 22:02:10 +02:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Zebediah Figura (@zfigura) Approved-by: Francisco Casas (@fcasas) Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/179
@ -1696,6 +1696,14 @@ static void write_sm1_expr(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *b
|
|||||||
write_sm1_unary_op(ctx, buffer, D3DSIO_ABS, &instr->reg, &arg1->reg, 0, 0);
|
write_sm1_unary_op(ctx, buffer, D3DSIO_ABS, &instr->reg, &arg1->reg, 0, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case HLSL_OP1_DSX:
|
||||||
|
write_sm1_unary_op(ctx, buffer, D3DSIO_DSX, &instr->reg, &arg1->reg, 0, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HLSL_OP1_DSY:
|
||||||
|
write_sm1_unary_op(ctx, buffer, D3DSIO_DSY, &instr->reg, &arg1->reg, 0, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
case HLSL_OP1_EXP2:
|
case HLSL_OP1_EXP2:
|
||||||
write_sm1_per_component_unary_op(ctx, buffer, instr, D3DSIO_EXP);
|
write_sm1_per_component_unary_op(ctx, buffer, instr, D3DSIO_EXP);
|
||||||
break;
|
break;
|
||||||
|
@ -2648,6 +2648,28 @@ static bool intrinsic_cross(struct hlsl_ctx *ctx,
|
|||||||
return !!add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_ADD, mul2, mul1_neg, loc);
|
return !!add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_ADD, mul2, mul1_neg, loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool intrinsic_ddx(struct hlsl_ctx *ctx,
|
||||||
|
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
|
||||||
|
{
|
||||||
|
struct hlsl_ir_node *arg;
|
||||||
|
|
||||||
|
if (!(arg = intrinsic_float_convert_arg(ctx, params, params->args[0], loc)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return !!add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_DSX, arg, loc);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool intrinsic_ddy(struct hlsl_ctx *ctx,
|
||||||
|
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
|
||||||
|
{
|
||||||
|
struct hlsl_ir_node *arg;
|
||||||
|
|
||||||
|
if (!(arg = intrinsic_float_convert_arg(ctx, params, params->args[0], loc)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return !!add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_DSY, arg, loc);
|
||||||
|
}
|
||||||
|
|
||||||
static bool intrinsic_distance(struct hlsl_ctx *ctx,
|
static bool intrinsic_distance(struct hlsl_ctx *ctx,
|
||||||
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
|
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
|
||||||
{
|
{
|
||||||
@ -3380,6 +3402,8 @@ intrinsic_functions[] =
|
|||||||
{"clamp", 3, true, intrinsic_clamp},
|
{"clamp", 3, true, intrinsic_clamp},
|
||||||
{"cos", 1, true, intrinsic_cos},
|
{"cos", 1, true, intrinsic_cos},
|
||||||
{"cross", 2, true, intrinsic_cross},
|
{"cross", 2, true, intrinsic_cross},
|
||||||
|
{"ddx", 1, true, intrinsic_ddx},
|
||||||
|
{"ddy", 1, true, intrinsic_ddy},
|
||||||
{"distance", 2, true, intrinsic_distance},
|
{"distance", 2, true, intrinsic_distance},
|
||||||
{"dot", 2, true, intrinsic_dot},
|
{"dot", 2, true, intrinsic_dot},
|
||||||
{"exp", 1, true, intrinsic_exp},
|
{"exp", 1, true, intrinsic_exp},
|
||||||
|
@ -3948,6 +3948,16 @@ static void write_sm4_expr(struct hlsl_ctx *ctx,
|
|||||||
write_sm4_unary_op_with_two_destinations(buffer, VKD3D_SM4_OP_SINCOS, &expr->node, 1, arg1);
|
write_sm4_unary_op_with_two_destinations(buffer, VKD3D_SM4_OP_SINCOS, &expr->node, 1, arg1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case HLSL_OP1_DSX:
|
||||||
|
assert(type_is_float(dst_type));
|
||||||
|
write_sm4_unary_op(buffer, VKD3D_SM4_OP_DERIV_RTX, &expr->node, arg1, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HLSL_OP1_DSY:
|
||||||
|
assert(type_is_float(dst_type));
|
||||||
|
write_sm4_unary_op(buffer, VKD3D_SM4_OP_DERIV_RTY, &expr->node, arg1, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
case HLSL_OP1_EXP2:
|
case HLSL_OP1_EXP2:
|
||||||
assert(type_is_float(dst_type));
|
assert(type_is_float(dst_type));
|
||||||
write_sm4_unary_op(buffer, VKD3D_SM4_OP_EXP, &expr->node, arg1, 0);
|
write_sm4_unary_op(buffer, VKD3D_SM4_OP_EXP, &expr->node, arg1, 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user