vkd3d-shader/hlsl: Support rsqrt() intrinsic.

This commit is contained in:
Nikolay Sivov 2023-01-27 19:07:10 +03:00 committed by Alexandre Julliard
parent 6ccde9e82c
commit d6b656641c
Notes: Alexandre Julliard 2023-03-08 21:51:08 +01:00
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/76
2 changed files with 25 additions and 0 deletions

View File

@ -2941,6 +2941,17 @@ static bool intrinsic_round(struct hlsl_ctx *ctx,
return !!add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_ROUND, arg, loc); return !!add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_ROUND, arg, loc);
} }
static bool intrinsic_rsqrt(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_RSQ, arg, loc);
}
static bool intrinsic_saturate(struct hlsl_ctx *ctx, static bool intrinsic_saturate(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)
{ {
@ -3208,6 +3219,7 @@ intrinsic_functions[] =
{"pow", 2, true, intrinsic_pow}, {"pow", 2, true, intrinsic_pow},
{"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},
{"saturate", 1, true, intrinsic_saturate}, {"saturate", 1, true, intrinsic_saturate},
{"sin", 1, true, intrinsic_sin}, {"sin", 1, true, intrinsic_sin},
{"smoothstep", 3, true, intrinsic_smoothstep}, {"smoothstep", 3, true, intrinsic_smoothstep},

View File

@ -10,3 +10,16 @@ float4 main() : sv_target
uniform 0 float4 1.0 9.0 32.3 46.5 uniform 0 float4 1.0 9.0 32.3 46.5
draw quad draw quad
probe all rgba (1.0, 3.0, 5.683309, 6.819091) 1 probe all rgba (1.0, 3.0, 5.683309, 6.819091) 1
[pixel shader]
uniform float4 f;
float4 main() : sv_target
{
return rsqrt(f);
}
[test]
uniform 0 float4 1.0 9.0 4.0 16.0
draw quad
probe all rgba (1.0, 0.33333333, 0.5, 0.25) 1