Zebediah Figura : vkd3d-shader/hlsl: Parse the saturate() intrinsic.
Alexandre Julliard
julliard at winehq.org
Fri Sep 17 15:56:54 CDT 2021
Module: vkd3d
Branch: master
Commit: f0955c164a87b7099e556489ebeef90a847e8418
URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=f0955c164a87b7099e556489ebeef90a847e8418
Author: Zebediah Figura <zfigura at codeweavers.com>
Date: Thu Sep 16 20:55:56 2021 +0200
vkd3d-shader/hlsl: Parse the saturate() intrinsic.
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
Makefile.am | 2 ++
libs/vkd3d-shader/hlsl.y | 9 +++++++++
tests/saturate.shader_test | 10 ++++++++++
3 files changed, 21 insertions(+)
diff --git a/Makefile.am b/Makefile.am
index 67dcbba..45db1a1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -87,6 +87,7 @@ vkd3d_shader_tests = \
tests/preproc-invalid.shader_test \
tests/preproc-macro.shader_test \
tests/preproc-misc.shader_test \
+ tests/saturate.shader_test \
tests/swizzle-0.shader_test \
tests/swizzle-1.shader_test \
tests/swizzle-2.shader_test \
@@ -295,6 +296,7 @@ XFAIL_TESTS = \
tests/hlsl-vector-indexing-uniform.shader_test \
tests/math.shader_test \
tests/max.shader_test \
+ tests/saturate.shader_test \
tests/trigonometry.shader_test \
tests/writemask-assignop-1.shader_test
endif
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y
index 8f63472..fe3c328 100644
--- a/libs/vkd3d-shader/hlsl.y
+++ b/libs/vkd3d-shader/hlsl.y
@@ -1577,6 +1577,14 @@ static bool intrinsic_max(struct hlsl_ctx *ctx,
return !!add_expr(ctx, params->instrs, HLSL_OP2_MAX, args, &loc);
}
+static bool intrinsic_saturate(struct hlsl_ctx *ctx,
+ const struct parse_initializer *params, struct vkd3d_shader_location loc)
+{
+ struct hlsl_ir_node *args[3] = {params->args[0]};
+
+ return !!add_expr(ctx, params->instrs, HLSL_OP1_SAT, args, &loc);
+}
+
static const struct intrinsic_function
{
const char *name;
@@ -1588,6 +1596,7 @@ intrinsic_functions[] =
{
{"clamp", 3, true, intrinsic_clamp},
{"max", 2, true, intrinsic_max},
+ {"saturate", 1, true, intrinsic_saturate},
};
static int intrinsic_function_name_compare(const void *a, const void *b)
diff --git a/tests/saturate.shader_test b/tests/saturate.shader_test
new file mode 100644
index 0000000..0a954e7
--- /dev/null
+++ b/tests/saturate.shader_test
@@ -0,0 +1,10 @@
+[pixel shader]
+float4 main(uniform float2 u) : sv_target
+{
+ return float4(saturate(u), saturate(u.x + 0.5), saturate(-1.2));
+}
+
+[test]
+uniform 0 float4 0.7 -0.1 0.0 0.0
+draw quad
+probe all rgba (0.7, 0.0, 1.0, 0.0)
More information about the wine-cvs
mailing list