mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d-shader/hlsl: Support fine derivates.
This commit is contained in:
parent
ff31284f8d
commit
e4d94d955c
Notes:
Alexandre Julliard
2023-07-04 23:24:52 +02:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Zebediah Figura (@zfigura) Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/224
@ -2340,8 +2340,10 @@ const char *debug_hlsl_expr_op(enum hlsl_ir_expr_op op)
|
||||
[HLSL_OP1_COS_REDUCED] = "cos_reduced",
|
||||
[HLSL_OP1_DSX] = "dsx",
|
||||
[HLSL_OP1_DSX_COARSE] = "dsx_coarse",
|
||||
[HLSL_OP1_DSX_FINE] = "dsx_fine",
|
||||
[HLSL_OP1_DSY] = "dsy",
|
||||
[HLSL_OP1_DSY_COARSE] = "dsy_coarse",
|
||||
[HLSL_OP1_DSY_FINE] = "dsy_fine",
|
||||
[HLSL_OP1_EXP2] = "exp2",
|
||||
[HLSL_OP1_FRACT] = "fract",
|
||||
[HLSL_OP1_LOG2] = "log2",
|
||||
|
@ -503,8 +503,10 @@ enum hlsl_ir_expr_op
|
||||
HLSL_OP1_COS_REDUCED, /* Reduced range [-pi, pi] */
|
||||
HLSL_OP1_DSX,
|
||||
HLSL_OP1_DSX_COARSE,
|
||||
HLSL_OP1_DSX_FINE,
|
||||
HLSL_OP1_DSY,
|
||||
HLSL_OP1_DSY_COARSE,
|
||||
HLSL_OP1_DSY_FINE,
|
||||
HLSL_OP1_EXP2,
|
||||
HLSL_OP1_FLOOR,
|
||||
HLSL_OP1_FRACT,
|
||||
|
@ -2681,6 +2681,17 @@ static bool intrinsic_ddx_coarse(struct hlsl_ctx *ctx,
|
||||
return !!add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_DSX_COARSE, arg, loc);
|
||||
}
|
||||
|
||||
static bool intrinsic_ddx_fine(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_FINE, arg, loc);
|
||||
}
|
||||
|
||||
static bool intrinsic_ddy(struct hlsl_ctx *ctx,
|
||||
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
|
||||
{
|
||||
@ -2703,6 +2714,17 @@ static bool intrinsic_ddy_coarse(struct hlsl_ctx *ctx,
|
||||
return !!add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_DSY_COARSE, arg, loc);
|
||||
}
|
||||
|
||||
static bool intrinsic_ddy_fine(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_FINE, arg, loc);
|
||||
}
|
||||
|
||||
static bool intrinsic_distance(struct hlsl_ctx *ctx,
|
||||
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
|
||||
{
|
||||
@ -3564,8 +3586,10 @@ intrinsic_functions[] =
|
||||
{"cross", 2, true, intrinsic_cross},
|
||||
{"ddx", 1, true, intrinsic_ddx},
|
||||
{"ddx_coarse", 1, true, intrinsic_ddx_coarse},
|
||||
{"ddx_fine", 1, true, intrinsic_ddx_fine},
|
||||
{"ddy", 1, true, intrinsic_ddy},
|
||||
{"ddy_coarse", 1, true, intrinsic_ddy_coarse},
|
||||
{"ddy_fine", 1, true, intrinsic_ddy_fine},
|
||||
{"distance", 2, true, intrinsic_distance},
|
||||
{"dot", 2, true, intrinsic_dot},
|
||||
{"exp", 1, true, intrinsic_exp},
|
||||
|
@ -4375,6 +4375,11 @@ static void write_sm4_expr(struct hlsl_ctx *ctx,
|
||||
write_sm4_unary_op(buffer, VKD3D_SM5_OP_DERIV_RTX_COARSE, &expr->node, arg1, 0);
|
||||
break;
|
||||
|
||||
case HLSL_OP1_DSX_FINE:
|
||||
assert(type_is_float(dst_type));
|
||||
write_sm4_unary_op(buffer, VKD3D_SM5_OP_DERIV_RTX_FINE, &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);
|
||||
@ -4385,6 +4390,11 @@ static void write_sm4_expr(struct hlsl_ctx *ctx,
|
||||
write_sm4_unary_op(buffer, VKD3D_SM5_OP_DERIV_RTY_COARSE, &expr->node, arg1, 0);
|
||||
break;
|
||||
|
||||
case HLSL_OP1_DSY_FINE:
|
||||
assert(type_is_float(dst_type));
|
||||
write_sm4_unary_op(buffer, VKD3D_SM5_OP_DERIV_RTY_FINE, &expr->node, arg1, 0);
|
||||
break;
|
||||
|
||||
case HLSL_OP1_EXP2:
|
||||
assert(type_is_float(dst_type));
|
||||
write_sm4_unary_op(buffer, VKD3D_SM4_OP_EXP, &expr->node, arg1, 0);
|
||||
|
@ -65,7 +65,7 @@ probe (16, 16) rgba (-25.0, -7.0, 5.0, 0.0)
|
||||
probe (150, 150) rgba (-226.0, -47.0, 45.0, 0.0)
|
||||
|
||||
|
||||
[pixel shader todo]
|
||||
[pixel shader]
|
||||
float4 main(float4 pos : sv_position) : sv_target
|
||||
{
|
||||
pos /= 10.0;
|
||||
@ -74,7 +74,7 @@ float4 main(float4 pos : sv_position) : sv_target
|
||||
}
|
||||
|
||||
[test]
|
||||
todo draw quad
|
||||
draw quad
|
||||
probe (10, 10) rgba (-0.524999976, -0.164999843, 0.104999900, 0.0) 16
|
||||
probe (11, 10) rgba (-0.689999819, -0.164999843, 0.114999890, 0.0) 32
|
||||
probe (10, 11) rgba (-0.420000076, -0.154999852, 0.104999900, 0.0) 32
|
||||
|
Loading…
x
Reference in New Issue
Block a user