mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/hlsl: Add radians() function.
This commit is contained in:
parent
88caf87789
commit
e493627130
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
@ -46,6 +46,7 @@ vkd3d_cross_tests = \
|
|||||||
vkd3d_shader_tests = \
|
vkd3d_shader_tests = \
|
||||||
tests/hlsl/abs.shader_test \
|
tests/hlsl/abs.shader_test \
|
||||||
tests/hlsl/all.shader_test \
|
tests/hlsl/all.shader_test \
|
||||||
|
tests/hlsl/angle-unit.shader_test \
|
||||||
tests/hlsl/any.shader_test \
|
tests/hlsl/any.shader_test \
|
||||||
tests/hlsl/arithmetic-float-uniform.shader_test \
|
tests/hlsl/arithmetic-float-uniform.shader_test \
|
||||||
tests/hlsl/arithmetic-float.shader_test \
|
tests/hlsl/arithmetic-float.shader_test \
|
||||||
|
@ -3341,6 +3341,22 @@ static bool intrinsic_pow(struct hlsl_ctx *ctx,
|
|||||||
return !!add_pow_expr(ctx, params->instrs, params->args[0], params->args[1], loc);
|
return !!add_pow_expr(ctx, params->instrs, params->args[0], params->args[1], loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool intrinsic_radians(struct hlsl_ctx *ctx,
|
||||||
|
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
|
||||||
|
{
|
||||||
|
struct hlsl_ir_node *arg, *rad;
|
||||||
|
|
||||||
|
if (!(arg = intrinsic_float_convert_arg(ctx, params, params->args[0], loc)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
/* 1 degree = pi/180 rad = 0.0174532925f rad */
|
||||||
|
if (!(rad = hlsl_new_float_constant(ctx, 0.0174532925f, loc)))
|
||||||
|
return false;
|
||||||
|
hlsl_block_add_instr(params->instrs, rad);
|
||||||
|
|
||||||
|
return !!add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MUL, arg, rad, loc);
|
||||||
|
}
|
||||||
|
|
||||||
static bool intrinsic_reflect(struct hlsl_ctx *ctx,
|
static bool intrinsic_reflect(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)
|
||||||
{
|
{
|
||||||
@ -3869,6 +3885,7 @@ intrinsic_functions[] =
|
|||||||
{"mul", 2, true, intrinsic_mul},
|
{"mul", 2, true, intrinsic_mul},
|
||||||
{"normalize", 1, true, intrinsic_normalize},
|
{"normalize", 1, true, intrinsic_normalize},
|
||||||
{"pow", 2, true, intrinsic_pow},
|
{"pow", 2, true, intrinsic_pow},
|
||||||
|
{"radians", 1, true, intrinsic_radians},
|
||||||
{"reflect", 2, true, intrinsic_reflect},
|
{"reflect", 2, true, intrinsic_reflect},
|
||||||
{"round", 1, true, intrinsic_round},
|
{"round", 1, true, intrinsic_round},
|
||||||
{"rsqrt", 1, true, intrinsic_rsqrt},
|
{"rsqrt", 1, true, intrinsic_rsqrt},
|
||||||
|
12
tests/hlsl/angle-unit.shader_test
Normal file
12
tests/hlsl/angle-unit.shader_test
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
[pixel shader]
|
||||||
|
uniform float4 a;
|
||||||
|
|
||||||
|
float4 main() : sv_target
|
||||||
|
{
|
||||||
|
return radians(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
[test]
|
||||||
|
uniform 0 float4 0.0 30.0 150.0 180.0
|
||||||
|
draw quad
|
||||||
|
probe all rgba (0.0, 0.52359877, 2.61799387, 3.14159265)
|
Loading…
Reference in New Issue
Block a user