mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/hlsl: Add degrees() function.
This commit is contained in:
parent
e493627130
commit
aed2d142cf
Notes:
Alexandre Julliard
2023-11-20 22:31:44 +01:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Francisco Casas (@fcasas) 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/475
@ -2878,6 +2878,22 @@ 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_degrees(struct hlsl_ctx *ctx,
|
||||
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
|
||||
{
|
||||
struct hlsl_ir_node *arg, *deg;
|
||||
|
||||
if (!(arg = intrinsic_float_convert_arg(ctx, params, params->args[0], loc)))
|
||||
return false;
|
||||
|
||||
/* 1 rad = 180/pi degree = 57.2957795 degree */
|
||||
if (!(deg = hlsl_new_float_constant(ctx, 57.2957795f, loc)))
|
||||
return false;
|
||||
hlsl_block_add_instr(params->instrs, deg);
|
||||
|
||||
return !!add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MUL, arg, deg, loc);
|
||||
}
|
||||
|
||||
static bool intrinsic_ddy_fine(struct hlsl_ctx *ctx,
|
||||
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
|
||||
{
|
||||
@ -3865,6 +3881,7 @@ intrinsic_functions[] =
|
||||
{"ddy", 1, true, intrinsic_ddy},
|
||||
{"ddy_coarse", 1, true, intrinsic_ddy_coarse},
|
||||
{"ddy_fine", 1, true, intrinsic_ddy_fine},
|
||||
{"degrees", 1, true, intrinsic_degrees},
|
||||
{"distance", 2, true, intrinsic_distance},
|
||||
{"dot", 2, true, intrinsic_dot},
|
||||
{"exp", 1, true, intrinsic_exp},
|
||||
|
@ -10,3 +10,17 @@ float4 main() : sv_target
|
||||
uniform 0 float4 0.0 30.0 150.0 180.0
|
||||
draw quad
|
||||
probe all rgba (0.0, 0.52359877, 2.61799387, 3.14159265)
|
||||
|
||||
|
||||
[pixel shader]
|
||||
uniform float4 a;
|
||||
|
||||
float4 main() : sv_target
|
||||
{
|
||||
return degrees(a);
|
||||
}
|
||||
|
||||
[test]
|
||||
uniform 0 float4 0.0 0.78539816 1.57079632 2.35619449
|
||||
draw quad
|
||||
probe all rgba (0.0, 45.0, 90.0, 135.0)
|
||||
|
Loading…
Reference in New Issue
Block a user