Skip to content
Snippets Groups Projects
Commit aed2d142 authored by Akihiro Sagawa's avatar Akihiro Sagawa Committed by Alexandre Julliard
Browse files

vkd3d-shader/hlsl: Add degrees() function.

parent e4936271
No related branches found
No related tags found
1 merge request!475vkd3d-shader/hlsl: Add radians() and degrees() functions.
......@@ -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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment