From: Francisco Casas fcasas@codeweavers.com
--- libs/vkd3d-shader/hlsl.y | 12 ++++++++++++ tests/sqrt.shader_test | 6 +++--- 2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 6beb80e4..f56df476 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -2783,6 +2783,17 @@ static bool intrinsic_smoothstep(struct hlsl_ctx *ctx, 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, const struct parse_initializer *params, const struct vkd3d_shader_location *loc) { @@ -2871,6 +2882,7 @@ intrinsic_functions[] = {"saturate", 1, true, intrinsic_saturate}, {"sin", 1, true, intrinsic_sin}, {"smoothstep", 3, true, intrinsic_smoothstep}, + {"sqrt", 1, true, intrinsic_sqrt}, {"transpose", 1, true, intrinsic_transpose}, };
diff --git a/tests/sqrt.shader_test b/tests/sqrt.shader_test index 81bf99a4..5d048b4f 100644 --- a/tests/sqrt.shader_test +++ b/tests/sqrt.shader_test @@ -1,4 +1,4 @@ -[pixel shader todo] +[pixel shader] uniform float4 f;
float4 main() : sv_target @@ -8,5 +8,5 @@ float4 main() : sv_target
[test] uniform 0 float4 1.0 9.0 32.3 46.5 -todo draw quad -todo probe all rgba (1.0, 3.0, 5.683309, 6.819091) 1 +draw quad +probe all rgba (1.0, 3.0, 5.683309, 6.819091) 1