Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- Makefile.am | 2 ++ libs/vkd3d-shader/hlsl.y | 9 +++++++++ tests/abs.shader_test | 13 +++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 tests/abs.shader_test
diff --git a/Makefile.am b/Makefile.am index c9ad38893..3287ec75a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -54,6 +54,7 @@ vkd3d_shader_runners = \ tests/shader_runner_d3d12
vkd3d_shader_tests = \ + tests/abs.shader_test \ tests/cast-to-float.shader_test \ tests/cast-to-half.shader_test \ tests/cast-to-int.shader_test \ @@ -273,6 +274,7 @@ tests_vkd3d_api_LDADD = libvkd3d.la @VULKAN_LIBS@ tests_vkd3d_shader_api_LDADD = libvkd3d-shader.la SHADER_TEST_LOG_COMPILER = tests/shader_runner_d3d12 XFAIL_TESTS = \ + tests/abs.shader_test \ tests/cast-to-float.shader_test \ tests/cast-to-half.shader_test \ tests/cast-to-int.shader_test \ diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index fe3c3289d..bd2660389 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -1555,6 +1555,14 @@ static const struct hlsl_ir_function_decl *find_function_call(struct hlsl_ctx *c return args.decl; }
+static bool intrinsic_abs(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_ABS, args, &loc); +} + static bool intrinsic_clamp(struct hlsl_ctx *ctx, const struct parse_initializer *params, struct vkd3d_shader_location loc) { @@ -1594,6 +1602,7 @@ static const struct intrinsic_function } intrinsic_functions[] = { + {"abs", 1, true, intrinsic_abs}, {"clamp", 3, true, intrinsic_clamp}, {"max", 2, true, intrinsic_max}, {"saturate", 1, true, intrinsic_saturate}, diff --git a/tests/abs.shader_test b/tests/abs.shader_test new file mode 100644 index 000000000..6fa6d1ca7 --- /dev/null +++ b/tests/abs.shader_test @@ -0,0 +1,13 @@ +[pixel shader] +float4 main(uniform float2 u) : sv_target +{ + return float4(abs(u), abs(u.x - 0.5), abs(-0.4)); +} + +[test] +uniform 0 float4 0.1 0.7 0.0 0.0 +draw quad +probe all rgba (0.1, 0.7, 0.4, 0.4) +uniform 0 float4 -0.7 0.1 0.0 0.0 +draw quad +probe all rgba (0.7, 0.1, 1.2, 0.4)
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- Makefile.am | 1 - libs/vkd3d-shader/hlsl_sm4.c | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/Makefile.am b/Makefile.am index 3287ec75a..32b76e19d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -274,7 +274,6 @@ tests_vkd3d_api_LDADD = libvkd3d.la @VULKAN_LIBS@ tests_vkd3d_shader_api_LDADD = libvkd3d-shader.la SHADER_TEST_LOG_COMPILER = tests/shader_runner_d3d12 XFAIL_TESTS = \ - tests/abs.shader_test \ tests/cast-to-float.shader_test \ tests/cast-to-half.shader_test \ tests/cast-to-int.shader_test \ diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index 8a1d36322..5aefc7e89 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -982,6 +982,10 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, { switch (expr->op) { + case HLSL_OP1_ABS: + write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV, &expr->node, arg1, VKD3D_SM4_REGISTER_MODIFIER_ABS); + break; + case HLSL_OP1_CAST: { const struct hlsl_type *src_type = arg1->data_type;
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
Il 17/09/21 23:06, Zebediah Figura ha scritto:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
Makefile.am | 1 - libs/vkd3d-shader/hlsl_sm4.c | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/Makefile.am b/Makefile.am index 3287ec75a..32b76e19d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -274,7 +274,6 @@ tests_vkd3d_api_LDADD = libvkd3d.la @VULKAN_LIBS@ tests_vkd3d_shader_api_LDADD = libvkd3d-shader.la SHADER_TEST_LOG_COMPILER = tests/shader_runner_d3d12 XFAIL_TESTS = \
- tests/abs.shader_test \ tests/cast-to-float.shader_test \ tests/cast-to-half.shader_test \ tests/cast-to-int.shader_test \
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index 8a1d36322..5aefc7e89 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -982,6 +982,10 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, { switch (expr->op) {
case HLSL_OP1_ABS:
write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV, &expr->node, arg1, VKD3D_SM4_REGISTER_MODIFIER_ABS);
break;
case HLSL_OP1_CAST: { const struct hlsl_type *src_type = arg1->data_type;
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- Makefile.am | 2 ++ libs/vkd3d-shader/hlsl.c | 1 - libs/vkd3d-shader/hlsl.h | 1 - libs/vkd3d-shader/hlsl.y | 23 +++++++++++++++++++++++ tests/pow.shader_test | 10 ++++++++++ 5 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 tests/pow.shader_test
diff --git a/Makefile.am b/Makefile.am index 32b76e19d..34617c672 100644 --- a/Makefile.am +++ b/Makefile.am @@ -82,6 +82,7 @@ vkd3d_shader_tests = \ tests/hlsl-vector-indexing-uniform.shader_test \ tests/math.shader_test \ tests/max.shader_test \ + tests/pow.shader_test \ tests/preproc-if.shader_test \ tests/preproc-ifdef.shader_test \ tests/preproc-if-expr.shader_test \ @@ -297,6 +298,7 @@ XFAIL_TESTS = \ tests/hlsl-vector-indexing-uniform.shader_test \ tests/math.shader_test \ tests/max.shader_test \ + tests/pow.shader_test \ tests/trigonometry.shader_test \ tests/writemask-assignop-1.shader_test endif diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index 0d5396003..96473d057 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -1093,7 +1093,6 @@ const char *debug_hlsl_expr_op(enum hlsl_ir_expr_op op) [HLSL_OP2_MOD] = "%", [HLSL_OP2_MUL] = "*", [HLSL_OP2_NEQUAL] = "!=", - [HLSL_OP2_POW] = "pow", [HLSL_OP2_RSHIFT] = ">>",
[HLSL_OP3_LERP] = "lerp", diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 9b579b724..ce1f1b756 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -318,7 +318,6 @@ enum hlsl_ir_expr_op HLSL_OP2_MOD, HLSL_OP2_MUL, HLSL_OP2_NEQUAL, - HLSL_OP2_POW, HLSL_OP2_RSHIFT,
HLSL_OP3_LERP, diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index bd2660389..2b381dc8a 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -1585,6 +1585,28 @@ static bool intrinsic_max(struct hlsl_ctx *ctx, return !!add_expr(ctx, params->instrs, HLSL_OP2_MAX, args, &loc); }
+static bool intrinsic_pow(struct hlsl_ctx *ctx, + const struct parse_initializer *params, struct vkd3d_shader_location loc) +{ + struct hlsl_ir_node *args[3] = {0}; + struct hlsl_ir_node *log, *exp; + struct hlsl_ir_expr *mul; + + if (!(log = hlsl_new_unary_expr(ctx, HLSL_OP1_LOG2, params->args[0], loc))) + return false; + list_add_tail(params->instrs, &log->entry); + + args[0] = params->args[1]; + args[1] = log; + if (!(mul = add_expr(ctx, params->instrs, HLSL_OP2_MUL, args, &loc))) + return false; + + if (!(exp = hlsl_new_unary_expr(ctx, HLSL_OP1_EXP2, &mul->node, loc))) + return false; + list_add_tail(params->instrs, &exp->entry); + return true; +} + static bool intrinsic_saturate(struct hlsl_ctx *ctx, const struct parse_initializer *params, struct vkd3d_shader_location loc) { @@ -1605,6 +1627,7 @@ intrinsic_functions[] = {"abs", 1, true, intrinsic_abs}, {"clamp", 3, true, intrinsic_clamp}, {"max", 2, true, intrinsic_max}, + {"pow", 2, true, intrinsic_pow}, {"saturate", 1, true, intrinsic_saturate}, };
diff --git a/tests/pow.shader_test b/tests/pow.shader_test new file mode 100644 index 000000000..aa6df21ca --- /dev/null +++ b/tests/pow.shader_test @@ -0,0 +1,10 @@ +[pixel shader] +float4 main(uniform float2 u, uniform float2 v) : sv_target +{ + return float4(pow(u.y, 3), pow(u, v), pow(0.5, v.y)); +} + +[test] +uniform 0 float4 0.4 0.8 2.5 2.0 +draw quad +probe all rgba (0.512, 0.101192884, 0.64, 0.25)
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- I guess native never generates pow() on SM1?
Nice test, it does show that the native compiler is pretty smart with this.
On 9/19/21 1:00 PM, Matteo Bruni wrote:
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
I guess native never generates pow() on SM1?
Nice test, it does show that the native compiler is pretty smart with this.
I couldn't easily find a way to get it to generate the pow instruction, no.
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
Il 17/09/21 23:06, Zebediah Figura ha scritto:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
Makefile.am | 2 ++ libs/vkd3d-shader/hlsl.c | 1 - libs/vkd3d-shader/hlsl.h | 1 - libs/vkd3d-shader/hlsl.y | 23 +++++++++++++++++++++++ tests/pow.shader_test | 10 ++++++++++ 5 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 tests/pow.shader_test
diff --git a/Makefile.am b/Makefile.am index 32b76e19d..34617c672 100644 --- a/Makefile.am +++ b/Makefile.am @@ -82,6 +82,7 @@ vkd3d_shader_tests = \ tests/hlsl-vector-indexing-uniform.shader_test \ tests/math.shader_test \ tests/max.shader_test \
- tests/pow.shader_test \ tests/preproc-if.shader_test \ tests/preproc-ifdef.shader_test \ tests/preproc-if-expr.shader_test \
@@ -297,6 +298,7 @@ XFAIL_TESTS = \ tests/hlsl-vector-indexing-uniform.shader_test \ tests/math.shader_test \ tests/max.shader_test \
- tests/pow.shader_test \ tests/trigonometry.shader_test \ tests/writemask-assignop-1.shader_test endif
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index 0d5396003..96473d057 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -1093,7 +1093,6 @@ const char *debug_hlsl_expr_op(enum hlsl_ir_expr_op op) [HLSL_OP2_MOD] = "%", [HLSL_OP2_MUL] = "*", [HLSL_OP2_NEQUAL] = "!=",
[HLSL_OP2_POW] = "pow", [HLSL_OP2_RSHIFT] = ">>", [HLSL_OP3_LERP] = "lerp",
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 9b579b724..ce1f1b756 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -318,7 +318,6 @@ enum hlsl_ir_expr_op HLSL_OP2_MOD, HLSL_OP2_MUL, HLSL_OP2_NEQUAL,
HLSL_OP2_POW, HLSL_OP2_RSHIFT,
HLSL_OP3_LERP,
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index bd2660389..2b381dc8a 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -1585,6 +1585,28 @@ static bool intrinsic_max(struct hlsl_ctx *ctx, return !!add_expr(ctx, params->instrs, HLSL_OP2_MAX, args, &loc); }
+static bool intrinsic_pow(struct hlsl_ctx *ctx,
const struct parse_initializer *params, struct vkd3d_shader_location loc)
+{
- struct hlsl_ir_node *args[3] = {0};
- struct hlsl_ir_node *log, *exp;
- struct hlsl_ir_expr *mul;
- if (!(log = hlsl_new_unary_expr(ctx, HLSL_OP1_LOG2, params->args[0], loc)))
return false;
- list_add_tail(params->instrs, &log->entry);
- args[0] = params->args[1];
- args[1] = log;
- if (!(mul = add_expr(ctx, params->instrs, HLSL_OP2_MUL, args, &loc)))
return false;
- if (!(exp = hlsl_new_unary_expr(ctx, HLSL_OP1_EXP2, &mul->node, loc)))
return false;
- list_add_tail(params->instrs, &exp->entry);
- return true;
+}
- static bool intrinsic_saturate(struct hlsl_ctx *ctx, const struct parse_initializer *params, struct vkd3d_shader_location loc) {
@@ -1605,6 +1627,7 @@ intrinsic_functions[] = {"abs", 1, true, intrinsic_abs}, {"clamp", 3, true, intrinsic_clamp}, {"max", 2, true, intrinsic_max},
- {"pow", 2, true, intrinsic_pow}, {"saturate", 1, true, intrinsic_saturate}, };
diff --git a/tests/pow.shader_test b/tests/pow.shader_test new file mode 100644 index 000000000..aa6df21ca --- /dev/null +++ b/tests/pow.shader_test @@ -0,0 +1,10 @@ +[pixel shader] +float4 main(uniform float2 u, uniform float2 v) : sv_target +{
- return float4(pow(u.y, 3), pow(u, v), pow(0.5, v.y));
+}
+[test] +uniform 0 float4 0.4 0.8 2.5 2.0 +draw quad +probe all rgba (0.512, 0.101192884, 0.64, 0.25)
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/hlsl_sm4.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index 5aefc7e89..ca4e7eb6b 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1023,6 +1023,10 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, break; }
+ case HLSL_OP1_LOG2: + write_sm4_unary_op(buffer, VKD3D_SM4_OP_LOG, &expr->node, arg1, 0); + break; + case HLSL_OP1_NEG: write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV, &expr->node, arg1, VKD3D_SM4_REGISTER_MODIFIER_NEGATE); break;
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
Il 17/09/21 23:06, Zebediah Figura ha scritto:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
libs/vkd3d-shader/hlsl_sm4.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index 5aefc7e89..ca4e7eb6b 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1023,6 +1023,10 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, break; }
case HLSL_OP1_LOG2:
write_sm4_unary_op(buffer, VKD3D_SM4_OP_LOG, &expr->node, arg1, 0);
break;
case HLSL_OP1_NEG: write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV, &expr->node, arg1, VKD3D_SM4_REGISTER_MODIFIER_NEGATE); break;
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- Makefile.am | 1 - libs/vkd3d-shader/hlsl_sm4.c | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/Makefile.am b/Makefile.am index 34617c672..4a2bf8e18 100644 --- a/Makefile.am +++ b/Makefile.am @@ -298,7 +298,6 @@ XFAIL_TESTS = \ tests/hlsl-vector-indexing-uniform.shader_test \ tests/math.shader_test \ tests/max.shader_test \ - tests/pow.shader_test \ tests/trigonometry.shader_test \ tests/writemask-assignop-1.shader_test endif diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index ca4e7eb6b..b347e3526 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1023,6 +1023,10 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, break; }
+ case HLSL_OP1_EXP2: + write_sm4_unary_op(buffer, VKD3D_SM4_OP_EXP, &expr->node, arg1, 0); + break; + case HLSL_OP1_LOG2: write_sm4_unary_op(buffer, VKD3D_SM4_OP_LOG, &expr->node, arg1, 0); break;
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Hi,
Il 17/09/21 23:06, Zebediah Figura ha scritto:
diff --git a/Makefile.am b/Makefile.am index 34617c672..4a2bf8e18 100644 --- a/Makefile.am +++ b/Makefile.am @@ -298,7 +298,6 @@ XFAIL_TESTS = \ tests/hlsl-vector-indexing-uniform.shader_test \ tests/math.shader_test \ tests/max.shader_test \
- tests/pow.shader_test \ tests/trigonometry.shader_test \ tests/writemask-assignop-1.shader_test endif
Test pow.shader_test doesn't pass on my machine, on both video cards. On the NVIDIA card I need at least 3 ULPs of allowance to have it pass, on the Intel card 2 ULPs are enough. I would suggest to allow 3 ULPs, to avoid spurious errors.
On another computer with an AMD video card the test runs just fine.
Giovanni.
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
Il 17/09/21 23:06, Zebediah Figura ha scritto:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
Makefile.am | 1 - libs/vkd3d-shader/hlsl_sm4.c | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/Makefile.am b/Makefile.am index 34617c672..4a2bf8e18 100644 --- a/Makefile.am +++ b/Makefile.am @@ -298,7 +298,6 @@ XFAIL_TESTS = \ tests/hlsl-vector-indexing-uniform.shader_test \ tests/math.shader_test \ tests/max.shader_test \
- tests/pow.shader_test \ tests/trigonometry.shader_test \ tests/writemask-assignop-1.shader_test endif
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index ca4e7eb6b..b347e3526 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1023,6 +1023,10 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, break; }
case HLSL_OP1_EXP2:
write_sm4_unary_op(buffer, VKD3D_SM4_OP_EXP, &expr->node, arg1, 0);
break;
case HLSL_OP1_LOG2: write_sm4_unary_op(buffer, VKD3D_SM4_OP_LOG, &expr->node, arg1, 0); break;
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
Il 17/09/21 23:06, Zebediah Figura ha scritto:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
Makefile.am | 2 ++ libs/vkd3d-shader/hlsl.y | 9 +++++++++ tests/abs.shader_test | 13 +++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 tests/abs.shader_test
diff --git a/Makefile.am b/Makefile.am index c9ad38893..3287ec75a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -54,6 +54,7 @@ vkd3d_shader_runners = \ tests/shader_runner_d3d12
vkd3d_shader_tests = \
- tests/abs.shader_test \ tests/cast-to-float.shader_test \ tests/cast-to-half.shader_test \ tests/cast-to-int.shader_test \
@@ -273,6 +274,7 @@ tests_vkd3d_api_LDADD = libvkd3d.la @VULKAN_LIBS@ tests_vkd3d_shader_api_LDADD = libvkd3d-shader.la SHADER_TEST_LOG_COMPILER = tests/shader_runner_d3d12 XFAIL_TESTS = \
- tests/abs.shader_test \ tests/cast-to-float.shader_test \ tests/cast-to-half.shader_test \ tests/cast-to-int.shader_test \
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index fe3c3289d..bd2660389 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -1555,6 +1555,14 @@ static const struct hlsl_ir_function_decl *find_function_call(struct hlsl_ctx *c return args.decl; }
+static bool intrinsic_abs(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_ABS, args, &loc);
+}
- static bool intrinsic_clamp(struct hlsl_ctx *ctx, const struct parse_initializer *params, struct vkd3d_shader_location loc) {
@@ -1594,6 +1602,7 @@ static const struct intrinsic_function } intrinsic_functions[] = {
- {"abs", 1, true, intrinsic_abs}, {"clamp", 3, true, intrinsic_clamp}, {"max", 2, true, intrinsic_max}, {"saturate", 1, true, intrinsic_saturate},
diff --git a/tests/abs.shader_test b/tests/abs.shader_test new file mode 100644 index 000000000..6fa6d1ca7 --- /dev/null +++ b/tests/abs.shader_test @@ -0,0 +1,13 @@ +[pixel shader] +float4 main(uniform float2 u) : sv_target +{
- return float4(abs(u), abs(u.x - 0.5), abs(-0.4));
+}
+[test] +uniform 0 float4 0.1 0.7 0.0 0.0 +draw quad +probe all rgba (0.1, 0.7, 0.4, 0.4) +uniform 0 float4 -0.7 0.1 0.0 0.0 +draw quad +probe all rgba (0.7, 0.1, 1.2, 0.4)