vkd3d-shader/hlsl: Parse sqrt() intrinsic.

This commit is contained in:
Francisco Casas 2023-01-13 15:58:15 -03:00 committed by Alexandre Julliard
parent 7dbc879e2d
commit 6fbf2b3e75
Notes: Alexandre Julliard 2023-01-19 22:45:36 +01: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/62
2 changed files with 15 additions and 3 deletions

View File

@ -2817,6 +2817,17 @@ static bool intrinsic_smoothstep(struct hlsl_ctx *ctx,
return true; return true;
} }
static bool intrinsic_sqrt(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_SQRT, arg, loc);
}
static bool intrinsic_transpose(struct hlsl_ctx *ctx, static bool intrinsic_transpose(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)
{ {
@ -2905,6 +2916,7 @@ intrinsic_functions[] =
{"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},
{"sqrt", 1, true, intrinsic_sqrt},
{"transpose", 1, true, intrinsic_transpose}, {"transpose", 1, true, intrinsic_transpose},
}; };

View File

@ -1,4 +1,4 @@
[pixel shader todo] [pixel shader]
uniform float4 f; uniform float4 f;
float4 main() : sv_target float4 main() : sv_target
@ -8,5 +8,5 @@ float4 main() : sv_target
[test] [test]
uniform 0 float4 1.0 9.0 32.3 46.5 uniform 0 float4 1.0 9.0 32.3 46.5
todo draw quad draw quad
todo probe all rgba (1.0, 3.0, 5.683309, 6.819091) 1 probe all rgba (1.0, 3.0, 5.683309, 6.819091) 1