tint/writer/glsl: Fix emission of lowest i32 value
GLSL has the same behavior as MSL, in that -2147483648 is parsed as a unary minus on '2147483648'. 2147483648 overflows an i32, so this actually gets treated as -0. Change-Id: Ibebd8b78a8840f18c438ed1d3d24dee486a65816 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123202 Reviewed-by: Stephen White <senorblanco@chromium.org> Commit-Queue: Ben Clayton <bclayton@google.com> Commit-Queue: Ben Clayton <bclayton@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
ce2578bc99
commit
51be3420b8
|
@ -17,6 +17,7 @@
|
|||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <iomanip>
|
||||
#include <limits>
|
||||
#include <set>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
@ -83,8 +84,15 @@
|
|||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
namespace {
|
||||
|
||||
const char kTempNamePrefix[] = "tint_tmp";
|
||||
|
||||
bool last_is_break(const ast::BlockStatement* stmts) {
|
||||
return IsAnyOf<ast::BreakStatement>(stmts->Last());
|
||||
}
|
||||
|
||||
bool IsRelational(tint::ast::BinaryOp op) {
|
||||
return op == tint::ast::BinaryOp::kEqual || op == tint::ast::BinaryOp::kNotEqual ||
|
||||
op == tint::ast::BinaryOp::kLessThan || op == tint::ast::BinaryOp::kGreaterThan ||
|
||||
|
@ -102,15 +110,15 @@ bool RequiresOESSampleVariables(tint::builtin::BuiltinValue builtin) {
|
|||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
namespace {
|
||||
|
||||
const char kTempNamePrefix[] = "tint_tmp";
|
||||
|
||||
bool last_is_break(const ast::BlockStatement* stmts) {
|
||||
return IsAnyOf<ast::BreakStatement>(stmts->Last());
|
||||
void PrintI32(utils::StringStream& out, int32_t value) {
|
||||
// GLSL parses `-2147483648` as a unary minus and `2147483648` as separate tokens, and the
|
||||
// latter doesn't fit into an (32-bit) `int`. Emit `(-2147483647 - 1)` instead, which ensures
|
||||
// the expression type is `int`.
|
||||
if (auto int_min = std::numeric_limits<int32_t>::min(); value == int_min) {
|
||||
out << "(" << int_min + 1 << " - 1)";
|
||||
} else {
|
||||
out << value;
|
||||
}
|
||||
}
|
||||
|
||||
void PrintF32(utils::StringStream& out, float value) {
|
||||
|
@ -2367,7 +2375,7 @@ bool GeneratorImpl::EmitConstant(utils::StringStream& out, const constant::Value
|
|||
return true;
|
||||
},
|
||||
[&](const type::I32*) {
|
||||
out << constant->ValueAs<AInt>();
|
||||
PrintI32(out, constant->ValueAs<i32>());
|
||||
return true;
|
||||
},
|
||||
[&](const type::U32*) {
|
||||
|
@ -2483,12 +2491,20 @@ bool GeneratorImpl::EmitLiteral(utils::StringStream& out, const ast::LiteralExpr
|
|||
}
|
||||
return true;
|
||||
},
|
||||
[&](const ast::IntLiteralExpression* l) {
|
||||
out << l->value;
|
||||
if (l->suffix == ast::IntLiteralExpression::Suffix::kU) {
|
||||
out << "u";
|
||||
[&](const ast::IntLiteralExpression* i) {
|
||||
switch (i->suffix) {
|
||||
case ast::IntLiteralExpression::Suffix::kNone:
|
||||
case ast::IntLiteralExpression::Suffix::kI: {
|
||||
PrintI32(out, static_cast<int32_t>(i->value));
|
||||
return true;
|
||||
}
|
||||
case ast::IntLiteralExpression::Suffix::kU: {
|
||||
out << i->value << "u";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
diagnostics_.add_error(diag::System::Writer, "unknown integer literal suffix type");
|
||||
return false;
|
||||
},
|
||||
[&](Default) {
|
||||
diagnostics_.add_error(diag::System::Writer, "unknown literal type");
|
||||
|
|
|
@ -80,5 +80,17 @@ TEST_F(GlslUnaryOpTest, Negation) {
|
|||
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.error();
|
||||
EXPECT_EQ(out.str(), "-(expr)");
|
||||
}
|
||||
|
||||
TEST_F(GlslUnaryOpTest, IntMin) {
|
||||
auto* op = Expr(i32(std::numeric_limits<int32_t>::min()));
|
||||
WrapInFunction(op);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.error();
|
||||
EXPECT_EQ(out.str(), "(-2147483647 - 1)");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace tint::writer::glsl
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#version 310 es
|
||||
|
||||
int tint_div(int lhs, int rhs) {
|
||||
return (lhs / (bool(uint((rhs == 0)) | uint(bool(uint((lhs == -2147483648)) & uint((rhs == -1))))) ? 1 : rhs));
|
||||
return (lhs / (bool(uint((rhs == 0)) | uint(bool(uint((lhs == (-2147483647 - 1))) & uint((rhs == -1))))) ? 1 : rhs));
|
||||
}
|
||||
|
||||
void f() {
|
||||
|
|
|
@ -25,7 +25,7 @@ vec4 sk_FragColor = vec4(0.0f, 0.0f, 0.0f, 0.0f);
|
|||
bool sk_Clockwise = false;
|
||||
vec4 vcolor_S0 = vec4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
ivec4 tint_div(ivec4 lhs, ivec4 rhs) {
|
||||
return (lhs / mix(rhs, ivec4(1), bvec4(uvec4(equal(rhs, ivec4(0))) | uvec4(bvec4(uvec4(equal(lhs, ivec4(-2147483648))) & uvec4(equal(rhs, ivec4(-1))))))));
|
||||
return (lhs / mix(rhs, ivec4(1), bvec4(uvec4(equal(rhs, ivec4(0))) | uvec4(bvec4(uvec4(equal(lhs, ivec4((-2147483647 - 1)))) & uvec4(equal(rhs, ivec4(-1))))))));
|
||||
}
|
||||
|
||||
bool test_int_S1_c0_b() {
|
||||
|
|
|
@ -5,7 +5,7 @@ layout(binding = 0, std430) buffer prevent_dce_block_ssbo {
|
|||
} prevent_dce;
|
||||
|
||||
void reverseBits_222177() {
|
||||
ivec2 res = ivec2(-2147483648);
|
||||
ivec2 res = ivec2((-2147483647 - 1));
|
||||
prevent_dce.inner = res;
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ layout(binding = 0, std430) buffer prevent_dce_block_ssbo {
|
|||
} prevent_dce;
|
||||
|
||||
void reverseBits_222177() {
|
||||
ivec2 res = ivec2(-2147483648);
|
||||
ivec2 res = ivec2((-2147483647 - 1));
|
||||
prevent_dce.inner = res;
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ layout(binding = 0, std430) buffer prevent_dce_block_ssbo {
|
|||
} prevent_dce;
|
||||
|
||||
void reverseBits_222177() {
|
||||
ivec2 res = ivec2(-2147483648);
|
||||
ivec2 res = ivec2((-2147483647 - 1));
|
||||
prevent_dce.inner = res;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ layout(binding = 0, std430) buffer prevent_dce_block_ssbo {
|
|||
} prevent_dce;
|
||||
|
||||
void reverseBits_4dbd6f() {
|
||||
ivec4 res = ivec4(-2147483648);
|
||||
ivec4 res = ivec4((-2147483647 - 1));
|
||||
prevent_dce.inner = res;
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ layout(binding = 0, std430) buffer prevent_dce_block_ssbo {
|
|||
} prevent_dce;
|
||||
|
||||
void reverseBits_4dbd6f() {
|
||||
ivec4 res = ivec4(-2147483648);
|
||||
ivec4 res = ivec4((-2147483647 - 1));
|
||||
prevent_dce.inner = res;
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ layout(binding = 0, std430) buffer prevent_dce_block_ssbo {
|
|||
} prevent_dce;
|
||||
|
||||
void reverseBits_4dbd6f() {
|
||||
ivec4 res = ivec4(-2147483648);
|
||||
ivec4 res = ivec4((-2147483647 - 1));
|
||||
prevent_dce.inner = res;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ layout(binding = 0, std430) buffer prevent_dce_block_ssbo {
|
|||
} prevent_dce;
|
||||
|
||||
void reverseBits_7c4269() {
|
||||
int res = -2147483648;
|
||||
int res = (-2147483647 - 1);
|
||||
prevent_dce.inner = res;
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ layout(binding = 0, std430) buffer prevent_dce_block_ssbo {
|
|||
} prevent_dce;
|
||||
|
||||
void reverseBits_7c4269() {
|
||||
int res = -2147483648;
|
||||
int res = (-2147483647 - 1);
|
||||
prevent_dce.inner = res;
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ layout(binding = 0, std430) buffer prevent_dce_block_ssbo {
|
|||
} prevent_dce;
|
||||
|
||||
void reverseBits_7c4269() {
|
||||
int res = -2147483648;
|
||||
int res = (-2147483647 - 1);
|
||||
prevent_dce.inner = res;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ layout(binding = 0, std430) buffer prevent_dce_block_ssbo {
|
|||
} prevent_dce;
|
||||
|
||||
void reverseBits_c21bc1() {
|
||||
ivec3 res = ivec3(-2147483648);
|
||||
ivec3 res = ivec3((-2147483647 - 1));
|
||||
prevent_dce.inner = res;
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ layout(binding = 0, std430) buffer prevent_dce_block_ssbo {
|
|||
} prevent_dce;
|
||||
|
||||
void reverseBits_c21bc1() {
|
||||
ivec3 res = ivec3(-2147483648);
|
||||
ivec3 res = ivec3((-2147483647 - 1));
|
||||
prevent_dce.inner = res;
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ layout(binding = 0, std430) buffer prevent_dce_block_ssbo {
|
|||
} prevent_dce;
|
||||
|
||||
void reverseBits_c21bc1() {
|
||||
ivec3 res = ivec3(-2147483648);
|
||||
ivec3 res = ivec3((-2147483647 - 1));
|
||||
prevent_dce.inner = res;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#version 310 es
|
||||
|
||||
int tint_div(int lhs, int rhs) {
|
||||
return (lhs / (bool(uint((rhs == 0)) | uint(bool(uint((lhs == -2147483648)) & uint((rhs == -1))))) ? 1 : rhs));
|
||||
return (lhs / (bool(uint((rhs == 0)) | uint(bool(uint((lhs == (-2147483647 - 1))) & uint((rhs == -1))))) ? 1 : rhs));
|
||||
}
|
||||
|
||||
void f() {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
ivec3 tint_div(int lhs, ivec3 rhs) {
|
||||
ivec3 l = ivec3(lhs);
|
||||
return (l / mix(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(l, ivec3(-2147483648))) & uvec3(equal(rhs, ivec3(-1))))))));
|
||||
return (l / mix(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(l, ivec3((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1))))))));
|
||||
}
|
||||
|
||||
void f() {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
ivec3 tint_div(ivec3 lhs, int rhs) {
|
||||
ivec3 r = ivec3(rhs);
|
||||
return (lhs / mix(r, ivec3(1), bvec3(uvec3(equal(r, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3(-2147483648))) & uvec3(equal(r, ivec3(-1))))))));
|
||||
return (lhs / mix(r, ivec3(1), bvec3(uvec3(equal(r, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3((-2147483647 - 1)))) & uvec3(equal(r, ivec3(-1))))))));
|
||||
}
|
||||
|
||||
void f() {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#version 310 es
|
||||
|
||||
ivec3 tint_div(ivec3 lhs, ivec3 rhs) {
|
||||
return (lhs / mix(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3(-2147483648))) & uvec3(equal(rhs, ivec3(-1))))))));
|
||||
return (lhs / mix(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1))))))));
|
||||
}
|
||||
|
||||
void f() {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#version 310 es
|
||||
|
||||
int tint_div(int lhs, int rhs) {
|
||||
return (lhs / (bool(uint((rhs == 0)) | uint(bool(uint((lhs == -2147483648)) & uint((rhs == -1))))) ? 1 : rhs));
|
||||
return (lhs / (bool(uint((rhs == 0)) | uint(bool(uint((lhs == (-2147483647 - 1))) & uint((rhs == -1))))) ? 1 : rhs));
|
||||
}
|
||||
|
||||
void f() {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
ivec3 tint_div(int lhs, ivec3 rhs) {
|
||||
ivec3 l = ivec3(lhs);
|
||||
return (l / mix(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(l, ivec3(-2147483648))) & uvec3(equal(rhs, ivec3(-1))))))));
|
||||
return (l / mix(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(l, ivec3((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1))))))));
|
||||
}
|
||||
|
||||
void f() {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
ivec3 tint_div(ivec3 lhs, int rhs) {
|
||||
ivec3 r = ivec3(rhs);
|
||||
return (lhs / mix(r, ivec3(1), bvec3(uvec3(equal(r, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3(-2147483648))) & uvec3(equal(r, ivec3(-1))))))));
|
||||
return (lhs / mix(r, ivec3(1), bvec3(uvec3(equal(r, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3((-2147483647 - 1)))) & uvec3(equal(r, ivec3(-1))))))));
|
||||
}
|
||||
|
||||
void f() {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#version 310 es
|
||||
|
||||
ivec3 tint_div(ivec3 lhs, ivec3 rhs) {
|
||||
return (lhs / mix(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3(-2147483648))) & uvec3(equal(rhs, ivec3(-1))))))));
|
||||
return (lhs / mix(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1))))))));
|
||||
}
|
||||
|
||||
void f() {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#version 310 es
|
||||
|
||||
int tint_div(int lhs, int rhs) {
|
||||
return (lhs / (bool(uint((rhs == 0)) | uint(bool(uint((lhs == -2147483648)) & uint((rhs == -1))))) ? 1 : rhs));
|
||||
return (lhs / (bool(uint((rhs == 0)) | uint(bool(uint((lhs == (-2147483647 - 1))) & uint((rhs == -1))))) ? 1 : rhs));
|
||||
}
|
||||
|
||||
void f() {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
ivec3 tint_div(int lhs, ivec3 rhs) {
|
||||
ivec3 l = ivec3(lhs);
|
||||
return (l / mix(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(l, ivec3(-2147483648))) & uvec3(equal(rhs, ivec3(-1))))))));
|
||||
return (l / mix(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(l, ivec3((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1))))))));
|
||||
}
|
||||
|
||||
void f() {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
ivec3 tint_div(ivec3 lhs, int rhs) {
|
||||
ivec3 r = ivec3(rhs);
|
||||
return (lhs / mix(r, ivec3(1), bvec3(uvec3(equal(r, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3(-2147483648))) & uvec3(equal(r, ivec3(-1))))))));
|
||||
return (lhs / mix(r, ivec3(1), bvec3(uvec3(equal(r, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3((-2147483647 - 1)))) & uvec3(equal(r, ivec3(-1))))))));
|
||||
}
|
||||
|
||||
void f() {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#version 310 es
|
||||
|
||||
ivec3 tint_div(ivec3 lhs, ivec3 rhs) {
|
||||
return (lhs / mix(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3(-2147483648))) & uvec3(equal(rhs, ivec3(-1))))))));
|
||||
return (lhs / mix(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1))))))));
|
||||
}
|
||||
|
||||
void f() {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#version 310 es
|
||||
|
||||
int tint_div(int lhs, int rhs) {
|
||||
return (lhs / (bool(uint((rhs == 0)) | uint(bool(uint((lhs == -2147483648)) & uint((rhs == -1))))) ? 1 : rhs));
|
||||
return (lhs / (bool(uint((rhs == 0)) | uint(bool(uint((lhs == (-2147483647 - 1))) & uint((rhs == -1))))) ? 1 : rhs));
|
||||
}
|
||||
|
||||
void f() {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
ivec3 tint_div(int lhs, ivec3 rhs) {
|
||||
ivec3 l = ivec3(lhs);
|
||||
return (l / mix(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(l, ivec3(-2147483648))) & uvec3(equal(rhs, ivec3(-1))))))));
|
||||
return (l / mix(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(l, ivec3((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1))))))));
|
||||
}
|
||||
|
||||
void f() {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
ivec3 tint_div(ivec3 lhs, int rhs) {
|
||||
ivec3 r = ivec3(rhs);
|
||||
return (lhs / mix(r, ivec3(1), bvec3(uvec3(equal(r, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3(-2147483648))) & uvec3(equal(r, ivec3(-1))))))));
|
||||
return (lhs / mix(r, ivec3(1), bvec3(uvec3(equal(r, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3((-2147483647 - 1)))) & uvec3(equal(r, ivec3(-1))))))));
|
||||
}
|
||||
|
||||
void f() {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#version 310 es
|
||||
|
||||
ivec3 tint_div(ivec3 lhs, ivec3 rhs) {
|
||||
return (lhs / mix(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3(-2147483648))) & uvec3(equal(rhs, ivec3(-1))))))));
|
||||
return (lhs / mix(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1))))))));
|
||||
}
|
||||
|
||||
void f() {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#version 310 es
|
||||
|
||||
int tint_mod(int lhs, int rhs) {
|
||||
int rhs_or_one = (bool(uint((rhs == 0)) | uint(bool(uint((lhs == -2147483648)) & uint((rhs == -1))))) ? 1 : rhs);
|
||||
int rhs_or_one = (bool(uint((rhs == 0)) | uint(bool(uint((lhs == (-2147483647 - 1))) & uint((rhs == -1))))) ? 1 : rhs);
|
||||
if (((uint((lhs | rhs_or_one)) & 2147483648u) != 0u)) {
|
||||
return (lhs - ((lhs / rhs_or_one) * rhs_or_one));
|
||||
} else {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
ivec3 tint_mod(int lhs, ivec3 rhs) {
|
||||
ivec3 l = ivec3(lhs);
|
||||
ivec3 rhs_or_one = mix(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(l, ivec3(-2147483648))) & uvec3(equal(rhs, ivec3(-1)))))));
|
||||
ivec3 rhs_or_one = mix(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(l, ivec3((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1)))))));
|
||||
if (any(notEqual((uvec3((l | rhs_or_one)) & uvec3(2147483648u)), uvec3(0u)))) {
|
||||
return (l - ((l / rhs_or_one) * rhs_or_one));
|
||||
} else {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
ivec3 tint_mod(ivec3 lhs, int rhs) {
|
||||
ivec3 r = ivec3(rhs);
|
||||
ivec3 rhs_or_one = mix(r, ivec3(1), bvec3(uvec3(equal(r, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3(-2147483648))) & uvec3(equal(r, ivec3(-1)))))));
|
||||
ivec3 rhs_or_one = mix(r, ivec3(1), bvec3(uvec3(equal(r, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3((-2147483647 - 1)))) & uvec3(equal(r, ivec3(-1)))))));
|
||||
if (any(notEqual((uvec3((lhs | rhs_or_one)) & uvec3(2147483648u)), uvec3(0u)))) {
|
||||
return (lhs - ((lhs / rhs_or_one) * rhs_or_one));
|
||||
} else {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#version 310 es
|
||||
|
||||
ivec3 tint_mod(ivec3 lhs, ivec3 rhs) {
|
||||
ivec3 rhs_or_one = mix(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3(-2147483648))) & uvec3(equal(rhs, ivec3(-1)))))));
|
||||
ivec3 rhs_or_one = mix(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1)))))));
|
||||
if (any(notEqual((uvec3((lhs | rhs_or_one)) & uvec3(2147483648u)), uvec3(0u)))) {
|
||||
return (lhs - ((lhs / rhs_or_one) * rhs_or_one));
|
||||
} else {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#version 310 es
|
||||
|
||||
int tint_mod(int lhs, int rhs) {
|
||||
int rhs_or_one = (bool(uint((rhs == 0)) | uint(bool(uint((lhs == -2147483648)) & uint((rhs == -1))))) ? 1 : rhs);
|
||||
int rhs_or_one = (bool(uint((rhs == 0)) | uint(bool(uint((lhs == (-2147483647 - 1))) & uint((rhs == -1))))) ? 1 : rhs);
|
||||
if (((uint((lhs | rhs_or_one)) & 2147483648u) != 0u)) {
|
||||
return (lhs - ((lhs / rhs_or_one) * rhs_or_one));
|
||||
} else {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
ivec3 tint_mod(int lhs, ivec3 rhs) {
|
||||
ivec3 l = ivec3(lhs);
|
||||
ivec3 rhs_or_one = mix(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(l, ivec3(-2147483648))) & uvec3(equal(rhs, ivec3(-1)))))));
|
||||
ivec3 rhs_or_one = mix(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(l, ivec3((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1)))))));
|
||||
if (any(notEqual((uvec3((l | rhs_or_one)) & uvec3(2147483648u)), uvec3(0u)))) {
|
||||
return (l - ((l / rhs_or_one) * rhs_or_one));
|
||||
} else {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
ivec3 tint_mod(ivec3 lhs, int rhs) {
|
||||
ivec3 r = ivec3(rhs);
|
||||
ivec3 rhs_or_one = mix(r, ivec3(1), bvec3(uvec3(equal(r, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3(-2147483648))) & uvec3(equal(r, ivec3(-1)))))));
|
||||
ivec3 rhs_or_one = mix(r, ivec3(1), bvec3(uvec3(equal(r, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3((-2147483647 - 1)))) & uvec3(equal(r, ivec3(-1)))))));
|
||||
if (any(notEqual((uvec3((lhs | rhs_or_one)) & uvec3(2147483648u)), uvec3(0u)))) {
|
||||
return (lhs - ((lhs / rhs_or_one) * rhs_or_one));
|
||||
} else {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#version 310 es
|
||||
|
||||
ivec3 tint_mod(ivec3 lhs, ivec3 rhs) {
|
||||
ivec3 rhs_or_one = mix(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3(-2147483648))) & uvec3(equal(rhs, ivec3(-1)))))));
|
||||
ivec3 rhs_or_one = mix(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1)))))));
|
||||
if (any(notEqual((uvec3((lhs | rhs_or_one)) & uvec3(2147483648u)), uvec3(0u)))) {
|
||||
return (lhs - ((lhs / rhs_or_one) * rhs_or_one));
|
||||
} else {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#version 310 es
|
||||
|
||||
int tint_mod(int lhs, int rhs) {
|
||||
int rhs_or_one = (bool(uint((rhs == 0)) | uint(bool(uint((lhs == -2147483648)) & uint((rhs == -1))))) ? 1 : rhs);
|
||||
int rhs_or_one = (bool(uint((rhs == 0)) | uint(bool(uint((lhs == (-2147483647 - 1))) & uint((rhs == -1))))) ? 1 : rhs);
|
||||
if (((uint((lhs | rhs_or_one)) & 2147483648u) != 0u)) {
|
||||
return (lhs - ((lhs / rhs_or_one) * rhs_or_one));
|
||||
} else {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
ivec3 tint_mod(int lhs, ivec3 rhs) {
|
||||
ivec3 l = ivec3(lhs);
|
||||
ivec3 rhs_or_one = mix(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(l, ivec3(-2147483648))) & uvec3(equal(rhs, ivec3(-1)))))));
|
||||
ivec3 rhs_or_one = mix(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(l, ivec3((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1)))))));
|
||||
if (any(notEqual((uvec3((l | rhs_or_one)) & uvec3(2147483648u)), uvec3(0u)))) {
|
||||
return (l - ((l / rhs_or_one) * rhs_or_one));
|
||||
} else {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
ivec3 tint_mod(ivec3 lhs, int rhs) {
|
||||
ivec3 r = ivec3(rhs);
|
||||
ivec3 rhs_or_one = mix(r, ivec3(1), bvec3(uvec3(equal(r, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3(-2147483648))) & uvec3(equal(r, ivec3(-1)))))));
|
||||
ivec3 rhs_or_one = mix(r, ivec3(1), bvec3(uvec3(equal(r, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3((-2147483647 - 1)))) & uvec3(equal(r, ivec3(-1)))))));
|
||||
if (any(notEqual((uvec3((lhs | rhs_or_one)) & uvec3(2147483648u)), uvec3(0u)))) {
|
||||
return (lhs - ((lhs / rhs_or_one) * rhs_or_one));
|
||||
} else {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#version 310 es
|
||||
|
||||
ivec3 tint_mod(ivec3 lhs, ivec3 rhs) {
|
||||
ivec3 rhs_or_one = mix(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3(-2147483648))) & uvec3(equal(rhs, ivec3(-1)))))));
|
||||
ivec3 rhs_or_one = mix(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1)))))));
|
||||
if (any(notEqual((uvec3((lhs | rhs_or_one)) & uvec3(2147483648u)), uvec3(0u)))) {
|
||||
return (lhs - ((lhs / rhs_or_one) * rhs_or_one));
|
||||
} else {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#version 310 es
|
||||
|
||||
int tint_mod(int lhs, int rhs) {
|
||||
int rhs_or_one = (bool(uint((rhs == 0)) | uint(bool(uint((lhs == -2147483648)) & uint((rhs == -1))))) ? 1 : rhs);
|
||||
int rhs_or_one = (bool(uint((rhs == 0)) | uint(bool(uint((lhs == (-2147483647 - 1))) & uint((rhs == -1))))) ? 1 : rhs);
|
||||
if (((uint((lhs | rhs_or_one)) & 2147483648u) != 0u)) {
|
||||
return (lhs - ((lhs / rhs_or_one) * rhs_or_one));
|
||||
} else {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
ivec3 tint_mod(int lhs, ivec3 rhs) {
|
||||
ivec3 l = ivec3(lhs);
|
||||
ivec3 rhs_or_one = mix(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(l, ivec3(-2147483648))) & uvec3(equal(rhs, ivec3(-1)))))));
|
||||
ivec3 rhs_or_one = mix(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(l, ivec3((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1)))))));
|
||||
if (any(notEqual((uvec3((l | rhs_or_one)) & uvec3(2147483648u)), uvec3(0u)))) {
|
||||
return (l - ((l / rhs_or_one) * rhs_or_one));
|
||||
} else {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
ivec3 tint_mod(ivec3 lhs, int rhs) {
|
||||
ivec3 r = ivec3(rhs);
|
||||
ivec3 rhs_or_one = mix(r, ivec3(1), bvec3(uvec3(equal(r, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3(-2147483648))) & uvec3(equal(r, ivec3(-1)))))));
|
||||
ivec3 rhs_or_one = mix(r, ivec3(1), bvec3(uvec3(equal(r, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3((-2147483647 - 1)))) & uvec3(equal(r, ivec3(-1)))))));
|
||||
if (any(notEqual((uvec3((lhs | rhs_or_one)) & uvec3(2147483648u)), uvec3(0u)))) {
|
||||
return (lhs - ((lhs / rhs_or_one) * rhs_or_one));
|
||||
} else {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#version 310 es
|
||||
|
||||
ivec3 tint_mod(ivec3 lhs, ivec3 rhs) {
|
||||
ivec3 rhs_or_one = mix(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3(-2147483648))) & uvec3(equal(rhs, ivec3(-1)))))));
|
||||
ivec3 rhs_or_one = mix(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1)))))));
|
||||
if (any(notEqual((uvec3((lhs | rhs_or_one)) & uvec3(2147483648u)), uvec3(0u)))) {
|
||||
return (lhs - ((lhs / rhs_or_one) * rhs_or_one));
|
||||
} else {
|
||||
|
|
|
@ -5,7 +5,7 @@ void unused_entry_point() {
|
|||
return;
|
||||
}
|
||||
int add_int_min_explicit() {
|
||||
int a = -2147483648;
|
||||
int a = (-2147483647 - 1);
|
||||
int b = (a + 1);
|
||||
int c = -2147483647;
|
||||
return c;
|
||||
|
|
|
@ -12,11 +12,11 @@ void unused_entry_point() {
|
|||
int a = 0;
|
||||
float b = 0.0f;
|
||||
int tint_div(int lhs, int rhs) {
|
||||
return (lhs / (bool(uint((rhs == 0)) | uint(bool(uint((lhs == -2147483648)) & uint((rhs == -1))))) ? 1 : rhs));
|
||||
return (lhs / (bool(uint((rhs == 0)) | uint(bool(uint((lhs == (-2147483647 - 1))) & uint((rhs == -1))))) ? 1 : rhs));
|
||||
}
|
||||
|
||||
int tint_mod(int lhs, int rhs) {
|
||||
int rhs_or_one = (bool(uint((rhs == 0)) | uint(bool(uint((lhs == -2147483648)) & uint((rhs == -1))))) ? 1 : rhs);
|
||||
int rhs_or_one = (bool(uint((rhs == 0)) | uint(bool(uint((lhs == (-2147483647 - 1))) & uint((rhs == -1))))) ? 1 : rhs);
|
||||
if (((uint((lhs | rhs_or_one)) & 2147483648u) != 0u)) {
|
||||
return (lhs - ((lhs / rhs_or_one) * rhs_or_one));
|
||||
} else {
|
||||
|
|
|
@ -5,7 +5,7 @@ void unused_entry_point() {
|
|||
return;
|
||||
}
|
||||
int tint_div(int lhs, int rhs) {
|
||||
return (lhs / (bool(uint((rhs == 0)) | uint(bool(uint((lhs == -2147483648)) & uint((rhs == -1))))) ? 1 : rhs));
|
||||
return (lhs / (bool(uint((rhs == 0)) | uint(bool(uint((lhs == (-2147483647 - 1))) & uint((rhs == -1))))) ? 1 : rhs));
|
||||
}
|
||||
|
||||
void foo() {
|
||||
|
|
|
@ -8,7 +8,7 @@ int a = 0;
|
|||
vec4 b = vec4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
mat2 c = mat2(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
int tint_div(int lhs, int rhs) {
|
||||
return (lhs / (bool(uint((rhs == 0)) | uint(bool(uint((lhs == -2147483648)) & uint((rhs == -1))))) ? 1 : rhs));
|
||||
return (lhs / (bool(uint((rhs == 0)) | uint(bool(uint((lhs == (-2147483647 - 1))) & uint((rhs == -1))))) ? 1 : rhs));
|
||||
}
|
||||
|
||||
void foo() {
|
||||
|
|
|
@ -13,7 +13,7 @@ layout(binding = 0, std430) buffer v_block_ssbo {
|
|||
} v;
|
||||
|
||||
int tint_div(int lhs, int rhs) {
|
||||
return (lhs / (bool(uint((rhs == 0)) | uint(bool(uint((lhs == -2147483648)) & uint((rhs == -1))))) ? 1 : rhs));
|
||||
return (lhs / (bool(uint((rhs == 0)) | uint(bool(uint((lhs == (-2147483647 - 1))) & uint((rhs == -1))))) ? 1 : rhs));
|
||||
}
|
||||
|
||||
void foo() {
|
||||
|
|
|
@ -13,7 +13,7 @@ layout(binding = 0, std430) buffer v_block_ssbo {
|
|||
} v;
|
||||
|
||||
int tint_mod(int lhs, int rhs) {
|
||||
int rhs_or_one = (bool(uint((rhs == 0)) | uint(bool(uint((lhs == -2147483648)) & uint((rhs == -1))))) ? 1 : rhs);
|
||||
int rhs_or_one = (bool(uint((rhs == 0)) | uint(bool(uint((lhs == (-2147483647 - 1))) & uint((rhs == -1))))) ? 1 : rhs);
|
||||
if (((uint((lhs | rhs_or_one)) & 2147483648u) != 0u)) {
|
||||
return (lhs - ((lhs / rhs_or_one) * rhs_or_one));
|
||||
} else {
|
||||
|
|
|
@ -13,7 +13,7 @@ layout(binding = 0, std430) buffer v_block_ssbo {
|
|||
} v;
|
||||
|
||||
ivec4 tint_div(ivec4 lhs, ivec4 rhs) {
|
||||
return (lhs / mix(rhs, ivec4(1), bvec4(uvec4(equal(rhs, ivec4(0))) | uvec4(bvec4(uvec4(equal(lhs, ivec4(-2147483648))) & uvec4(equal(rhs, ivec4(-1))))))));
|
||||
return (lhs / mix(rhs, ivec4(1), bvec4(uvec4(equal(rhs, ivec4(0))) | uvec4(bvec4(uvec4(equal(lhs, ivec4((-2147483647 - 1)))) & uvec4(equal(rhs, ivec4(-1))))))));
|
||||
}
|
||||
|
||||
void foo() {
|
||||
|
|
|
@ -14,7 +14,7 @@ layout(binding = 0, std430) buffer v_block_ssbo {
|
|||
|
||||
ivec4 tint_mod(ivec4 lhs, int rhs) {
|
||||
ivec4 r = ivec4(rhs);
|
||||
ivec4 rhs_or_one = mix(r, ivec4(1), bvec4(uvec4(equal(r, ivec4(0))) | uvec4(bvec4(uvec4(equal(lhs, ivec4(-2147483648))) & uvec4(equal(r, ivec4(-1)))))));
|
||||
ivec4 rhs_or_one = mix(r, ivec4(1), bvec4(uvec4(equal(r, ivec4(0))) | uvec4(bvec4(uvec4(equal(lhs, ivec4((-2147483647 - 1)))) & uvec4(equal(r, ivec4(-1)))))));
|
||||
if (any(notEqual((uvec4((lhs | rhs_or_one)) & uvec4(2147483648u)), uvec4(0u)))) {
|
||||
return (lhs - ((lhs / rhs_or_one) * rhs_or_one));
|
||||
} else {
|
||||
|
|
|
@ -13,7 +13,7 @@ layout(binding = 0, std430) buffer v_block_ssbo {
|
|||
} v;
|
||||
|
||||
ivec4 tint_mod(ivec4 lhs, ivec4 rhs) {
|
||||
ivec4 rhs_or_one = mix(rhs, ivec4(1), bvec4(uvec4(equal(rhs, ivec4(0))) | uvec4(bvec4(uvec4(equal(lhs, ivec4(-2147483648))) & uvec4(equal(rhs, ivec4(-1)))))));
|
||||
ivec4 rhs_or_one = mix(rhs, ivec4(1), bvec4(uvec4(equal(rhs, ivec4(0))) | uvec4(bvec4(uvec4(equal(lhs, ivec4((-2147483647 - 1)))) & uvec4(equal(rhs, ivec4(-1)))))));
|
||||
if (any(notEqual((uvec4((lhs | rhs_or_one)) & uvec4(2147483648u)), uvec4(0u)))) {
|
||||
return (lhs - ((lhs / rhs_or_one) * rhs_or_one));
|
||||
} else {
|
||||
|
|
|
@ -8,7 +8,7 @@ shared int a;
|
|||
shared vec4 b;
|
||||
shared mat2 c;
|
||||
int tint_div(int lhs, int rhs) {
|
||||
return (lhs / (bool(uint((rhs == 0)) | uint(bool(uint((lhs == -2147483648)) & uint((rhs == -1))))) ? 1 : rhs));
|
||||
return (lhs / (bool(uint((rhs == 0)) | uint(bool(uint((lhs == (-2147483647 - 1))) & uint((rhs == -1))))) ? 1 : rhs));
|
||||
}
|
||||
|
||||
void foo() {
|
||||
|
|
Loading…
Reference in New Issue