[PATCH vkd3d v2 6/7] vkd3d-shader/hlsl: Parse the ldexp() intrinsic.
Giovanni Mascellani
gmascellani at codeweavers.com
Fri Jun 24 02:41:29 CDT 2022
From: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani at codeweavers.com>
---
libs/vkd3d-shader/hlsl.y | 15 +++++++++++++++
tests/hlsl-ldexp.shader_test | 4 ++--
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y
index 391cf890..7469b525 100644
--- a/libs/vkd3d-shader/hlsl.y
+++ b/libs/vkd3d-shader/hlsl.y
@@ -2095,6 +2095,20 @@ static bool intrinsic_floor(struct hlsl_ctx *ctx,
return !!add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_FLOOR, arg, loc);
}
+static bool intrinsic_ldexp(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[1], loc)))
+ return false;
+
+ if (!(arg = add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_EXP2, arg, loc)))
+ return false;
+
+ return !!add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MUL, params->args[0], arg, loc);
+}
+
static bool intrinsic_max(struct hlsl_ctx *ctx,
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
{
@@ -2283,6 +2297,7 @@ intrinsic_functions[] =
{"cross", 2, true, intrinsic_cross},
{"dot", 2, true, intrinsic_dot},
{"floor", 1, true, intrinsic_floor},
+ {"ldexp", 2, true, intrinsic_ldexp},
{"max", 2, true, intrinsic_max},
{"min", 2, true, intrinsic_min},
{"mul", 2, true, intrinsic_mul},
diff --git a/tests/hlsl-ldexp.shader_test b/tests/hlsl-ldexp.shader_test
index 46b87a38..0873fc9e 100644
--- a/tests/hlsl-ldexp.shader_test
+++ b/tests/hlsl-ldexp.shader_test
@@ -10,7 +10,7 @@ float4 main() : SV_TARGET
[test]
uniform 0 float4 2.0 3.0 4.0 5.0
uniform 4 float4 0.0 -10.0 10.0 100.0
-todo draw quad
+draw quad
probe all rgba (2.0, 0.00292968750, 4096.0, 6.33825300e+030)
[require]
@@ -28,5 +28,5 @@ float4 main() : SV_TARGET
[test]
uniform 0 int4 2 3 4 5
uniform 4 int4 0 -10 10 100
-todo draw quad
+draw quad
probe all rgba (2.0, 0.00292968750, 4096.0, 6.33825300e+030)
--
2.36.1
More information about the wine-devel
mailing list