Hello,
April 22, 2022 6:25 AM, "Giovanni Mascellani" gmascellani@codeweavers.com wrote:
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
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;
In the 0/0 case, the result is NAN and isinf(NAN) returns 0, and the error is not detected.
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]
2.35.2