Giovanni Mascellani : vkd3d-shader/hlsl: Do not generate infinities in SM1.
Alexandre Julliard
julliard at winehq.org
Mon Apr 25 16:08:49 CDT 2022
Module: vkd3d
Branch: master
Commit: c680b674d61aac3dbe72a5286793f61bbf873423
URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=c680b674d61aac3dbe72a5286793f61bbf873423
Author: Giovanni Mascellani <gmascellani at codeweavers.com>
Date: Fri Apr 22 12:24:57 2022 +0200
vkd3d-shader/hlsl: Do not generate infinities in SM1.
Signed-off-by: Giovanni Mascellani <gmascellani at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
libs/vkd3d-shader/hlsl_constant_ops.c | 9 ++++++++-
tests/arithmetic-float.shader_test | 1 +
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/libs/vkd3d-shader/hlsl_constant_ops.c b/libs/vkd3d-shader/hlsl_constant_ops.c
index 06b957ba..a1551ba1 100644
--- a/libs/vkd3d-shader/hlsl_constant_ops.c
+++ b/libs/vkd3d-shader/hlsl_constant_ops.c
@@ -18,6 +18,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#include <math.h>
+
#include "hlsl.h"
static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct hlsl_ir_constant *src)
@@ -270,12 +272,17 @@ static bool fold_div(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst,
{
case HLSL_TYPE_FLOAT:
case HLSL_TYPE_HALF:
- if (src2->value[k].f == 0)
+ if (ctx->profile->major_version >= 4 && src2->value[k].f == 0)
{
hlsl_warning(ctx, &dst->node.loc, VKD3D_SHADER_WARNING_HLSL_DIVISION_BY_ZERO,
"Floating point division by zero");
}
dst->value[k].f = src1->value[k].f / src2->value[k].f;
+ if (ctx->profile->major_version < 4 && isinf(dst->value[k].f))
+ {
+ hlsl_error(ctx, &dst->node.loc, VKD3D_SHADER_ERROR_HLSL_DIVISION_BY_ZERO,
+ "Infinities are not allowed by the shader model.");
+ }
break;
case HLSL_TYPE_DOUBLE:
diff --git a/tests/arithmetic-float.shader_test b/tests/arithmetic-float.shader_test
index f99b9728..6824c3f1 100644
--- a/tests/arithmetic-float.shader_test
+++ b/tests/arithmetic-float.shader_test
@@ -25,6 +25,7 @@ todo draw quad
probe all rgba (5.0, 5.0, -5.0, 3.0)
[require]
+% Infinities are not allowed in SM1
shader model >= 4.0
[pixel shader]
More information about the wine-cvs
mailing list