diff --git a/src/tint/writer/glsl/generator_impl.cc b/src/tint/writer/glsl/generator_impl.cc index e1d3061484..5e0690279a 100644 --- a/src/tint/writer/glsl/generator_impl.cc +++ b/src/tint/writer/glsl/generator_impl.cc @@ -780,7 +780,7 @@ bool GeneratorImpl::EmitBuiltinCall(utils::StringStream& out, return EmitCountOneBitsCall(out, expr); } if (builtin->Type() == sem::BuiltinType::kSelect) { - return EmitSelectCall(out, expr); + return EmitSelectCall(out, expr, builtin); } if (builtin->Type() == sem::BuiltinType::kDot) { return EmitDotCall(out, expr, builtin); @@ -1100,28 +1100,39 @@ bool GeneratorImpl::EmitCountOneBitsCall(utils::StringStream& out, return true; } -bool GeneratorImpl::EmitSelectCall(utils::StringStream& out, const ast::CallExpression* expr) { +bool GeneratorImpl::EmitSelectCall(utils::StringStream& out, + const ast::CallExpression* expr, + const sem::Builtin* builtin) { + // GLSL does not support ternary expressions with a bool vector conditional, + // so polyfill with a helper. + if (auto* vec = builtin->Parameters()[2]->Type()->As()) { + return CallBuiltinHelper( + out, expr, builtin, [&](TextBuffer* b, const std::vector& params) { + auto l = line(b); + l << " return "; + if (!EmitType(l, builtin->ReturnType(), builtin::AddressSpace::kUndefined, + builtin::Access::kUndefined, "")) { + return false; + } + { + ScopedParen sp(l); + for (uint32_t i = 0; i < vec->Width(); i++) { + if (i > 0) { + l << ", "; + } + l << params[2] << "[" << i << "] ? " << params[1] << "[" << i + << "] : " << params[0] << "[" << i << "]"; + } + } + l << ";"; + return true; + }); + } + auto* expr_false = expr->args[0]; auto* expr_true = expr->args[1]; auto* expr_cond = expr->args[2]; - // GLSL does not support ternary expressions with a bool vector conditional, - // but it does support mix() with same. - if (TypeOf(expr_cond)->UnwrapRef()->is_bool_vector()) { - out << "mix("; - if (!EmitExpression(out, expr_false)) { - return false; - } - out << ", "; - if (!EmitExpression(out, expr_true)) { - return false; - } - out << ", "; - if (!EmitExpression(out, expr_cond)) { - return false; - } - out << ")"; - return true; - } + ScopedParen paren(out); if (!EmitExpression(out, expr_cond)) { return false; diff --git a/src/tint/writer/glsl/generator_impl.h b/src/tint/writer/glsl/generator_impl.h index d954921453..96042c1a1a 100644 --- a/src/tint/writer/glsl/generator_impl.h +++ b/src/tint/writer/glsl/generator_impl.h @@ -234,8 +234,11 @@ class GeneratorImpl : public TextGenerator { /// Handles generating a call to the `countOneBits()` builtin /// @param out the output of the expression stream /// @param expr the call expression + /// @param builtin the semantic information for the builtin /// @returns true if the call expression is emitted - bool EmitSelectCall(utils::StringStream& out, const ast::CallExpression* expr); + bool EmitSelectCall(utils::StringStream& out, + const ast::CallExpression* expr, + const sem::Builtin* builtin); /// Handles generating a call to the `dot()` builtin /// @param out the output of the expression stream /// @param expr the call expression diff --git a/src/tint/writer/glsl/generator_impl_builtin_test.cc b/src/tint/writer/glsl/generator_impl_builtin_test.cc index d281cdbbc2..19bf555e27 100644 --- a/src/tint/writer/glsl/generator_impl_builtin_test.cc +++ b/src/tint/writer/glsl/generator_impl_builtin_test.cc @@ -379,7 +379,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, Select_Vector) { gen.increment_indent(); utils::StringStream out; ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.error(); - EXPECT_EQ(out.str(), "mix(a, b, bvec2(true, false))"); + EXPECT_EQ(out.str(), "tint_select(a, b, bvec2(true, false))"); } TEST_F(GlslGeneratorImplTest_Builtin, FMA_f32) { diff --git a/test/tint/bug/tint/1520.spvasm.expected.glsl b/test/tint/bug/tint/1520.spvasm.expected.glsl index f83736dcab..b1bcf2f47f 100644 --- a/test/tint/bug/tint/1520.spvasm.expected.glsl +++ b/test/tint/bug/tint/1520.spvasm.expected.glsl @@ -1,6 +1,11 @@ #version 310 es precision mediump float; +ivec4 tint_select(ivec4 param_0, ivec4 param_1, bvec4 param_2) { + return ivec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + layout(location = 0) in vec4 vcolor_S0_param_1; layout(location = 0) out vec4 sk_FragColor_1_1; struct UniformBuffer { @@ -25,7 +30,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((-2147483647 - 1)))) & uvec4(equal(rhs, ivec4(-1)))))))); + return (lhs / tint_select(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() { diff --git a/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.glsl b/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.glsl index 50390aa71e..273445c970 100644 --- a/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.glsl @@ -1,5 +1,10 @@ #version 310 es +vec3 tint_select(vec3 param_0, vec3 param_1, bvec3 param_2) { + return vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + struct GammaTransferParams { float G; float A; @@ -49,7 +54,7 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { bvec3 cond = lessThan(abs(v), vec3(params.D)); vec3 t = (sign(v) * ((params.C * abs(v)) + params.F)); vec3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3(params.G)) + params.E)); - return mix(f, t, cond); + return tint_select(f, t, cond); } vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, uvec2 coord, ExternalTextureParams params) { @@ -99,6 +104,11 @@ void main() { #version 310 es precision mediump float; +vec3 tint_select(vec3 param_0, vec3 param_1, bvec3 param_2) { + return vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + struct GammaTransferParams { float G; float A; @@ -148,7 +158,7 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { bvec3 cond = lessThan(abs(v), vec3(params.D)); vec3 t = (sign(v) * ((params.C * abs(v)) + params.F)); vec3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3(params.G)) + params.E)); - return mix(f, t, cond); + return tint_select(f, t, cond); } vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, uvec2 coord, ExternalTextureParams params) { @@ -192,6 +202,11 @@ void main() { } #version 310 es +vec3 tint_select(vec3 param_0, vec3 param_1, bvec3 param_2) { + return vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + struct GammaTransferParams { float G; float A; @@ -241,7 +256,7 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { bvec3 cond = lessThan(abs(v), vec3(params.D)); vec3 t = (sign(v) * ((params.C * abs(v)) + params.F)); vec3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3(params.G)) + params.E)); - return mix(f, t, cond); + return tint_select(f, t, cond); } vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, uvec2 coord, ExternalTextureParams params) { diff --git a/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.glsl b/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.glsl index ef39bd8673..5760501099 100644 --- a/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.glsl @@ -1,5 +1,10 @@ #version 310 es +vec3 tint_select(vec3 param_0, vec3 param_1, bvec3 param_2) { + return vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + struct GammaTransferParams { float G; float A; @@ -49,7 +54,7 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { bvec3 cond = lessThan(abs(v), vec3(params.D)); vec3 t = (sign(v) * ((params.C * abs(v)) + params.F)); vec3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3(params.G)) + params.E)); - return mix(f, t, cond); + return tint_select(f, t, cond); } vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, ivec2 coord, ExternalTextureParams params) { @@ -99,6 +104,11 @@ void main() { #version 310 es precision mediump float; +vec3 tint_select(vec3 param_0, vec3 param_1, bvec3 param_2) { + return vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + struct GammaTransferParams { float G; float A; @@ -148,7 +158,7 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { bvec3 cond = lessThan(abs(v), vec3(params.D)); vec3 t = (sign(v) * ((params.C * abs(v)) + params.F)); vec3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3(params.G)) + params.E)); - return mix(f, t, cond); + return tint_select(f, t, cond); } vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, ivec2 coord, ExternalTextureParams params) { @@ -192,6 +202,11 @@ void main() { } #version 310 es +vec3 tint_select(vec3 param_0, vec3 param_1, bvec3 param_2) { + return vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + struct GammaTransferParams { float G; float A; @@ -241,7 +256,7 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { bvec3 cond = lessThan(abs(v), vec3(params.D)); vec3 t = (sign(v) * ((params.C * abs(v)) + params.F)); vec3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3(params.G)) + params.E)); - return mix(f, t, cond); + return tint_select(f, t, cond); } vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, ivec2 coord, ExternalTextureParams params) { diff --git a/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.glsl b/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.glsl index df288dbb06..b348446829 100644 --- a/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.glsl @@ -1,5 +1,10 @@ #version 310 es +vec3 tint_select(vec3 param_0, vec3 param_1, bvec3 param_2) { + return vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + struct GammaTransferParams { float G; float A; @@ -49,7 +54,7 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { bvec3 cond = lessThan(abs(v), vec3(params.D)); vec3 t = (sign(v) * ((params.C * abs(v)) + params.F)); vec3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3(params.G)) + params.E)); - return mix(f, t, cond); + return tint_select(f, t, cond); } @@ -108,6 +113,11 @@ void main() { #version 310 es precision mediump float; +vec3 tint_select(vec3 param_0, vec3 param_1, bvec3 param_2) { + return vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + struct GammaTransferParams { float G; float A; @@ -157,7 +167,7 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { bvec3 cond = lessThan(abs(v), vec3(params.D)); vec3 t = (sign(v) * ((params.C * abs(v)) + params.F)); vec3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3(params.G)) + params.E)); - return mix(f, t, cond); + return tint_select(f, t, cond); } @@ -210,6 +220,11 @@ void main() { } #version 310 es +vec3 tint_select(vec3 param_0, vec3 param_1, bvec3 param_2) { + return vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + struct GammaTransferParams { float G; float A; @@ -259,7 +274,7 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { bvec3 cond = lessThan(abs(v), vec3(params.D)); vec3 t = (sign(v) * ((params.C * abs(v)) + params.F)); vec3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3(params.G)) + params.E)); - return mix(f, t, cond); + return tint_select(f, t, cond); } diff --git a/test/tint/builtins/gen/var/acosh/5f49d8.wgsl.expected.glsl b/test/tint/builtins/gen/var/acosh/5f49d8.wgsl.expected.glsl index d27deec910..8f8fece44f 100644 --- a/test/tint/builtins/gen/var/acosh/5f49d8.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/acosh/5f49d8.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es #extension GL_AMD_gpu_shader_half_float : require +f16vec2 tint_select(f16vec2 param_0, f16vec2 param_1, bvec2 param_2) { + return f16vec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + f16vec2 tint_acosh(f16vec2 x) { - return mix(acosh(x), f16vec2(0.0hf), lessThan(x, f16vec2(1.0hf))); + return tint_select(acosh(x), f16vec2(0.0hf), lessThan(x, f16vec2(1.0hf))); } layout(binding = 0, std430) buffer prevent_dce_block_ssbo { @@ -32,8 +37,13 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require precision mediump float; +f16vec2 tint_select(f16vec2 param_0, f16vec2 param_1, bvec2 param_2) { + return f16vec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + f16vec2 tint_acosh(f16vec2 x) { - return mix(acosh(x), f16vec2(0.0hf), lessThan(x, f16vec2(1.0hf))); + return tint_select(acosh(x), f16vec2(0.0hf), lessThan(x, f16vec2(1.0hf))); } layout(binding = 0, std430) buffer prevent_dce_block_ssbo { @@ -57,8 +67,13 @@ void main() { #version 310 es #extension GL_AMD_gpu_shader_half_float : require +f16vec2 tint_select(f16vec2 param_0, f16vec2 param_1, bvec2 param_2) { + return f16vec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + f16vec2 tint_acosh(f16vec2 x) { - return mix(acosh(x), f16vec2(0.0hf), lessThan(x, f16vec2(1.0hf))); + return tint_select(acosh(x), f16vec2(0.0hf), lessThan(x, f16vec2(1.0hf))); } layout(binding = 0, std430) buffer prevent_dce_block_ssbo { diff --git a/test/tint/builtins/gen/var/acosh/640883.wgsl.expected.glsl b/test/tint/builtins/gen/var/acosh/640883.wgsl.expected.glsl index 3d6f927342..7ea82c5a76 100644 --- a/test/tint/builtins/gen/var/acosh/640883.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/acosh/640883.wgsl.expected.glsl @@ -1,7 +1,12 @@ #version 310 es +vec2 tint_select(vec2 param_0, vec2 param_1, bvec2 param_2) { + return vec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + vec2 tint_acosh(vec2 x) { - return mix(acosh(x), vec2(0.0f), lessThan(x, vec2(1.0f))); + return tint_select(acosh(x), vec2(0.0f), lessThan(x, vec2(1.0f))); } layout(binding = 0, std430) buffer prevent_dce_block_ssbo { @@ -30,8 +35,13 @@ void main() { #version 310 es precision mediump float; +vec2 tint_select(vec2 param_0, vec2 param_1, bvec2 param_2) { + return vec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + vec2 tint_acosh(vec2 x) { - return mix(acosh(x), vec2(0.0f), lessThan(x, vec2(1.0f))); + return tint_select(acosh(x), vec2(0.0f), lessThan(x, vec2(1.0f))); } layout(binding = 0, std430) buffer prevent_dce_block_ssbo { @@ -54,8 +64,13 @@ void main() { } #version 310 es +vec2 tint_select(vec2 param_0, vec2 param_1, bvec2 param_2) { + return vec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + vec2 tint_acosh(vec2 x) { - return mix(acosh(x), vec2(0.0f), lessThan(x, vec2(1.0f))); + return tint_select(acosh(x), vec2(0.0f), lessThan(x, vec2(1.0f))); } layout(binding = 0, std430) buffer prevent_dce_block_ssbo { diff --git a/test/tint/builtins/gen/var/acosh/d51ccb.wgsl.expected.glsl b/test/tint/builtins/gen/var/acosh/d51ccb.wgsl.expected.glsl index 51cf439c8c..a454f9848f 100644 --- a/test/tint/builtins/gen/var/acosh/d51ccb.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/acosh/d51ccb.wgsl.expected.glsl @@ -1,7 +1,12 @@ #version 310 es +vec4 tint_select(vec4 param_0, vec4 param_1, bvec4 param_2) { + return vec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + vec4 tint_acosh(vec4 x) { - return mix(acosh(x), vec4(0.0f), lessThan(x, vec4(1.0f))); + return tint_select(acosh(x), vec4(0.0f), lessThan(x, vec4(1.0f))); } layout(binding = 0, std430) buffer prevent_dce_block_ssbo { @@ -30,8 +35,13 @@ void main() { #version 310 es precision mediump float; +vec4 tint_select(vec4 param_0, vec4 param_1, bvec4 param_2) { + return vec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + vec4 tint_acosh(vec4 x) { - return mix(acosh(x), vec4(0.0f), lessThan(x, vec4(1.0f))); + return tint_select(acosh(x), vec4(0.0f), lessThan(x, vec4(1.0f))); } layout(binding = 0, std430) buffer prevent_dce_block_ssbo { @@ -54,8 +64,13 @@ void main() { } #version 310 es +vec4 tint_select(vec4 param_0, vec4 param_1, bvec4 param_2) { + return vec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + vec4 tint_acosh(vec4 x) { - return mix(acosh(x), vec4(0.0f), lessThan(x, vec4(1.0f))); + return tint_select(acosh(x), vec4(0.0f), lessThan(x, vec4(1.0f))); } layout(binding = 0, std430) buffer prevent_dce_block_ssbo { diff --git a/test/tint/builtins/gen/var/acosh/de60d8.wgsl.expected.glsl b/test/tint/builtins/gen/var/acosh/de60d8.wgsl.expected.glsl index 711447dacc..95d73e97f2 100644 --- a/test/tint/builtins/gen/var/acosh/de60d8.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/acosh/de60d8.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es #extension GL_AMD_gpu_shader_half_float : require +f16vec4 tint_select(f16vec4 param_0, f16vec4 param_1, bvec4 param_2) { + return f16vec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + f16vec4 tint_acosh(f16vec4 x) { - return mix(acosh(x), f16vec4(0.0hf), lessThan(x, f16vec4(1.0hf))); + return tint_select(acosh(x), f16vec4(0.0hf), lessThan(x, f16vec4(1.0hf))); } layout(binding = 0, std430) buffer prevent_dce_block_ssbo { @@ -32,8 +37,13 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require precision mediump float; +f16vec4 tint_select(f16vec4 param_0, f16vec4 param_1, bvec4 param_2) { + return f16vec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + f16vec4 tint_acosh(f16vec4 x) { - return mix(acosh(x), f16vec4(0.0hf), lessThan(x, f16vec4(1.0hf))); + return tint_select(acosh(x), f16vec4(0.0hf), lessThan(x, f16vec4(1.0hf))); } layout(binding = 0, std430) buffer prevent_dce_block_ssbo { @@ -57,8 +67,13 @@ void main() { #version 310 es #extension GL_AMD_gpu_shader_half_float : require +f16vec4 tint_select(f16vec4 param_0, f16vec4 param_1, bvec4 param_2) { + return f16vec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + f16vec4 tint_acosh(f16vec4 x) { - return mix(acosh(x), f16vec4(0.0hf), lessThan(x, f16vec4(1.0hf))); + return tint_select(acosh(x), f16vec4(0.0hf), lessThan(x, f16vec4(1.0hf))); } layout(binding = 0, std430) buffer prevent_dce_block_ssbo { diff --git a/test/tint/builtins/gen/var/acosh/e38f5c.wgsl.expected.glsl b/test/tint/builtins/gen/var/acosh/e38f5c.wgsl.expected.glsl index fdf33f8098..a604103231 100644 --- a/test/tint/builtins/gen/var/acosh/e38f5c.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/acosh/e38f5c.wgsl.expected.glsl @@ -1,7 +1,12 @@ #version 310 es +vec3 tint_select(vec3 param_0, vec3 param_1, bvec3 param_2) { + return vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + vec3 tint_acosh(vec3 x) { - return mix(acosh(x), vec3(0.0f), lessThan(x, vec3(1.0f))); + return tint_select(acosh(x), vec3(0.0f), lessThan(x, vec3(1.0f))); } layout(binding = 0, std430) buffer prevent_dce_block_ssbo { @@ -30,8 +35,13 @@ void main() { #version 310 es precision mediump float; +vec3 tint_select(vec3 param_0, vec3 param_1, bvec3 param_2) { + return vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + vec3 tint_acosh(vec3 x) { - return mix(acosh(x), vec3(0.0f), lessThan(x, vec3(1.0f))); + return tint_select(acosh(x), vec3(0.0f), lessThan(x, vec3(1.0f))); } layout(binding = 0, std430) buffer prevent_dce_block_ssbo { @@ -54,8 +64,13 @@ void main() { } #version 310 es +vec3 tint_select(vec3 param_0, vec3 param_1, bvec3 param_2) { + return vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + vec3 tint_acosh(vec3 x) { - return mix(acosh(x), vec3(0.0f), lessThan(x, vec3(1.0f))); + return tint_select(acosh(x), vec3(0.0f), lessThan(x, vec3(1.0f))); } layout(binding = 0, std430) buffer prevent_dce_block_ssbo { diff --git a/test/tint/builtins/gen/var/acosh/f56574.wgsl.expected.glsl b/test/tint/builtins/gen/var/acosh/f56574.wgsl.expected.glsl index 80c879a365..e270d0852c 100644 --- a/test/tint/builtins/gen/var/acosh/f56574.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/acosh/f56574.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es #extension GL_AMD_gpu_shader_half_float : require +f16vec3 tint_select(f16vec3 param_0, f16vec3 param_1, bvec3 param_2) { + return f16vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + f16vec3 tint_acosh(f16vec3 x) { - return mix(acosh(x), f16vec3(0.0hf), lessThan(x, f16vec3(1.0hf))); + return tint_select(acosh(x), f16vec3(0.0hf), lessThan(x, f16vec3(1.0hf))); } layout(binding = 0, std430) buffer prevent_dce_block_ssbo { @@ -32,8 +37,13 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require precision mediump float; +f16vec3 tint_select(f16vec3 param_0, f16vec3 param_1, bvec3 param_2) { + return f16vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + f16vec3 tint_acosh(f16vec3 x) { - return mix(acosh(x), f16vec3(0.0hf), lessThan(x, f16vec3(1.0hf))); + return tint_select(acosh(x), f16vec3(0.0hf), lessThan(x, f16vec3(1.0hf))); } layout(binding = 0, std430) buffer prevent_dce_block_ssbo { @@ -57,8 +67,13 @@ void main() { #version 310 es #extension GL_AMD_gpu_shader_half_float : require +f16vec3 tint_select(f16vec3 param_0, f16vec3 param_1, bvec3 param_2) { + return f16vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + f16vec3 tint_acosh(f16vec3 x) { - return mix(acosh(x), f16vec3(0.0hf), lessThan(x, f16vec3(1.0hf))); + return tint_select(acosh(x), f16vec3(0.0hf), lessThan(x, f16vec3(1.0hf))); } layout(binding = 0, std430) buffer prevent_dce_block_ssbo { diff --git a/test/tint/builtins/gen/var/atanh/440cca.wgsl.expected.glsl b/test/tint/builtins/gen/var/atanh/440cca.wgsl.expected.glsl index 256f348b40..cf1cfda7bb 100644 --- a/test/tint/builtins/gen/var/atanh/440cca.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/atanh/440cca.wgsl.expected.glsl @@ -1,7 +1,12 @@ #version 310 es +vec3 tint_select(vec3 param_0, vec3 param_1, bvec3 param_2) { + return vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + vec3 tint_atanh(vec3 x) { - return mix(atanh(x), vec3(0.0f), greaterThanEqual(x, vec3(1.0f))); + return tint_select(atanh(x), vec3(0.0f), greaterThanEqual(x, vec3(1.0f))); } layout(binding = 0, std430) buffer prevent_dce_block_ssbo { @@ -30,8 +35,13 @@ void main() { #version 310 es precision mediump float; +vec3 tint_select(vec3 param_0, vec3 param_1, bvec3 param_2) { + return vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + vec3 tint_atanh(vec3 x) { - return mix(atanh(x), vec3(0.0f), greaterThanEqual(x, vec3(1.0f))); + return tint_select(atanh(x), vec3(0.0f), greaterThanEqual(x, vec3(1.0f))); } layout(binding = 0, std430) buffer prevent_dce_block_ssbo { @@ -54,8 +64,13 @@ void main() { } #version 310 es +vec3 tint_select(vec3 param_0, vec3 param_1, bvec3 param_2) { + return vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + vec3 tint_atanh(vec3 x) { - return mix(atanh(x), vec3(0.0f), greaterThanEqual(x, vec3(1.0f))); + return tint_select(atanh(x), vec3(0.0f), greaterThanEqual(x, vec3(1.0f))); } layout(binding = 0, std430) buffer prevent_dce_block_ssbo { diff --git a/test/tint/builtins/gen/var/atanh/5bf88d.wgsl.expected.glsl b/test/tint/builtins/gen/var/atanh/5bf88d.wgsl.expected.glsl index f8fd950407..dc8f5790e5 100644 --- a/test/tint/builtins/gen/var/atanh/5bf88d.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/atanh/5bf88d.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es #extension GL_AMD_gpu_shader_half_float : require +f16vec2 tint_select(f16vec2 param_0, f16vec2 param_1, bvec2 param_2) { + return f16vec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + f16vec2 tint_atanh(f16vec2 x) { - return mix(atanh(x), f16vec2(0.0hf), greaterThanEqual(x, f16vec2(1.0hf))); + return tint_select(atanh(x), f16vec2(0.0hf), greaterThanEqual(x, f16vec2(1.0hf))); } layout(binding = 0, std430) buffer prevent_dce_block_ssbo { @@ -32,8 +37,13 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require precision mediump float; +f16vec2 tint_select(f16vec2 param_0, f16vec2 param_1, bvec2 param_2) { + return f16vec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + f16vec2 tint_atanh(f16vec2 x) { - return mix(atanh(x), f16vec2(0.0hf), greaterThanEqual(x, f16vec2(1.0hf))); + return tint_select(atanh(x), f16vec2(0.0hf), greaterThanEqual(x, f16vec2(1.0hf))); } layout(binding = 0, std430) buffer prevent_dce_block_ssbo { @@ -57,8 +67,13 @@ void main() { #version 310 es #extension GL_AMD_gpu_shader_half_float : require +f16vec2 tint_select(f16vec2 param_0, f16vec2 param_1, bvec2 param_2) { + return f16vec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + f16vec2 tint_atanh(f16vec2 x) { - return mix(atanh(x), f16vec2(0.0hf), greaterThanEqual(x, f16vec2(1.0hf))); + return tint_select(atanh(x), f16vec2(0.0hf), greaterThanEqual(x, f16vec2(1.0hf))); } layout(binding = 0, std430) buffer prevent_dce_block_ssbo { diff --git a/test/tint/builtins/gen/var/atanh/c0e634.wgsl.expected.glsl b/test/tint/builtins/gen/var/atanh/c0e634.wgsl.expected.glsl index a4da60cd55..c6a4bc5c1c 100644 --- a/test/tint/builtins/gen/var/atanh/c0e634.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/atanh/c0e634.wgsl.expected.glsl @@ -1,7 +1,12 @@ #version 310 es +vec2 tint_select(vec2 param_0, vec2 param_1, bvec2 param_2) { + return vec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + vec2 tint_atanh(vec2 x) { - return mix(atanh(x), vec2(0.0f), greaterThanEqual(x, vec2(1.0f))); + return tint_select(atanh(x), vec2(0.0f), greaterThanEqual(x, vec2(1.0f))); } layout(binding = 0, std430) buffer prevent_dce_block_ssbo { @@ -30,8 +35,13 @@ void main() { #version 310 es precision mediump float; +vec2 tint_select(vec2 param_0, vec2 param_1, bvec2 param_2) { + return vec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + vec2 tint_atanh(vec2 x) { - return mix(atanh(x), vec2(0.0f), greaterThanEqual(x, vec2(1.0f))); + return tint_select(atanh(x), vec2(0.0f), greaterThanEqual(x, vec2(1.0f))); } layout(binding = 0, std430) buffer prevent_dce_block_ssbo { @@ -54,8 +64,13 @@ void main() { } #version 310 es +vec2 tint_select(vec2 param_0, vec2 param_1, bvec2 param_2) { + return vec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + vec2 tint_atanh(vec2 x) { - return mix(atanh(x), vec2(0.0f), greaterThanEqual(x, vec2(1.0f))); + return tint_select(atanh(x), vec2(0.0f), greaterThanEqual(x, vec2(1.0f))); } layout(binding = 0, std430) buffer prevent_dce_block_ssbo { diff --git a/test/tint/builtins/gen/var/atanh/e3b450.wgsl.expected.glsl b/test/tint/builtins/gen/var/atanh/e3b450.wgsl.expected.glsl index 2c42b55298..5de83b15e5 100644 --- a/test/tint/builtins/gen/var/atanh/e3b450.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/atanh/e3b450.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es #extension GL_AMD_gpu_shader_half_float : require +f16vec4 tint_select(f16vec4 param_0, f16vec4 param_1, bvec4 param_2) { + return f16vec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + f16vec4 tint_atanh(f16vec4 x) { - return mix(atanh(x), f16vec4(0.0hf), greaterThanEqual(x, f16vec4(1.0hf))); + return tint_select(atanh(x), f16vec4(0.0hf), greaterThanEqual(x, f16vec4(1.0hf))); } layout(binding = 0, std430) buffer prevent_dce_block_ssbo { @@ -32,8 +37,13 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require precision mediump float; +f16vec4 tint_select(f16vec4 param_0, f16vec4 param_1, bvec4 param_2) { + return f16vec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + f16vec4 tint_atanh(f16vec4 x) { - return mix(atanh(x), f16vec4(0.0hf), greaterThanEqual(x, f16vec4(1.0hf))); + return tint_select(atanh(x), f16vec4(0.0hf), greaterThanEqual(x, f16vec4(1.0hf))); } layout(binding = 0, std430) buffer prevent_dce_block_ssbo { @@ -57,8 +67,13 @@ void main() { #version 310 es #extension GL_AMD_gpu_shader_half_float : require +f16vec4 tint_select(f16vec4 param_0, f16vec4 param_1, bvec4 param_2) { + return f16vec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + f16vec4 tint_atanh(f16vec4 x) { - return mix(atanh(x), f16vec4(0.0hf), greaterThanEqual(x, f16vec4(1.0hf))); + return tint_select(atanh(x), f16vec4(0.0hf), greaterThanEqual(x, f16vec4(1.0hf))); } layout(binding = 0, std430) buffer prevent_dce_block_ssbo { diff --git a/test/tint/builtins/gen/var/atanh/ec4b06.wgsl.expected.glsl b/test/tint/builtins/gen/var/atanh/ec4b06.wgsl.expected.glsl index 84c1bc5a04..799000e990 100644 --- a/test/tint/builtins/gen/var/atanh/ec4b06.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/atanh/ec4b06.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es #extension GL_AMD_gpu_shader_half_float : require +f16vec3 tint_select(f16vec3 param_0, f16vec3 param_1, bvec3 param_2) { + return f16vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + f16vec3 tint_atanh(f16vec3 x) { - return mix(atanh(x), f16vec3(0.0hf), greaterThanEqual(x, f16vec3(1.0hf))); + return tint_select(atanh(x), f16vec3(0.0hf), greaterThanEqual(x, f16vec3(1.0hf))); } layout(binding = 0, std430) buffer prevent_dce_block_ssbo { @@ -32,8 +37,13 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require precision mediump float; +f16vec3 tint_select(f16vec3 param_0, f16vec3 param_1, bvec3 param_2) { + return f16vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + f16vec3 tint_atanh(f16vec3 x) { - return mix(atanh(x), f16vec3(0.0hf), greaterThanEqual(x, f16vec3(1.0hf))); + return tint_select(atanh(x), f16vec3(0.0hf), greaterThanEqual(x, f16vec3(1.0hf))); } layout(binding = 0, std430) buffer prevent_dce_block_ssbo { @@ -57,8 +67,13 @@ void main() { #version 310 es #extension GL_AMD_gpu_shader_half_float : require +f16vec3 tint_select(f16vec3 param_0, f16vec3 param_1, bvec3 param_2) { + return f16vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + f16vec3 tint_atanh(f16vec3 x) { - return mix(atanh(x), f16vec3(0.0hf), greaterThanEqual(x, f16vec3(1.0hf))); + return tint_select(atanh(x), f16vec3(0.0hf), greaterThanEqual(x, f16vec3(1.0hf))); } layout(binding = 0, std430) buffer prevent_dce_block_ssbo { diff --git a/test/tint/builtins/gen/var/atanh/f3e01b.wgsl.expected.glsl b/test/tint/builtins/gen/var/atanh/f3e01b.wgsl.expected.glsl index 480d3d3b1c..de6a26b7b1 100644 --- a/test/tint/builtins/gen/var/atanh/f3e01b.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/atanh/f3e01b.wgsl.expected.glsl @@ -1,7 +1,12 @@ #version 310 es +vec4 tint_select(vec4 param_0, vec4 param_1, bvec4 param_2) { + return vec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + vec4 tint_atanh(vec4 x) { - return mix(atanh(x), vec4(0.0f), greaterThanEqual(x, vec4(1.0f))); + return tint_select(atanh(x), vec4(0.0f), greaterThanEqual(x, vec4(1.0f))); } layout(binding = 0, std430) buffer prevent_dce_block_ssbo { @@ -30,8 +35,13 @@ void main() { #version 310 es precision mediump float; +vec4 tint_select(vec4 param_0, vec4 param_1, bvec4 param_2) { + return vec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + vec4 tint_atanh(vec4 x) { - return mix(atanh(x), vec4(0.0f), greaterThanEqual(x, vec4(1.0f))); + return tint_select(atanh(x), vec4(0.0f), greaterThanEqual(x, vec4(1.0f))); } layout(binding = 0, std430) buffer prevent_dce_block_ssbo { @@ -54,8 +64,13 @@ void main() { } #version 310 es +vec4 tint_select(vec4 param_0, vec4 param_1, bvec4 param_2) { + return vec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + vec4 tint_atanh(vec4 x) { - return mix(atanh(x), vec4(0.0f), greaterThanEqual(x, vec4(1.0f))); + return tint_select(atanh(x), vec4(0.0f), greaterThanEqual(x, vec4(1.0f))); } layout(binding = 0, std430) buffer prevent_dce_block_ssbo { diff --git a/test/tint/builtins/gen/var/countLeadingZeros/70783f.wgsl.expected.glsl b/test/tint/builtins/gen/var/countLeadingZeros/70783f.wgsl.expected.glsl index bdf6581fc8..f9cd05986c 100644 --- a/test/tint/builtins/gen/var/countLeadingZeros/70783f.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/countLeadingZeros/70783f.wgsl.expected.glsl @@ -1,17 +1,22 @@ #version 310 es +uvec2 tint_select(uvec2 param_0, uvec2 param_1, bvec2 param_2) { + return uvec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + uvec2 tint_count_leading_zeros(uvec2 v) { uvec2 x = uvec2(v); - uvec2 b16 = mix(uvec2(0u), uvec2(16u), lessThanEqual(x, uvec2(65535u))); + uvec2 b16 = tint_select(uvec2(0u), uvec2(16u), lessThanEqual(x, uvec2(65535u))); x = (x << b16); - uvec2 b8 = mix(uvec2(0u), uvec2(8u), lessThanEqual(x, uvec2(16777215u))); + uvec2 b8 = tint_select(uvec2(0u), uvec2(8u), lessThanEqual(x, uvec2(16777215u))); x = (x << b8); - uvec2 b4 = mix(uvec2(0u), uvec2(4u), lessThanEqual(x, uvec2(268435455u))); + uvec2 b4 = tint_select(uvec2(0u), uvec2(4u), lessThanEqual(x, uvec2(268435455u))); x = (x << b4); - uvec2 b2 = mix(uvec2(0u), uvec2(2u), lessThanEqual(x, uvec2(1073741823u))); + uvec2 b2 = tint_select(uvec2(0u), uvec2(2u), lessThanEqual(x, uvec2(1073741823u))); x = (x << b2); - uvec2 b1 = mix(uvec2(0u), uvec2(1u), lessThanEqual(x, uvec2(2147483647u))); - uvec2 is_zero = mix(uvec2(0u), uvec2(1u), equal(x, uvec2(0u))); + uvec2 b1 = tint_select(uvec2(0u), uvec2(1u), lessThanEqual(x, uvec2(2147483647u))); + uvec2 is_zero = tint_select(uvec2(0u), uvec2(1u), equal(x, uvec2(0u))); return uvec2((((((b16 | b8) | b4) | b2) | b1) + is_zero)); } @@ -41,18 +46,23 @@ void main() { #version 310 es precision mediump float; +uvec2 tint_select(uvec2 param_0, uvec2 param_1, bvec2 param_2) { + return uvec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + uvec2 tint_count_leading_zeros(uvec2 v) { uvec2 x = uvec2(v); - uvec2 b16 = mix(uvec2(0u), uvec2(16u), lessThanEqual(x, uvec2(65535u))); + uvec2 b16 = tint_select(uvec2(0u), uvec2(16u), lessThanEqual(x, uvec2(65535u))); x = (x << b16); - uvec2 b8 = mix(uvec2(0u), uvec2(8u), lessThanEqual(x, uvec2(16777215u))); + uvec2 b8 = tint_select(uvec2(0u), uvec2(8u), lessThanEqual(x, uvec2(16777215u))); x = (x << b8); - uvec2 b4 = mix(uvec2(0u), uvec2(4u), lessThanEqual(x, uvec2(268435455u))); + uvec2 b4 = tint_select(uvec2(0u), uvec2(4u), lessThanEqual(x, uvec2(268435455u))); x = (x << b4); - uvec2 b2 = mix(uvec2(0u), uvec2(2u), lessThanEqual(x, uvec2(1073741823u))); + uvec2 b2 = tint_select(uvec2(0u), uvec2(2u), lessThanEqual(x, uvec2(1073741823u))); x = (x << b2); - uvec2 b1 = mix(uvec2(0u), uvec2(1u), lessThanEqual(x, uvec2(2147483647u))); - uvec2 is_zero = mix(uvec2(0u), uvec2(1u), equal(x, uvec2(0u))); + uvec2 b1 = tint_select(uvec2(0u), uvec2(1u), lessThanEqual(x, uvec2(2147483647u))); + uvec2 is_zero = tint_select(uvec2(0u), uvec2(1u), equal(x, uvec2(0u))); return uvec2((((((b16 | b8) | b4) | b2) | b1) + is_zero)); } @@ -76,18 +86,23 @@ void main() { } #version 310 es +uvec2 tint_select(uvec2 param_0, uvec2 param_1, bvec2 param_2) { + return uvec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + uvec2 tint_count_leading_zeros(uvec2 v) { uvec2 x = uvec2(v); - uvec2 b16 = mix(uvec2(0u), uvec2(16u), lessThanEqual(x, uvec2(65535u))); + uvec2 b16 = tint_select(uvec2(0u), uvec2(16u), lessThanEqual(x, uvec2(65535u))); x = (x << b16); - uvec2 b8 = mix(uvec2(0u), uvec2(8u), lessThanEqual(x, uvec2(16777215u))); + uvec2 b8 = tint_select(uvec2(0u), uvec2(8u), lessThanEqual(x, uvec2(16777215u))); x = (x << b8); - uvec2 b4 = mix(uvec2(0u), uvec2(4u), lessThanEqual(x, uvec2(268435455u))); + uvec2 b4 = tint_select(uvec2(0u), uvec2(4u), lessThanEqual(x, uvec2(268435455u))); x = (x << b4); - uvec2 b2 = mix(uvec2(0u), uvec2(2u), lessThanEqual(x, uvec2(1073741823u))); + uvec2 b2 = tint_select(uvec2(0u), uvec2(2u), lessThanEqual(x, uvec2(1073741823u))); x = (x << b2); - uvec2 b1 = mix(uvec2(0u), uvec2(1u), lessThanEqual(x, uvec2(2147483647u))); - uvec2 is_zero = mix(uvec2(0u), uvec2(1u), equal(x, uvec2(0u))); + uvec2 b1 = tint_select(uvec2(0u), uvec2(1u), lessThanEqual(x, uvec2(2147483647u))); + uvec2 is_zero = tint_select(uvec2(0u), uvec2(1u), equal(x, uvec2(0u))); return uvec2((((((b16 | b8) | b4) | b2) | b1) + is_zero)); } diff --git a/test/tint/builtins/gen/var/countLeadingZeros/7c38a6.wgsl.expected.glsl b/test/tint/builtins/gen/var/countLeadingZeros/7c38a6.wgsl.expected.glsl index a54c6d28c4..8a13b9335d 100644 --- a/test/tint/builtins/gen/var/countLeadingZeros/7c38a6.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/countLeadingZeros/7c38a6.wgsl.expected.glsl @@ -1,17 +1,22 @@ #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + ivec3 tint_count_leading_zeros(ivec3 v) { uvec3 x = uvec3(v); - uvec3 b16 = mix(uvec3(0u), uvec3(16u), lessThanEqual(x, uvec3(65535u))); + uvec3 b16 = tint_select(uvec3(0u), uvec3(16u), lessThanEqual(x, uvec3(65535u))); x = (x << b16); - uvec3 b8 = mix(uvec3(0u), uvec3(8u), lessThanEqual(x, uvec3(16777215u))); + uvec3 b8 = tint_select(uvec3(0u), uvec3(8u), lessThanEqual(x, uvec3(16777215u))); x = (x << b8); - uvec3 b4 = mix(uvec3(0u), uvec3(4u), lessThanEqual(x, uvec3(268435455u))); + uvec3 b4 = tint_select(uvec3(0u), uvec3(4u), lessThanEqual(x, uvec3(268435455u))); x = (x << b4); - uvec3 b2 = mix(uvec3(0u), uvec3(2u), lessThanEqual(x, uvec3(1073741823u))); + uvec3 b2 = tint_select(uvec3(0u), uvec3(2u), lessThanEqual(x, uvec3(1073741823u))); x = (x << b2); - uvec3 b1 = mix(uvec3(0u), uvec3(1u), lessThanEqual(x, uvec3(2147483647u))); - uvec3 is_zero = mix(uvec3(0u), uvec3(1u), equal(x, uvec3(0u))); + uvec3 b1 = tint_select(uvec3(0u), uvec3(1u), lessThanEqual(x, uvec3(2147483647u))); + uvec3 is_zero = tint_select(uvec3(0u), uvec3(1u), equal(x, uvec3(0u))); return ivec3((((((b16 | b8) | b4) | b2) | b1) + is_zero)); } @@ -41,18 +46,23 @@ void main() { #version 310 es precision mediump float; +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + ivec3 tint_count_leading_zeros(ivec3 v) { uvec3 x = uvec3(v); - uvec3 b16 = mix(uvec3(0u), uvec3(16u), lessThanEqual(x, uvec3(65535u))); + uvec3 b16 = tint_select(uvec3(0u), uvec3(16u), lessThanEqual(x, uvec3(65535u))); x = (x << b16); - uvec3 b8 = mix(uvec3(0u), uvec3(8u), lessThanEqual(x, uvec3(16777215u))); + uvec3 b8 = tint_select(uvec3(0u), uvec3(8u), lessThanEqual(x, uvec3(16777215u))); x = (x << b8); - uvec3 b4 = mix(uvec3(0u), uvec3(4u), lessThanEqual(x, uvec3(268435455u))); + uvec3 b4 = tint_select(uvec3(0u), uvec3(4u), lessThanEqual(x, uvec3(268435455u))); x = (x << b4); - uvec3 b2 = mix(uvec3(0u), uvec3(2u), lessThanEqual(x, uvec3(1073741823u))); + uvec3 b2 = tint_select(uvec3(0u), uvec3(2u), lessThanEqual(x, uvec3(1073741823u))); x = (x << b2); - uvec3 b1 = mix(uvec3(0u), uvec3(1u), lessThanEqual(x, uvec3(2147483647u))); - uvec3 is_zero = mix(uvec3(0u), uvec3(1u), equal(x, uvec3(0u))); + uvec3 b1 = tint_select(uvec3(0u), uvec3(1u), lessThanEqual(x, uvec3(2147483647u))); + uvec3 is_zero = tint_select(uvec3(0u), uvec3(1u), equal(x, uvec3(0u))); return ivec3((((((b16 | b8) | b4) | b2) | b1) + is_zero)); } @@ -76,18 +86,23 @@ void main() { } #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + ivec3 tint_count_leading_zeros(ivec3 v) { uvec3 x = uvec3(v); - uvec3 b16 = mix(uvec3(0u), uvec3(16u), lessThanEqual(x, uvec3(65535u))); + uvec3 b16 = tint_select(uvec3(0u), uvec3(16u), lessThanEqual(x, uvec3(65535u))); x = (x << b16); - uvec3 b8 = mix(uvec3(0u), uvec3(8u), lessThanEqual(x, uvec3(16777215u))); + uvec3 b8 = tint_select(uvec3(0u), uvec3(8u), lessThanEqual(x, uvec3(16777215u))); x = (x << b8); - uvec3 b4 = mix(uvec3(0u), uvec3(4u), lessThanEqual(x, uvec3(268435455u))); + uvec3 b4 = tint_select(uvec3(0u), uvec3(4u), lessThanEqual(x, uvec3(268435455u))); x = (x << b4); - uvec3 b2 = mix(uvec3(0u), uvec3(2u), lessThanEqual(x, uvec3(1073741823u))); + uvec3 b2 = tint_select(uvec3(0u), uvec3(2u), lessThanEqual(x, uvec3(1073741823u))); x = (x << b2); - uvec3 b1 = mix(uvec3(0u), uvec3(1u), lessThanEqual(x, uvec3(2147483647u))); - uvec3 is_zero = mix(uvec3(0u), uvec3(1u), equal(x, uvec3(0u))); + uvec3 b1 = tint_select(uvec3(0u), uvec3(1u), lessThanEqual(x, uvec3(2147483647u))); + uvec3 is_zero = tint_select(uvec3(0u), uvec3(1u), equal(x, uvec3(0u))); return ivec3((((((b16 | b8) | b4) | b2) | b1) + is_zero)); } diff --git a/test/tint/builtins/gen/var/countLeadingZeros/858d40.wgsl.expected.glsl b/test/tint/builtins/gen/var/countLeadingZeros/858d40.wgsl.expected.glsl index 3d418d3307..5d0dbea991 100644 --- a/test/tint/builtins/gen/var/countLeadingZeros/858d40.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/countLeadingZeros/858d40.wgsl.expected.glsl @@ -1,17 +1,22 @@ #version 310 es +uvec2 tint_select(uvec2 param_0, uvec2 param_1, bvec2 param_2) { + return uvec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + ivec2 tint_count_leading_zeros(ivec2 v) { uvec2 x = uvec2(v); - uvec2 b16 = mix(uvec2(0u), uvec2(16u), lessThanEqual(x, uvec2(65535u))); + uvec2 b16 = tint_select(uvec2(0u), uvec2(16u), lessThanEqual(x, uvec2(65535u))); x = (x << b16); - uvec2 b8 = mix(uvec2(0u), uvec2(8u), lessThanEqual(x, uvec2(16777215u))); + uvec2 b8 = tint_select(uvec2(0u), uvec2(8u), lessThanEqual(x, uvec2(16777215u))); x = (x << b8); - uvec2 b4 = mix(uvec2(0u), uvec2(4u), lessThanEqual(x, uvec2(268435455u))); + uvec2 b4 = tint_select(uvec2(0u), uvec2(4u), lessThanEqual(x, uvec2(268435455u))); x = (x << b4); - uvec2 b2 = mix(uvec2(0u), uvec2(2u), lessThanEqual(x, uvec2(1073741823u))); + uvec2 b2 = tint_select(uvec2(0u), uvec2(2u), lessThanEqual(x, uvec2(1073741823u))); x = (x << b2); - uvec2 b1 = mix(uvec2(0u), uvec2(1u), lessThanEqual(x, uvec2(2147483647u))); - uvec2 is_zero = mix(uvec2(0u), uvec2(1u), equal(x, uvec2(0u))); + uvec2 b1 = tint_select(uvec2(0u), uvec2(1u), lessThanEqual(x, uvec2(2147483647u))); + uvec2 is_zero = tint_select(uvec2(0u), uvec2(1u), equal(x, uvec2(0u))); return ivec2((((((b16 | b8) | b4) | b2) | b1) + is_zero)); } @@ -41,18 +46,23 @@ void main() { #version 310 es precision mediump float; +uvec2 tint_select(uvec2 param_0, uvec2 param_1, bvec2 param_2) { + return uvec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + ivec2 tint_count_leading_zeros(ivec2 v) { uvec2 x = uvec2(v); - uvec2 b16 = mix(uvec2(0u), uvec2(16u), lessThanEqual(x, uvec2(65535u))); + uvec2 b16 = tint_select(uvec2(0u), uvec2(16u), lessThanEqual(x, uvec2(65535u))); x = (x << b16); - uvec2 b8 = mix(uvec2(0u), uvec2(8u), lessThanEqual(x, uvec2(16777215u))); + uvec2 b8 = tint_select(uvec2(0u), uvec2(8u), lessThanEqual(x, uvec2(16777215u))); x = (x << b8); - uvec2 b4 = mix(uvec2(0u), uvec2(4u), lessThanEqual(x, uvec2(268435455u))); + uvec2 b4 = tint_select(uvec2(0u), uvec2(4u), lessThanEqual(x, uvec2(268435455u))); x = (x << b4); - uvec2 b2 = mix(uvec2(0u), uvec2(2u), lessThanEqual(x, uvec2(1073741823u))); + uvec2 b2 = tint_select(uvec2(0u), uvec2(2u), lessThanEqual(x, uvec2(1073741823u))); x = (x << b2); - uvec2 b1 = mix(uvec2(0u), uvec2(1u), lessThanEqual(x, uvec2(2147483647u))); - uvec2 is_zero = mix(uvec2(0u), uvec2(1u), equal(x, uvec2(0u))); + uvec2 b1 = tint_select(uvec2(0u), uvec2(1u), lessThanEqual(x, uvec2(2147483647u))); + uvec2 is_zero = tint_select(uvec2(0u), uvec2(1u), equal(x, uvec2(0u))); return ivec2((((((b16 | b8) | b4) | b2) | b1) + is_zero)); } @@ -76,18 +86,23 @@ void main() { } #version 310 es +uvec2 tint_select(uvec2 param_0, uvec2 param_1, bvec2 param_2) { + return uvec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + ivec2 tint_count_leading_zeros(ivec2 v) { uvec2 x = uvec2(v); - uvec2 b16 = mix(uvec2(0u), uvec2(16u), lessThanEqual(x, uvec2(65535u))); + uvec2 b16 = tint_select(uvec2(0u), uvec2(16u), lessThanEqual(x, uvec2(65535u))); x = (x << b16); - uvec2 b8 = mix(uvec2(0u), uvec2(8u), lessThanEqual(x, uvec2(16777215u))); + uvec2 b8 = tint_select(uvec2(0u), uvec2(8u), lessThanEqual(x, uvec2(16777215u))); x = (x << b8); - uvec2 b4 = mix(uvec2(0u), uvec2(4u), lessThanEqual(x, uvec2(268435455u))); + uvec2 b4 = tint_select(uvec2(0u), uvec2(4u), lessThanEqual(x, uvec2(268435455u))); x = (x << b4); - uvec2 b2 = mix(uvec2(0u), uvec2(2u), lessThanEqual(x, uvec2(1073741823u))); + uvec2 b2 = tint_select(uvec2(0u), uvec2(2u), lessThanEqual(x, uvec2(1073741823u))); x = (x << b2); - uvec2 b1 = mix(uvec2(0u), uvec2(1u), lessThanEqual(x, uvec2(2147483647u))); - uvec2 is_zero = mix(uvec2(0u), uvec2(1u), equal(x, uvec2(0u))); + uvec2 b1 = tint_select(uvec2(0u), uvec2(1u), lessThanEqual(x, uvec2(2147483647u))); + uvec2 is_zero = tint_select(uvec2(0u), uvec2(1u), equal(x, uvec2(0u))); return ivec2((((((b16 | b8) | b4) | b2) | b1) + is_zero)); } diff --git a/test/tint/builtins/gen/var/countLeadingZeros/ab6345.wgsl.expected.glsl b/test/tint/builtins/gen/var/countLeadingZeros/ab6345.wgsl.expected.glsl index 9bb06c38ac..500ced03b8 100644 --- a/test/tint/builtins/gen/var/countLeadingZeros/ab6345.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/countLeadingZeros/ab6345.wgsl.expected.glsl @@ -1,17 +1,22 @@ #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + uvec3 tint_count_leading_zeros(uvec3 v) { uvec3 x = uvec3(v); - uvec3 b16 = mix(uvec3(0u), uvec3(16u), lessThanEqual(x, uvec3(65535u))); + uvec3 b16 = tint_select(uvec3(0u), uvec3(16u), lessThanEqual(x, uvec3(65535u))); x = (x << b16); - uvec3 b8 = mix(uvec3(0u), uvec3(8u), lessThanEqual(x, uvec3(16777215u))); + uvec3 b8 = tint_select(uvec3(0u), uvec3(8u), lessThanEqual(x, uvec3(16777215u))); x = (x << b8); - uvec3 b4 = mix(uvec3(0u), uvec3(4u), lessThanEqual(x, uvec3(268435455u))); + uvec3 b4 = tint_select(uvec3(0u), uvec3(4u), lessThanEqual(x, uvec3(268435455u))); x = (x << b4); - uvec3 b2 = mix(uvec3(0u), uvec3(2u), lessThanEqual(x, uvec3(1073741823u))); + uvec3 b2 = tint_select(uvec3(0u), uvec3(2u), lessThanEqual(x, uvec3(1073741823u))); x = (x << b2); - uvec3 b1 = mix(uvec3(0u), uvec3(1u), lessThanEqual(x, uvec3(2147483647u))); - uvec3 is_zero = mix(uvec3(0u), uvec3(1u), equal(x, uvec3(0u))); + uvec3 b1 = tint_select(uvec3(0u), uvec3(1u), lessThanEqual(x, uvec3(2147483647u))); + uvec3 is_zero = tint_select(uvec3(0u), uvec3(1u), equal(x, uvec3(0u))); return uvec3((((((b16 | b8) | b4) | b2) | b1) + is_zero)); } @@ -41,18 +46,23 @@ void main() { #version 310 es precision mediump float; +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + uvec3 tint_count_leading_zeros(uvec3 v) { uvec3 x = uvec3(v); - uvec3 b16 = mix(uvec3(0u), uvec3(16u), lessThanEqual(x, uvec3(65535u))); + uvec3 b16 = tint_select(uvec3(0u), uvec3(16u), lessThanEqual(x, uvec3(65535u))); x = (x << b16); - uvec3 b8 = mix(uvec3(0u), uvec3(8u), lessThanEqual(x, uvec3(16777215u))); + uvec3 b8 = tint_select(uvec3(0u), uvec3(8u), lessThanEqual(x, uvec3(16777215u))); x = (x << b8); - uvec3 b4 = mix(uvec3(0u), uvec3(4u), lessThanEqual(x, uvec3(268435455u))); + uvec3 b4 = tint_select(uvec3(0u), uvec3(4u), lessThanEqual(x, uvec3(268435455u))); x = (x << b4); - uvec3 b2 = mix(uvec3(0u), uvec3(2u), lessThanEqual(x, uvec3(1073741823u))); + uvec3 b2 = tint_select(uvec3(0u), uvec3(2u), lessThanEqual(x, uvec3(1073741823u))); x = (x << b2); - uvec3 b1 = mix(uvec3(0u), uvec3(1u), lessThanEqual(x, uvec3(2147483647u))); - uvec3 is_zero = mix(uvec3(0u), uvec3(1u), equal(x, uvec3(0u))); + uvec3 b1 = tint_select(uvec3(0u), uvec3(1u), lessThanEqual(x, uvec3(2147483647u))); + uvec3 is_zero = tint_select(uvec3(0u), uvec3(1u), equal(x, uvec3(0u))); return uvec3((((((b16 | b8) | b4) | b2) | b1) + is_zero)); } @@ -76,18 +86,23 @@ void main() { } #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + uvec3 tint_count_leading_zeros(uvec3 v) { uvec3 x = uvec3(v); - uvec3 b16 = mix(uvec3(0u), uvec3(16u), lessThanEqual(x, uvec3(65535u))); + uvec3 b16 = tint_select(uvec3(0u), uvec3(16u), lessThanEqual(x, uvec3(65535u))); x = (x << b16); - uvec3 b8 = mix(uvec3(0u), uvec3(8u), lessThanEqual(x, uvec3(16777215u))); + uvec3 b8 = tint_select(uvec3(0u), uvec3(8u), lessThanEqual(x, uvec3(16777215u))); x = (x << b8); - uvec3 b4 = mix(uvec3(0u), uvec3(4u), lessThanEqual(x, uvec3(268435455u))); + uvec3 b4 = tint_select(uvec3(0u), uvec3(4u), lessThanEqual(x, uvec3(268435455u))); x = (x << b4); - uvec3 b2 = mix(uvec3(0u), uvec3(2u), lessThanEqual(x, uvec3(1073741823u))); + uvec3 b2 = tint_select(uvec3(0u), uvec3(2u), lessThanEqual(x, uvec3(1073741823u))); x = (x << b2); - uvec3 b1 = mix(uvec3(0u), uvec3(1u), lessThanEqual(x, uvec3(2147483647u))); - uvec3 is_zero = mix(uvec3(0u), uvec3(1u), equal(x, uvec3(0u))); + uvec3 b1 = tint_select(uvec3(0u), uvec3(1u), lessThanEqual(x, uvec3(2147483647u))); + uvec3 is_zero = tint_select(uvec3(0u), uvec3(1u), equal(x, uvec3(0u))); return uvec3((((((b16 | b8) | b4) | b2) | b1) + is_zero)); } diff --git a/test/tint/builtins/gen/var/countLeadingZeros/eab32b.wgsl.expected.glsl b/test/tint/builtins/gen/var/countLeadingZeros/eab32b.wgsl.expected.glsl index 346e9bbc62..9ff99e50d0 100644 --- a/test/tint/builtins/gen/var/countLeadingZeros/eab32b.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/countLeadingZeros/eab32b.wgsl.expected.glsl @@ -1,17 +1,22 @@ #version 310 es +uvec4 tint_select(uvec4 param_0, uvec4 param_1, bvec4 param_2) { + return uvec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + ivec4 tint_count_leading_zeros(ivec4 v) { uvec4 x = uvec4(v); - uvec4 b16 = mix(uvec4(0u), uvec4(16u), lessThanEqual(x, uvec4(65535u))); + uvec4 b16 = tint_select(uvec4(0u), uvec4(16u), lessThanEqual(x, uvec4(65535u))); x = (x << b16); - uvec4 b8 = mix(uvec4(0u), uvec4(8u), lessThanEqual(x, uvec4(16777215u))); + uvec4 b8 = tint_select(uvec4(0u), uvec4(8u), lessThanEqual(x, uvec4(16777215u))); x = (x << b8); - uvec4 b4 = mix(uvec4(0u), uvec4(4u), lessThanEqual(x, uvec4(268435455u))); + uvec4 b4 = tint_select(uvec4(0u), uvec4(4u), lessThanEqual(x, uvec4(268435455u))); x = (x << b4); - uvec4 b2 = mix(uvec4(0u), uvec4(2u), lessThanEqual(x, uvec4(1073741823u))); + uvec4 b2 = tint_select(uvec4(0u), uvec4(2u), lessThanEqual(x, uvec4(1073741823u))); x = (x << b2); - uvec4 b1 = mix(uvec4(0u), uvec4(1u), lessThanEqual(x, uvec4(2147483647u))); - uvec4 is_zero = mix(uvec4(0u), uvec4(1u), equal(x, uvec4(0u))); + uvec4 b1 = tint_select(uvec4(0u), uvec4(1u), lessThanEqual(x, uvec4(2147483647u))); + uvec4 is_zero = tint_select(uvec4(0u), uvec4(1u), equal(x, uvec4(0u))); return ivec4((((((b16 | b8) | b4) | b2) | b1) + is_zero)); } @@ -41,18 +46,23 @@ void main() { #version 310 es precision mediump float; +uvec4 tint_select(uvec4 param_0, uvec4 param_1, bvec4 param_2) { + return uvec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + ivec4 tint_count_leading_zeros(ivec4 v) { uvec4 x = uvec4(v); - uvec4 b16 = mix(uvec4(0u), uvec4(16u), lessThanEqual(x, uvec4(65535u))); + uvec4 b16 = tint_select(uvec4(0u), uvec4(16u), lessThanEqual(x, uvec4(65535u))); x = (x << b16); - uvec4 b8 = mix(uvec4(0u), uvec4(8u), lessThanEqual(x, uvec4(16777215u))); + uvec4 b8 = tint_select(uvec4(0u), uvec4(8u), lessThanEqual(x, uvec4(16777215u))); x = (x << b8); - uvec4 b4 = mix(uvec4(0u), uvec4(4u), lessThanEqual(x, uvec4(268435455u))); + uvec4 b4 = tint_select(uvec4(0u), uvec4(4u), lessThanEqual(x, uvec4(268435455u))); x = (x << b4); - uvec4 b2 = mix(uvec4(0u), uvec4(2u), lessThanEqual(x, uvec4(1073741823u))); + uvec4 b2 = tint_select(uvec4(0u), uvec4(2u), lessThanEqual(x, uvec4(1073741823u))); x = (x << b2); - uvec4 b1 = mix(uvec4(0u), uvec4(1u), lessThanEqual(x, uvec4(2147483647u))); - uvec4 is_zero = mix(uvec4(0u), uvec4(1u), equal(x, uvec4(0u))); + uvec4 b1 = tint_select(uvec4(0u), uvec4(1u), lessThanEqual(x, uvec4(2147483647u))); + uvec4 is_zero = tint_select(uvec4(0u), uvec4(1u), equal(x, uvec4(0u))); return ivec4((((((b16 | b8) | b4) | b2) | b1) + is_zero)); } @@ -76,18 +86,23 @@ void main() { } #version 310 es +uvec4 tint_select(uvec4 param_0, uvec4 param_1, bvec4 param_2) { + return uvec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + ivec4 tint_count_leading_zeros(ivec4 v) { uvec4 x = uvec4(v); - uvec4 b16 = mix(uvec4(0u), uvec4(16u), lessThanEqual(x, uvec4(65535u))); + uvec4 b16 = tint_select(uvec4(0u), uvec4(16u), lessThanEqual(x, uvec4(65535u))); x = (x << b16); - uvec4 b8 = mix(uvec4(0u), uvec4(8u), lessThanEqual(x, uvec4(16777215u))); + uvec4 b8 = tint_select(uvec4(0u), uvec4(8u), lessThanEqual(x, uvec4(16777215u))); x = (x << b8); - uvec4 b4 = mix(uvec4(0u), uvec4(4u), lessThanEqual(x, uvec4(268435455u))); + uvec4 b4 = tint_select(uvec4(0u), uvec4(4u), lessThanEqual(x, uvec4(268435455u))); x = (x << b4); - uvec4 b2 = mix(uvec4(0u), uvec4(2u), lessThanEqual(x, uvec4(1073741823u))); + uvec4 b2 = tint_select(uvec4(0u), uvec4(2u), lessThanEqual(x, uvec4(1073741823u))); x = (x << b2); - uvec4 b1 = mix(uvec4(0u), uvec4(1u), lessThanEqual(x, uvec4(2147483647u))); - uvec4 is_zero = mix(uvec4(0u), uvec4(1u), equal(x, uvec4(0u))); + uvec4 b1 = tint_select(uvec4(0u), uvec4(1u), lessThanEqual(x, uvec4(2147483647u))); + uvec4 is_zero = tint_select(uvec4(0u), uvec4(1u), equal(x, uvec4(0u))); return ivec4((((((b16 | b8) | b4) | b2) | b1) + is_zero)); } diff --git a/test/tint/builtins/gen/var/countLeadingZeros/f70103.wgsl.expected.glsl b/test/tint/builtins/gen/var/countLeadingZeros/f70103.wgsl.expected.glsl index 2ba9bb6421..6a6fc4a2e0 100644 --- a/test/tint/builtins/gen/var/countLeadingZeros/f70103.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/countLeadingZeros/f70103.wgsl.expected.glsl @@ -1,17 +1,22 @@ #version 310 es +uvec4 tint_select(uvec4 param_0, uvec4 param_1, bvec4 param_2) { + return uvec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + uvec4 tint_count_leading_zeros(uvec4 v) { uvec4 x = uvec4(v); - uvec4 b16 = mix(uvec4(0u), uvec4(16u), lessThanEqual(x, uvec4(65535u))); + uvec4 b16 = tint_select(uvec4(0u), uvec4(16u), lessThanEqual(x, uvec4(65535u))); x = (x << b16); - uvec4 b8 = mix(uvec4(0u), uvec4(8u), lessThanEqual(x, uvec4(16777215u))); + uvec4 b8 = tint_select(uvec4(0u), uvec4(8u), lessThanEqual(x, uvec4(16777215u))); x = (x << b8); - uvec4 b4 = mix(uvec4(0u), uvec4(4u), lessThanEqual(x, uvec4(268435455u))); + uvec4 b4 = tint_select(uvec4(0u), uvec4(4u), lessThanEqual(x, uvec4(268435455u))); x = (x << b4); - uvec4 b2 = mix(uvec4(0u), uvec4(2u), lessThanEqual(x, uvec4(1073741823u))); + uvec4 b2 = tint_select(uvec4(0u), uvec4(2u), lessThanEqual(x, uvec4(1073741823u))); x = (x << b2); - uvec4 b1 = mix(uvec4(0u), uvec4(1u), lessThanEqual(x, uvec4(2147483647u))); - uvec4 is_zero = mix(uvec4(0u), uvec4(1u), equal(x, uvec4(0u))); + uvec4 b1 = tint_select(uvec4(0u), uvec4(1u), lessThanEqual(x, uvec4(2147483647u))); + uvec4 is_zero = tint_select(uvec4(0u), uvec4(1u), equal(x, uvec4(0u))); return uvec4((((((b16 | b8) | b4) | b2) | b1) + is_zero)); } @@ -41,18 +46,23 @@ void main() { #version 310 es precision mediump float; +uvec4 tint_select(uvec4 param_0, uvec4 param_1, bvec4 param_2) { + return uvec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + uvec4 tint_count_leading_zeros(uvec4 v) { uvec4 x = uvec4(v); - uvec4 b16 = mix(uvec4(0u), uvec4(16u), lessThanEqual(x, uvec4(65535u))); + uvec4 b16 = tint_select(uvec4(0u), uvec4(16u), lessThanEqual(x, uvec4(65535u))); x = (x << b16); - uvec4 b8 = mix(uvec4(0u), uvec4(8u), lessThanEqual(x, uvec4(16777215u))); + uvec4 b8 = tint_select(uvec4(0u), uvec4(8u), lessThanEqual(x, uvec4(16777215u))); x = (x << b8); - uvec4 b4 = mix(uvec4(0u), uvec4(4u), lessThanEqual(x, uvec4(268435455u))); + uvec4 b4 = tint_select(uvec4(0u), uvec4(4u), lessThanEqual(x, uvec4(268435455u))); x = (x << b4); - uvec4 b2 = mix(uvec4(0u), uvec4(2u), lessThanEqual(x, uvec4(1073741823u))); + uvec4 b2 = tint_select(uvec4(0u), uvec4(2u), lessThanEqual(x, uvec4(1073741823u))); x = (x << b2); - uvec4 b1 = mix(uvec4(0u), uvec4(1u), lessThanEqual(x, uvec4(2147483647u))); - uvec4 is_zero = mix(uvec4(0u), uvec4(1u), equal(x, uvec4(0u))); + uvec4 b1 = tint_select(uvec4(0u), uvec4(1u), lessThanEqual(x, uvec4(2147483647u))); + uvec4 is_zero = tint_select(uvec4(0u), uvec4(1u), equal(x, uvec4(0u))); return uvec4((((((b16 | b8) | b4) | b2) | b1) + is_zero)); } @@ -76,18 +86,23 @@ void main() { } #version 310 es +uvec4 tint_select(uvec4 param_0, uvec4 param_1, bvec4 param_2) { + return uvec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + uvec4 tint_count_leading_zeros(uvec4 v) { uvec4 x = uvec4(v); - uvec4 b16 = mix(uvec4(0u), uvec4(16u), lessThanEqual(x, uvec4(65535u))); + uvec4 b16 = tint_select(uvec4(0u), uvec4(16u), lessThanEqual(x, uvec4(65535u))); x = (x << b16); - uvec4 b8 = mix(uvec4(0u), uvec4(8u), lessThanEqual(x, uvec4(16777215u))); + uvec4 b8 = tint_select(uvec4(0u), uvec4(8u), lessThanEqual(x, uvec4(16777215u))); x = (x << b8); - uvec4 b4 = mix(uvec4(0u), uvec4(4u), lessThanEqual(x, uvec4(268435455u))); + uvec4 b4 = tint_select(uvec4(0u), uvec4(4u), lessThanEqual(x, uvec4(268435455u))); x = (x << b4); - uvec4 b2 = mix(uvec4(0u), uvec4(2u), lessThanEqual(x, uvec4(1073741823u))); + uvec4 b2 = tint_select(uvec4(0u), uvec4(2u), lessThanEqual(x, uvec4(1073741823u))); x = (x << b2); - uvec4 b1 = mix(uvec4(0u), uvec4(1u), lessThanEqual(x, uvec4(2147483647u))); - uvec4 is_zero = mix(uvec4(0u), uvec4(1u), equal(x, uvec4(0u))); + uvec4 b1 = tint_select(uvec4(0u), uvec4(1u), lessThanEqual(x, uvec4(2147483647u))); + uvec4 is_zero = tint_select(uvec4(0u), uvec4(1u), equal(x, uvec4(0u))); return uvec4((((((b16 | b8) | b4) | b2) | b1) + is_zero)); } diff --git a/test/tint/builtins/gen/var/countTrailingZeros/1ad138.wgsl.expected.glsl b/test/tint/builtins/gen/var/countTrailingZeros/1ad138.wgsl.expected.glsl index 94b429f885..dc7e94f5c7 100644 --- a/test/tint/builtins/gen/var/countTrailingZeros/1ad138.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/countTrailingZeros/1ad138.wgsl.expected.glsl @@ -1,17 +1,22 @@ #version 310 es +uvec2 tint_select(uvec2 param_0, uvec2 param_1, bvec2 param_2) { + return uvec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + uvec2 tint_count_trailing_zeros(uvec2 v) { uvec2 x = uvec2(v); - uvec2 b16 = mix(uvec2(16u), uvec2(0u), bvec2((x & uvec2(65535u)))); + uvec2 b16 = tint_select(uvec2(16u), uvec2(0u), bvec2((x & uvec2(65535u)))); x = (x >> b16); - uvec2 b8 = mix(uvec2(8u), uvec2(0u), bvec2((x & uvec2(255u)))); + uvec2 b8 = tint_select(uvec2(8u), uvec2(0u), bvec2((x & uvec2(255u)))); x = (x >> b8); - uvec2 b4 = mix(uvec2(4u), uvec2(0u), bvec2((x & uvec2(15u)))); + uvec2 b4 = tint_select(uvec2(4u), uvec2(0u), bvec2((x & uvec2(15u)))); x = (x >> b4); - uvec2 b2 = mix(uvec2(2u), uvec2(0u), bvec2((x & uvec2(3u)))); + uvec2 b2 = tint_select(uvec2(2u), uvec2(0u), bvec2((x & uvec2(3u)))); x = (x >> b2); - uvec2 b1 = mix(uvec2(1u), uvec2(0u), bvec2((x & uvec2(1u)))); - uvec2 is_zero = mix(uvec2(0u), uvec2(1u), equal(x, uvec2(0u))); + uvec2 b1 = tint_select(uvec2(1u), uvec2(0u), bvec2((x & uvec2(1u)))); + uvec2 is_zero = tint_select(uvec2(0u), uvec2(1u), equal(x, uvec2(0u))); return uvec2((((((b16 | b8) | b4) | b2) | b1) + is_zero)); } @@ -41,18 +46,23 @@ void main() { #version 310 es precision mediump float; +uvec2 tint_select(uvec2 param_0, uvec2 param_1, bvec2 param_2) { + return uvec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + uvec2 tint_count_trailing_zeros(uvec2 v) { uvec2 x = uvec2(v); - uvec2 b16 = mix(uvec2(16u), uvec2(0u), bvec2((x & uvec2(65535u)))); + uvec2 b16 = tint_select(uvec2(16u), uvec2(0u), bvec2((x & uvec2(65535u)))); x = (x >> b16); - uvec2 b8 = mix(uvec2(8u), uvec2(0u), bvec2((x & uvec2(255u)))); + uvec2 b8 = tint_select(uvec2(8u), uvec2(0u), bvec2((x & uvec2(255u)))); x = (x >> b8); - uvec2 b4 = mix(uvec2(4u), uvec2(0u), bvec2((x & uvec2(15u)))); + uvec2 b4 = tint_select(uvec2(4u), uvec2(0u), bvec2((x & uvec2(15u)))); x = (x >> b4); - uvec2 b2 = mix(uvec2(2u), uvec2(0u), bvec2((x & uvec2(3u)))); + uvec2 b2 = tint_select(uvec2(2u), uvec2(0u), bvec2((x & uvec2(3u)))); x = (x >> b2); - uvec2 b1 = mix(uvec2(1u), uvec2(0u), bvec2((x & uvec2(1u)))); - uvec2 is_zero = mix(uvec2(0u), uvec2(1u), equal(x, uvec2(0u))); + uvec2 b1 = tint_select(uvec2(1u), uvec2(0u), bvec2((x & uvec2(1u)))); + uvec2 is_zero = tint_select(uvec2(0u), uvec2(1u), equal(x, uvec2(0u))); return uvec2((((((b16 | b8) | b4) | b2) | b1) + is_zero)); } @@ -76,18 +86,23 @@ void main() { } #version 310 es +uvec2 tint_select(uvec2 param_0, uvec2 param_1, bvec2 param_2) { + return uvec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + uvec2 tint_count_trailing_zeros(uvec2 v) { uvec2 x = uvec2(v); - uvec2 b16 = mix(uvec2(16u), uvec2(0u), bvec2((x & uvec2(65535u)))); + uvec2 b16 = tint_select(uvec2(16u), uvec2(0u), bvec2((x & uvec2(65535u)))); x = (x >> b16); - uvec2 b8 = mix(uvec2(8u), uvec2(0u), bvec2((x & uvec2(255u)))); + uvec2 b8 = tint_select(uvec2(8u), uvec2(0u), bvec2((x & uvec2(255u)))); x = (x >> b8); - uvec2 b4 = mix(uvec2(4u), uvec2(0u), bvec2((x & uvec2(15u)))); + uvec2 b4 = tint_select(uvec2(4u), uvec2(0u), bvec2((x & uvec2(15u)))); x = (x >> b4); - uvec2 b2 = mix(uvec2(2u), uvec2(0u), bvec2((x & uvec2(3u)))); + uvec2 b2 = tint_select(uvec2(2u), uvec2(0u), bvec2((x & uvec2(3u)))); x = (x >> b2); - uvec2 b1 = mix(uvec2(1u), uvec2(0u), bvec2((x & uvec2(1u)))); - uvec2 is_zero = mix(uvec2(0u), uvec2(1u), equal(x, uvec2(0u))); + uvec2 b1 = tint_select(uvec2(1u), uvec2(0u), bvec2((x & uvec2(1u)))); + uvec2 is_zero = tint_select(uvec2(0u), uvec2(1u), equal(x, uvec2(0u))); return uvec2((((((b16 | b8) | b4) | b2) | b1) + is_zero)); } diff --git a/test/tint/builtins/gen/var/countTrailingZeros/1dc84a.wgsl.expected.glsl b/test/tint/builtins/gen/var/countTrailingZeros/1dc84a.wgsl.expected.glsl index 70f5d7ee35..dcecc37c82 100644 --- a/test/tint/builtins/gen/var/countTrailingZeros/1dc84a.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/countTrailingZeros/1dc84a.wgsl.expected.glsl @@ -1,17 +1,22 @@ #version 310 es +uvec4 tint_select(uvec4 param_0, uvec4 param_1, bvec4 param_2) { + return uvec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + ivec4 tint_count_trailing_zeros(ivec4 v) { uvec4 x = uvec4(v); - uvec4 b16 = mix(uvec4(16u), uvec4(0u), bvec4((x & uvec4(65535u)))); + uvec4 b16 = tint_select(uvec4(16u), uvec4(0u), bvec4((x & uvec4(65535u)))); x = (x >> b16); - uvec4 b8 = mix(uvec4(8u), uvec4(0u), bvec4((x & uvec4(255u)))); + uvec4 b8 = tint_select(uvec4(8u), uvec4(0u), bvec4((x & uvec4(255u)))); x = (x >> b8); - uvec4 b4 = mix(uvec4(4u), uvec4(0u), bvec4((x & uvec4(15u)))); + uvec4 b4 = tint_select(uvec4(4u), uvec4(0u), bvec4((x & uvec4(15u)))); x = (x >> b4); - uvec4 b2 = mix(uvec4(2u), uvec4(0u), bvec4((x & uvec4(3u)))); + uvec4 b2 = tint_select(uvec4(2u), uvec4(0u), bvec4((x & uvec4(3u)))); x = (x >> b2); - uvec4 b1 = mix(uvec4(1u), uvec4(0u), bvec4((x & uvec4(1u)))); - uvec4 is_zero = mix(uvec4(0u), uvec4(1u), equal(x, uvec4(0u))); + uvec4 b1 = tint_select(uvec4(1u), uvec4(0u), bvec4((x & uvec4(1u)))); + uvec4 is_zero = tint_select(uvec4(0u), uvec4(1u), equal(x, uvec4(0u))); return ivec4((((((b16 | b8) | b4) | b2) | b1) + is_zero)); } @@ -41,18 +46,23 @@ void main() { #version 310 es precision mediump float; +uvec4 tint_select(uvec4 param_0, uvec4 param_1, bvec4 param_2) { + return uvec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + ivec4 tint_count_trailing_zeros(ivec4 v) { uvec4 x = uvec4(v); - uvec4 b16 = mix(uvec4(16u), uvec4(0u), bvec4((x & uvec4(65535u)))); + uvec4 b16 = tint_select(uvec4(16u), uvec4(0u), bvec4((x & uvec4(65535u)))); x = (x >> b16); - uvec4 b8 = mix(uvec4(8u), uvec4(0u), bvec4((x & uvec4(255u)))); + uvec4 b8 = tint_select(uvec4(8u), uvec4(0u), bvec4((x & uvec4(255u)))); x = (x >> b8); - uvec4 b4 = mix(uvec4(4u), uvec4(0u), bvec4((x & uvec4(15u)))); + uvec4 b4 = tint_select(uvec4(4u), uvec4(0u), bvec4((x & uvec4(15u)))); x = (x >> b4); - uvec4 b2 = mix(uvec4(2u), uvec4(0u), bvec4((x & uvec4(3u)))); + uvec4 b2 = tint_select(uvec4(2u), uvec4(0u), bvec4((x & uvec4(3u)))); x = (x >> b2); - uvec4 b1 = mix(uvec4(1u), uvec4(0u), bvec4((x & uvec4(1u)))); - uvec4 is_zero = mix(uvec4(0u), uvec4(1u), equal(x, uvec4(0u))); + uvec4 b1 = tint_select(uvec4(1u), uvec4(0u), bvec4((x & uvec4(1u)))); + uvec4 is_zero = tint_select(uvec4(0u), uvec4(1u), equal(x, uvec4(0u))); return ivec4((((((b16 | b8) | b4) | b2) | b1) + is_zero)); } @@ -76,18 +86,23 @@ void main() { } #version 310 es +uvec4 tint_select(uvec4 param_0, uvec4 param_1, bvec4 param_2) { + return uvec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + ivec4 tint_count_trailing_zeros(ivec4 v) { uvec4 x = uvec4(v); - uvec4 b16 = mix(uvec4(16u), uvec4(0u), bvec4((x & uvec4(65535u)))); + uvec4 b16 = tint_select(uvec4(16u), uvec4(0u), bvec4((x & uvec4(65535u)))); x = (x >> b16); - uvec4 b8 = mix(uvec4(8u), uvec4(0u), bvec4((x & uvec4(255u)))); + uvec4 b8 = tint_select(uvec4(8u), uvec4(0u), bvec4((x & uvec4(255u)))); x = (x >> b8); - uvec4 b4 = mix(uvec4(4u), uvec4(0u), bvec4((x & uvec4(15u)))); + uvec4 b4 = tint_select(uvec4(4u), uvec4(0u), bvec4((x & uvec4(15u)))); x = (x >> b4); - uvec4 b2 = mix(uvec4(2u), uvec4(0u), bvec4((x & uvec4(3u)))); + uvec4 b2 = tint_select(uvec4(2u), uvec4(0u), bvec4((x & uvec4(3u)))); x = (x >> b2); - uvec4 b1 = mix(uvec4(1u), uvec4(0u), bvec4((x & uvec4(1u)))); - uvec4 is_zero = mix(uvec4(0u), uvec4(1u), equal(x, uvec4(0u))); + uvec4 b1 = tint_select(uvec4(1u), uvec4(0u), bvec4((x & uvec4(1u)))); + uvec4 is_zero = tint_select(uvec4(0u), uvec4(1u), equal(x, uvec4(0u))); return ivec4((((((b16 | b8) | b4) | b2) | b1) + is_zero)); } diff --git a/test/tint/builtins/gen/var/countTrailingZeros/327c37.wgsl.expected.glsl b/test/tint/builtins/gen/var/countTrailingZeros/327c37.wgsl.expected.glsl index 297d6da331..a433a86dbd 100644 --- a/test/tint/builtins/gen/var/countTrailingZeros/327c37.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/countTrailingZeros/327c37.wgsl.expected.glsl @@ -1,17 +1,22 @@ #version 310 es +uvec2 tint_select(uvec2 param_0, uvec2 param_1, bvec2 param_2) { + return uvec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + ivec2 tint_count_trailing_zeros(ivec2 v) { uvec2 x = uvec2(v); - uvec2 b16 = mix(uvec2(16u), uvec2(0u), bvec2((x & uvec2(65535u)))); + uvec2 b16 = tint_select(uvec2(16u), uvec2(0u), bvec2((x & uvec2(65535u)))); x = (x >> b16); - uvec2 b8 = mix(uvec2(8u), uvec2(0u), bvec2((x & uvec2(255u)))); + uvec2 b8 = tint_select(uvec2(8u), uvec2(0u), bvec2((x & uvec2(255u)))); x = (x >> b8); - uvec2 b4 = mix(uvec2(4u), uvec2(0u), bvec2((x & uvec2(15u)))); + uvec2 b4 = tint_select(uvec2(4u), uvec2(0u), bvec2((x & uvec2(15u)))); x = (x >> b4); - uvec2 b2 = mix(uvec2(2u), uvec2(0u), bvec2((x & uvec2(3u)))); + uvec2 b2 = tint_select(uvec2(2u), uvec2(0u), bvec2((x & uvec2(3u)))); x = (x >> b2); - uvec2 b1 = mix(uvec2(1u), uvec2(0u), bvec2((x & uvec2(1u)))); - uvec2 is_zero = mix(uvec2(0u), uvec2(1u), equal(x, uvec2(0u))); + uvec2 b1 = tint_select(uvec2(1u), uvec2(0u), bvec2((x & uvec2(1u)))); + uvec2 is_zero = tint_select(uvec2(0u), uvec2(1u), equal(x, uvec2(0u))); return ivec2((((((b16 | b8) | b4) | b2) | b1) + is_zero)); } @@ -41,18 +46,23 @@ void main() { #version 310 es precision mediump float; +uvec2 tint_select(uvec2 param_0, uvec2 param_1, bvec2 param_2) { + return uvec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + ivec2 tint_count_trailing_zeros(ivec2 v) { uvec2 x = uvec2(v); - uvec2 b16 = mix(uvec2(16u), uvec2(0u), bvec2((x & uvec2(65535u)))); + uvec2 b16 = tint_select(uvec2(16u), uvec2(0u), bvec2((x & uvec2(65535u)))); x = (x >> b16); - uvec2 b8 = mix(uvec2(8u), uvec2(0u), bvec2((x & uvec2(255u)))); + uvec2 b8 = tint_select(uvec2(8u), uvec2(0u), bvec2((x & uvec2(255u)))); x = (x >> b8); - uvec2 b4 = mix(uvec2(4u), uvec2(0u), bvec2((x & uvec2(15u)))); + uvec2 b4 = tint_select(uvec2(4u), uvec2(0u), bvec2((x & uvec2(15u)))); x = (x >> b4); - uvec2 b2 = mix(uvec2(2u), uvec2(0u), bvec2((x & uvec2(3u)))); + uvec2 b2 = tint_select(uvec2(2u), uvec2(0u), bvec2((x & uvec2(3u)))); x = (x >> b2); - uvec2 b1 = mix(uvec2(1u), uvec2(0u), bvec2((x & uvec2(1u)))); - uvec2 is_zero = mix(uvec2(0u), uvec2(1u), equal(x, uvec2(0u))); + uvec2 b1 = tint_select(uvec2(1u), uvec2(0u), bvec2((x & uvec2(1u)))); + uvec2 is_zero = tint_select(uvec2(0u), uvec2(1u), equal(x, uvec2(0u))); return ivec2((((((b16 | b8) | b4) | b2) | b1) + is_zero)); } @@ -76,18 +86,23 @@ void main() { } #version 310 es +uvec2 tint_select(uvec2 param_0, uvec2 param_1, bvec2 param_2) { + return uvec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + ivec2 tint_count_trailing_zeros(ivec2 v) { uvec2 x = uvec2(v); - uvec2 b16 = mix(uvec2(16u), uvec2(0u), bvec2((x & uvec2(65535u)))); + uvec2 b16 = tint_select(uvec2(16u), uvec2(0u), bvec2((x & uvec2(65535u)))); x = (x >> b16); - uvec2 b8 = mix(uvec2(8u), uvec2(0u), bvec2((x & uvec2(255u)))); + uvec2 b8 = tint_select(uvec2(8u), uvec2(0u), bvec2((x & uvec2(255u)))); x = (x >> b8); - uvec2 b4 = mix(uvec2(4u), uvec2(0u), bvec2((x & uvec2(15u)))); + uvec2 b4 = tint_select(uvec2(4u), uvec2(0u), bvec2((x & uvec2(15u)))); x = (x >> b4); - uvec2 b2 = mix(uvec2(2u), uvec2(0u), bvec2((x & uvec2(3u)))); + uvec2 b2 = tint_select(uvec2(2u), uvec2(0u), bvec2((x & uvec2(3u)))); x = (x >> b2); - uvec2 b1 = mix(uvec2(1u), uvec2(0u), bvec2((x & uvec2(1u)))); - uvec2 is_zero = mix(uvec2(0u), uvec2(1u), equal(x, uvec2(0u))); + uvec2 b1 = tint_select(uvec2(1u), uvec2(0u), bvec2((x & uvec2(1u)))); + uvec2 is_zero = tint_select(uvec2(0u), uvec2(1u), equal(x, uvec2(0u))); return ivec2((((((b16 | b8) | b4) | b2) | b1) + is_zero)); } diff --git a/test/tint/builtins/gen/var/countTrailingZeros/8ed26f.wgsl.expected.glsl b/test/tint/builtins/gen/var/countTrailingZeros/8ed26f.wgsl.expected.glsl index 6e7954b182..d349d93523 100644 --- a/test/tint/builtins/gen/var/countTrailingZeros/8ed26f.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/countTrailingZeros/8ed26f.wgsl.expected.glsl @@ -1,17 +1,22 @@ #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + uvec3 tint_count_trailing_zeros(uvec3 v) { uvec3 x = uvec3(v); - uvec3 b16 = mix(uvec3(16u), uvec3(0u), bvec3((x & uvec3(65535u)))); + uvec3 b16 = tint_select(uvec3(16u), uvec3(0u), bvec3((x & uvec3(65535u)))); x = (x >> b16); - uvec3 b8 = mix(uvec3(8u), uvec3(0u), bvec3((x & uvec3(255u)))); + uvec3 b8 = tint_select(uvec3(8u), uvec3(0u), bvec3((x & uvec3(255u)))); x = (x >> b8); - uvec3 b4 = mix(uvec3(4u), uvec3(0u), bvec3((x & uvec3(15u)))); + uvec3 b4 = tint_select(uvec3(4u), uvec3(0u), bvec3((x & uvec3(15u)))); x = (x >> b4); - uvec3 b2 = mix(uvec3(2u), uvec3(0u), bvec3((x & uvec3(3u)))); + uvec3 b2 = tint_select(uvec3(2u), uvec3(0u), bvec3((x & uvec3(3u)))); x = (x >> b2); - uvec3 b1 = mix(uvec3(1u), uvec3(0u), bvec3((x & uvec3(1u)))); - uvec3 is_zero = mix(uvec3(0u), uvec3(1u), equal(x, uvec3(0u))); + uvec3 b1 = tint_select(uvec3(1u), uvec3(0u), bvec3((x & uvec3(1u)))); + uvec3 is_zero = tint_select(uvec3(0u), uvec3(1u), equal(x, uvec3(0u))); return uvec3((((((b16 | b8) | b4) | b2) | b1) + is_zero)); } @@ -41,18 +46,23 @@ void main() { #version 310 es precision mediump float; +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + uvec3 tint_count_trailing_zeros(uvec3 v) { uvec3 x = uvec3(v); - uvec3 b16 = mix(uvec3(16u), uvec3(0u), bvec3((x & uvec3(65535u)))); + uvec3 b16 = tint_select(uvec3(16u), uvec3(0u), bvec3((x & uvec3(65535u)))); x = (x >> b16); - uvec3 b8 = mix(uvec3(8u), uvec3(0u), bvec3((x & uvec3(255u)))); + uvec3 b8 = tint_select(uvec3(8u), uvec3(0u), bvec3((x & uvec3(255u)))); x = (x >> b8); - uvec3 b4 = mix(uvec3(4u), uvec3(0u), bvec3((x & uvec3(15u)))); + uvec3 b4 = tint_select(uvec3(4u), uvec3(0u), bvec3((x & uvec3(15u)))); x = (x >> b4); - uvec3 b2 = mix(uvec3(2u), uvec3(0u), bvec3((x & uvec3(3u)))); + uvec3 b2 = tint_select(uvec3(2u), uvec3(0u), bvec3((x & uvec3(3u)))); x = (x >> b2); - uvec3 b1 = mix(uvec3(1u), uvec3(0u), bvec3((x & uvec3(1u)))); - uvec3 is_zero = mix(uvec3(0u), uvec3(1u), equal(x, uvec3(0u))); + uvec3 b1 = tint_select(uvec3(1u), uvec3(0u), bvec3((x & uvec3(1u)))); + uvec3 is_zero = tint_select(uvec3(0u), uvec3(1u), equal(x, uvec3(0u))); return uvec3((((((b16 | b8) | b4) | b2) | b1) + is_zero)); } @@ -76,18 +86,23 @@ void main() { } #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + uvec3 tint_count_trailing_zeros(uvec3 v) { uvec3 x = uvec3(v); - uvec3 b16 = mix(uvec3(16u), uvec3(0u), bvec3((x & uvec3(65535u)))); + uvec3 b16 = tint_select(uvec3(16u), uvec3(0u), bvec3((x & uvec3(65535u)))); x = (x >> b16); - uvec3 b8 = mix(uvec3(8u), uvec3(0u), bvec3((x & uvec3(255u)))); + uvec3 b8 = tint_select(uvec3(8u), uvec3(0u), bvec3((x & uvec3(255u)))); x = (x >> b8); - uvec3 b4 = mix(uvec3(4u), uvec3(0u), bvec3((x & uvec3(15u)))); + uvec3 b4 = tint_select(uvec3(4u), uvec3(0u), bvec3((x & uvec3(15u)))); x = (x >> b4); - uvec3 b2 = mix(uvec3(2u), uvec3(0u), bvec3((x & uvec3(3u)))); + uvec3 b2 = tint_select(uvec3(2u), uvec3(0u), bvec3((x & uvec3(3u)))); x = (x >> b2); - uvec3 b1 = mix(uvec3(1u), uvec3(0u), bvec3((x & uvec3(1u)))); - uvec3 is_zero = mix(uvec3(0u), uvec3(1u), equal(x, uvec3(0u))); + uvec3 b1 = tint_select(uvec3(1u), uvec3(0u), bvec3((x & uvec3(1u)))); + uvec3 is_zero = tint_select(uvec3(0u), uvec3(1u), equal(x, uvec3(0u))); return uvec3((((((b16 | b8) | b4) | b2) | b1) + is_zero)); } diff --git a/test/tint/builtins/gen/var/countTrailingZeros/acfacb.wgsl.expected.glsl b/test/tint/builtins/gen/var/countTrailingZeros/acfacb.wgsl.expected.glsl index 3f285e77d8..1eb0bbc531 100644 --- a/test/tint/builtins/gen/var/countTrailingZeros/acfacb.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/countTrailingZeros/acfacb.wgsl.expected.glsl @@ -1,17 +1,22 @@ #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + ivec3 tint_count_trailing_zeros(ivec3 v) { uvec3 x = uvec3(v); - uvec3 b16 = mix(uvec3(16u), uvec3(0u), bvec3((x & uvec3(65535u)))); + uvec3 b16 = tint_select(uvec3(16u), uvec3(0u), bvec3((x & uvec3(65535u)))); x = (x >> b16); - uvec3 b8 = mix(uvec3(8u), uvec3(0u), bvec3((x & uvec3(255u)))); + uvec3 b8 = tint_select(uvec3(8u), uvec3(0u), bvec3((x & uvec3(255u)))); x = (x >> b8); - uvec3 b4 = mix(uvec3(4u), uvec3(0u), bvec3((x & uvec3(15u)))); + uvec3 b4 = tint_select(uvec3(4u), uvec3(0u), bvec3((x & uvec3(15u)))); x = (x >> b4); - uvec3 b2 = mix(uvec3(2u), uvec3(0u), bvec3((x & uvec3(3u)))); + uvec3 b2 = tint_select(uvec3(2u), uvec3(0u), bvec3((x & uvec3(3u)))); x = (x >> b2); - uvec3 b1 = mix(uvec3(1u), uvec3(0u), bvec3((x & uvec3(1u)))); - uvec3 is_zero = mix(uvec3(0u), uvec3(1u), equal(x, uvec3(0u))); + uvec3 b1 = tint_select(uvec3(1u), uvec3(0u), bvec3((x & uvec3(1u)))); + uvec3 is_zero = tint_select(uvec3(0u), uvec3(1u), equal(x, uvec3(0u))); return ivec3((((((b16 | b8) | b4) | b2) | b1) + is_zero)); } @@ -41,18 +46,23 @@ void main() { #version 310 es precision mediump float; +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + ivec3 tint_count_trailing_zeros(ivec3 v) { uvec3 x = uvec3(v); - uvec3 b16 = mix(uvec3(16u), uvec3(0u), bvec3((x & uvec3(65535u)))); + uvec3 b16 = tint_select(uvec3(16u), uvec3(0u), bvec3((x & uvec3(65535u)))); x = (x >> b16); - uvec3 b8 = mix(uvec3(8u), uvec3(0u), bvec3((x & uvec3(255u)))); + uvec3 b8 = tint_select(uvec3(8u), uvec3(0u), bvec3((x & uvec3(255u)))); x = (x >> b8); - uvec3 b4 = mix(uvec3(4u), uvec3(0u), bvec3((x & uvec3(15u)))); + uvec3 b4 = tint_select(uvec3(4u), uvec3(0u), bvec3((x & uvec3(15u)))); x = (x >> b4); - uvec3 b2 = mix(uvec3(2u), uvec3(0u), bvec3((x & uvec3(3u)))); + uvec3 b2 = tint_select(uvec3(2u), uvec3(0u), bvec3((x & uvec3(3u)))); x = (x >> b2); - uvec3 b1 = mix(uvec3(1u), uvec3(0u), bvec3((x & uvec3(1u)))); - uvec3 is_zero = mix(uvec3(0u), uvec3(1u), equal(x, uvec3(0u))); + uvec3 b1 = tint_select(uvec3(1u), uvec3(0u), bvec3((x & uvec3(1u)))); + uvec3 is_zero = tint_select(uvec3(0u), uvec3(1u), equal(x, uvec3(0u))); return ivec3((((((b16 | b8) | b4) | b2) | b1) + is_zero)); } @@ -76,18 +86,23 @@ void main() { } #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + ivec3 tint_count_trailing_zeros(ivec3 v) { uvec3 x = uvec3(v); - uvec3 b16 = mix(uvec3(16u), uvec3(0u), bvec3((x & uvec3(65535u)))); + uvec3 b16 = tint_select(uvec3(16u), uvec3(0u), bvec3((x & uvec3(65535u)))); x = (x >> b16); - uvec3 b8 = mix(uvec3(8u), uvec3(0u), bvec3((x & uvec3(255u)))); + uvec3 b8 = tint_select(uvec3(8u), uvec3(0u), bvec3((x & uvec3(255u)))); x = (x >> b8); - uvec3 b4 = mix(uvec3(4u), uvec3(0u), bvec3((x & uvec3(15u)))); + uvec3 b4 = tint_select(uvec3(4u), uvec3(0u), bvec3((x & uvec3(15u)))); x = (x >> b4); - uvec3 b2 = mix(uvec3(2u), uvec3(0u), bvec3((x & uvec3(3u)))); + uvec3 b2 = tint_select(uvec3(2u), uvec3(0u), bvec3((x & uvec3(3u)))); x = (x >> b2); - uvec3 b1 = mix(uvec3(1u), uvec3(0u), bvec3((x & uvec3(1u)))); - uvec3 is_zero = mix(uvec3(0u), uvec3(1u), equal(x, uvec3(0u))); + uvec3 b1 = tint_select(uvec3(1u), uvec3(0u), bvec3((x & uvec3(1u)))); + uvec3 is_zero = tint_select(uvec3(0u), uvec3(1u), equal(x, uvec3(0u))); return ivec3((((((b16 | b8) | b4) | b2) | b1) + is_zero)); } diff --git a/test/tint/builtins/gen/var/countTrailingZeros/d2b4a0.wgsl.expected.glsl b/test/tint/builtins/gen/var/countTrailingZeros/d2b4a0.wgsl.expected.glsl index 0e62166d99..f558abd0f8 100644 --- a/test/tint/builtins/gen/var/countTrailingZeros/d2b4a0.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/countTrailingZeros/d2b4a0.wgsl.expected.glsl @@ -1,17 +1,22 @@ #version 310 es +uvec4 tint_select(uvec4 param_0, uvec4 param_1, bvec4 param_2) { + return uvec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + uvec4 tint_count_trailing_zeros(uvec4 v) { uvec4 x = uvec4(v); - uvec4 b16 = mix(uvec4(16u), uvec4(0u), bvec4((x & uvec4(65535u)))); + uvec4 b16 = tint_select(uvec4(16u), uvec4(0u), bvec4((x & uvec4(65535u)))); x = (x >> b16); - uvec4 b8 = mix(uvec4(8u), uvec4(0u), bvec4((x & uvec4(255u)))); + uvec4 b8 = tint_select(uvec4(8u), uvec4(0u), bvec4((x & uvec4(255u)))); x = (x >> b8); - uvec4 b4 = mix(uvec4(4u), uvec4(0u), bvec4((x & uvec4(15u)))); + uvec4 b4 = tint_select(uvec4(4u), uvec4(0u), bvec4((x & uvec4(15u)))); x = (x >> b4); - uvec4 b2 = mix(uvec4(2u), uvec4(0u), bvec4((x & uvec4(3u)))); + uvec4 b2 = tint_select(uvec4(2u), uvec4(0u), bvec4((x & uvec4(3u)))); x = (x >> b2); - uvec4 b1 = mix(uvec4(1u), uvec4(0u), bvec4((x & uvec4(1u)))); - uvec4 is_zero = mix(uvec4(0u), uvec4(1u), equal(x, uvec4(0u))); + uvec4 b1 = tint_select(uvec4(1u), uvec4(0u), bvec4((x & uvec4(1u)))); + uvec4 is_zero = tint_select(uvec4(0u), uvec4(1u), equal(x, uvec4(0u))); return uvec4((((((b16 | b8) | b4) | b2) | b1) + is_zero)); } @@ -41,18 +46,23 @@ void main() { #version 310 es precision mediump float; +uvec4 tint_select(uvec4 param_0, uvec4 param_1, bvec4 param_2) { + return uvec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + uvec4 tint_count_trailing_zeros(uvec4 v) { uvec4 x = uvec4(v); - uvec4 b16 = mix(uvec4(16u), uvec4(0u), bvec4((x & uvec4(65535u)))); + uvec4 b16 = tint_select(uvec4(16u), uvec4(0u), bvec4((x & uvec4(65535u)))); x = (x >> b16); - uvec4 b8 = mix(uvec4(8u), uvec4(0u), bvec4((x & uvec4(255u)))); + uvec4 b8 = tint_select(uvec4(8u), uvec4(0u), bvec4((x & uvec4(255u)))); x = (x >> b8); - uvec4 b4 = mix(uvec4(4u), uvec4(0u), bvec4((x & uvec4(15u)))); + uvec4 b4 = tint_select(uvec4(4u), uvec4(0u), bvec4((x & uvec4(15u)))); x = (x >> b4); - uvec4 b2 = mix(uvec4(2u), uvec4(0u), bvec4((x & uvec4(3u)))); + uvec4 b2 = tint_select(uvec4(2u), uvec4(0u), bvec4((x & uvec4(3u)))); x = (x >> b2); - uvec4 b1 = mix(uvec4(1u), uvec4(0u), bvec4((x & uvec4(1u)))); - uvec4 is_zero = mix(uvec4(0u), uvec4(1u), equal(x, uvec4(0u))); + uvec4 b1 = tint_select(uvec4(1u), uvec4(0u), bvec4((x & uvec4(1u)))); + uvec4 is_zero = tint_select(uvec4(0u), uvec4(1u), equal(x, uvec4(0u))); return uvec4((((((b16 | b8) | b4) | b2) | b1) + is_zero)); } @@ -76,18 +86,23 @@ void main() { } #version 310 es +uvec4 tint_select(uvec4 param_0, uvec4 param_1, bvec4 param_2) { + return uvec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + uvec4 tint_count_trailing_zeros(uvec4 v) { uvec4 x = uvec4(v); - uvec4 b16 = mix(uvec4(16u), uvec4(0u), bvec4((x & uvec4(65535u)))); + uvec4 b16 = tint_select(uvec4(16u), uvec4(0u), bvec4((x & uvec4(65535u)))); x = (x >> b16); - uvec4 b8 = mix(uvec4(8u), uvec4(0u), bvec4((x & uvec4(255u)))); + uvec4 b8 = tint_select(uvec4(8u), uvec4(0u), bvec4((x & uvec4(255u)))); x = (x >> b8); - uvec4 b4 = mix(uvec4(4u), uvec4(0u), bvec4((x & uvec4(15u)))); + uvec4 b4 = tint_select(uvec4(4u), uvec4(0u), bvec4((x & uvec4(15u)))); x = (x >> b4); - uvec4 b2 = mix(uvec4(2u), uvec4(0u), bvec4((x & uvec4(3u)))); + uvec4 b2 = tint_select(uvec4(2u), uvec4(0u), bvec4((x & uvec4(3u)))); x = (x >> b2); - uvec4 b1 = mix(uvec4(1u), uvec4(0u), bvec4((x & uvec4(1u)))); - uvec4 is_zero = mix(uvec4(0u), uvec4(1u), equal(x, uvec4(0u))); + uvec4 b1 = tint_select(uvec4(1u), uvec4(0u), bvec4((x & uvec4(1u)))); + uvec4 is_zero = tint_select(uvec4(0u), uvec4(1u), equal(x, uvec4(0u))); return uvec4((((((b16 | b8) | b4) | b2) | b1) + is_zero)); } diff --git a/test/tint/builtins/gen/var/firstLeadingBit/000ff3.wgsl.expected.glsl b/test/tint/builtins/gen/var/firstLeadingBit/000ff3.wgsl.expected.glsl index a88db526f5..c168581e3b 100644 --- a/test/tint/builtins/gen/var/firstLeadingBit/000ff3.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/firstLeadingBit/000ff3.wgsl.expected.glsl @@ -1,17 +1,22 @@ #version 310 es +uvec4 tint_select(uvec4 param_0, uvec4 param_1, bvec4 param_2) { + return uvec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + uvec4 tint_first_leading_bit(uvec4 v) { uvec4 x = v; - uvec4 b16 = mix(uvec4(0u), uvec4(16u), bvec4((x & uvec4(4294901760u)))); + uvec4 b16 = tint_select(uvec4(0u), uvec4(16u), bvec4((x & uvec4(4294901760u)))); x = (x >> b16); - uvec4 b8 = mix(uvec4(0u), uvec4(8u), bvec4((x & uvec4(65280u)))); + uvec4 b8 = tint_select(uvec4(0u), uvec4(8u), bvec4((x & uvec4(65280u)))); x = (x >> b8); - uvec4 b4 = mix(uvec4(0u), uvec4(4u), bvec4((x & uvec4(240u)))); + uvec4 b4 = tint_select(uvec4(0u), uvec4(4u), bvec4((x & uvec4(240u)))); x = (x >> b4); - uvec4 b2 = mix(uvec4(0u), uvec4(2u), bvec4((x & uvec4(12u)))); + uvec4 b2 = tint_select(uvec4(0u), uvec4(2u), bvec4((x & uvec4(12u)))); x = (x >> b2); - uvec4 b1 = mix(uvec4(0u), uvec4(1u), bvec4((x & uvec4(2u)))); - uvec4 is_zero = mix(uvec4(0u), uvec4(4294967295u), equal(x, uvec4(0u))); + uvec4 b1 = tint_select(uvec4(0u), uvec4(1u), bvec4((x & uvec4(2u)))); + uvec4 is_zero = tint_select(uvec4(0u), uvec4(4294967295u), equal(x, uvec4(0u))); return uvec4((((((b16 | b8) | b4) | b2) | b1) | is_zero)); } @@ -41,18 +46,23 @@ void main() { #version 310 es precision mediump float; +uvec4 tint_select(uvec4 param_0, uvec4 param_1, bvec4 param_2) { + return uvec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + uvec4 tint_first_leading_bit(uvec4 v) { uvec4 x = v; - uvec4 b16 = mix(uvec4(0u), uvec4(16u), bvec4((x & uvec4(4294901760u)))); + uvec4 b16 = tint_select(uvec4(0u), uvec4(16u), bvec4((x & uvec4(4294901760u)))); x = (x >> b16); - uvec4 b8 = mix(uvec4(0u), uvec4(8u), bvec4((x & uvec4(65280u)))); + uvec4 b8 = tint_select(uvec4(0u), uvec4(8u), bvec4((x & uvec4(65280u)))); x = (x >> b8); - uvec4 b4 = mix(uvec4(0u), uvec4(4u), bvec4((x & uvec4(240u)))); + uvec4 b4 = tint_select(uvec4(0u), uvec4(4u), bvec4((x & uvec4(240u)))); x = (x >> b4); - uvec4 b2 = mix(uvec4(0u), uvec4(2u), bvec4((x & uvec4(12u)))); + uvec4 b2 = tint_select(uvec4(0u), uvec4(2u), bvec4((x & uvec4(12u)))); x = (x >> b2); - uvec4 b1 = mix(uvec4(0u), uvec4(1u), bvec4((x & uvec4(2u)))); - uvec4 is_zero = mix(uvec4(0u), uvec4(4294967295u), equal(x, uvec4(0u))); + uvec4 b1 = tint_select(uvec4(0u), uvec4(1u), bvec4((x & uvec4(2u)))); + uvec4 is_zero = tint_select(uvec4(0u), uvec4(4294967295u), equal(x, uvec4(0u))); return uvec4((((((b16 | b8) | b4) | b2) | b1) | is_zero)); } @@ -76,18 +86,23 @@ void main() { } #version 310 es +uvec4 tint_select(uvec4 param_0, uvec4 param_1, bvec4 param_2) { + return uvec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + uvec4 tint_first_leading_bit(uvec4 v) { uvec4 x = v; - uvec4 b16 = mix(uvec4(0u), uvec4(16u), bvec4((x & uvec4(4294901760u)))); + uvec4 b16 = tint_select(uvec4(0u), uvec4(16u), bvec4((x & uvec4(4294901760u)))); x = (x >> b16); - uvec4 b8 = mix(uvec4(0u), uvec4(8u), bvec4((x & uvec4(65280u)))); + uvec4 b8 = tint_select(uvec4(0u), uvec4(8u), bvec4((x & uvec4(65280u)))); x = (x >> b8); - uvec4 b4 = mix(uvec4(0u), uvec4(4u), bvec4((x & uvec4(240u)))); + uvec4 b4 = tint_select(uvec4(0u), uvec4(4u), bvec4((x & uvec4(240u)))); x = (x >> b4); - uvec4 b2 = mix(uvec4(0u), uvec4(2u), bvec4((x & uvec4(12u)))); + uvec4 b2 = tint_select(uvec4(0u), uvec4(2u), bvec4((x & uvec4(12u)))); x = (x >> b2); - uvec4 b1 = mix(uvec4(0u), uvec4(1u), bvec4((x & uvec4(2u)))); - uvec4 is_zero = mix(uvec4(0u), uvec4(4294967295u), equal(x, uvec4(0u))); + uvec4 b1 = tint_select(uvec4(0u), uvec4(1u), bvec4((x & uvec4(2u)))); + uvec4 is_zero = tint_select(uvec4(0u), uvec4(4294967295u), equal(x, uvec4(0u))); return uvec4((((((b16 | b8) | b4) | b2) | b1) | is_zero)); } diff --git a/test/tint/builtins/gen/var/firstLeadingBit/35053e.wgsl.expected.glsl b/test/tint/builtins/gen/var/firstLeadingBit/35053e.wgsl.expected.glsl index ffe0d7be70..0404a8f640 100644 --- a/test/tint/builtins/gen/var/firstLeadingBit/35053e.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/firstLeadingBit/35053e.wgsl.expected.glsl @@ -1,17 +1,22 @@ #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + ivec3 tint_first_leading_bit(ivec3 v) { - uvec3 x = mix(uvec3(v), uvec3(~(v)), lessThan(v, ivec3(0))); - uvec3 b16 = mix(uvec3(0u), uvec3(16u), bvec3((x & uvec3(4294901760u)))); + uvec3 x = tint_select(uvec3(v), uvec3(~(v)), lessThan(v, ivec3(0))); + uvec3 b16 = tint_select(uvec3(0u), uvec3(16u), bvec3((x & uvec3(4294901760u)))); x = (x >> b16); - uvec3 b8 = mix(uvec3(0u), uvec3(8u), bvec3((x & uvec3(65280u)))); + uvec3 b8 = tint_select(uvec3(0u), uvec3(8u), bvec3((x & uvec3(65280u)))); x = (x >> b8); - uvec3 b4 = mix(uvec3(0u), uvec3(4u), bvec3((x & uvec3(240u)))); + uvec3 b4 = tint_select(uvec3(0u), uvec3(4u), bvec3((x & uvec3(240u)))); x = (x >> b4); - uvec3 b2 = mix(uvec3(0u), uvec3(2u), bvec3((x & uvec3(12u)))); + uvec3 b2 = tint_select(uvec3(0u), uvec3(2u), bvec3((x & uvec3(12u)))); x = (x >> b2); - uvec3 b1 = mix(uvec3(0u), uvec3(1u), bvec3((x & uvec3(2u)))); - uvec3 is_zero = mix(uvec3(0u), uvec3(4294967295u), equal(x, uvec3(0u))); + uvec3 b1 = tint_select(uvec3(0u), uvec3(1u), bvec3((x & uvec3(2u)))); + uvec3 is_zero = tint_select(uvec3(0u), uvec3(4294967295u), equal(x, uvec3(0u))); return ivec3((((((b16 | b8) | b4) | b2) | b1) | is_zero)); } @@ -41,18 +46,23 @@ void main() { #version 310 es precision mediump float; +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + ivec3 tint_first_leading_bit(ivec3 v) { - uvec3 x = mix(uvec3(v), uvec3(~(v)), lessThan(v, ivec3(0))); - uvec3 b16 = mix(uvec3(0u), uvec3(16u), bvec3((x & uvec3(4294901760u)))); + uvec3 x = tint_select(uvec3(v), uvec3(~(v)), lessThan(v, ivec3(0))); + uvec3 b16 = tint_select(uvec3(0u), uvec3(16u), bvec3((x & uvec3(4294901760u)))); x = (x >> b16); - uvec3 b8 = mix(uvec3(0u), uvec3(8u), bvec3((x & uvec3(65280u)))); + uvec3 b8 = tint_select(uvec3(0u), uvec3(8u), bvec3((x & uvec3(65280u)))); x = (x >> b8); - uvec3 b4 = mix(uvec3(0u), uvec3(4u), bvec3((x & uvec3(240u)))); + uvec3 b4 = tint_select(uvec3(0u), uvec3(4u), bvec3((x & uvec3(240u)))); x = (x >> b4); - uvec3 b2 = mix(uvec3(0u), uvec3(2u), bvec3((x & uvec3(12u)))); + uvec3 b2 = tint_select(uvec3(0u), uvec3(2u), bvec3((x & uvec3(12u)))); x = (x >> b2); - uvec3 b1 = mix(uvec3(0u), uvec3(1u), bvec3((x & uvec3(2u)))); - uvec3 is_zero = mix(uvec3(0u), uvec3(4294967295u), equal(x, uvec3(0u))); + uvec3 b1 = tint_select(uvec3(0u), uvec3(1u), bvec3((x & uvec3(2u)))); + uvec3 is_zero = tint_select(uvec3(0u), uvec3(4294967295u), equal(x, uvec3(0u))); return ivec3((((((b16 | b8) | b4) | b2) | b1) | is_zero)); } @@ -76,18 +86,23 @@ void main() { } #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + ivec3 tint_first_leading_bit(ivec3 v) { - uvec3 x = mix(uvec3(v), uvec3(~(v)), lessThan(v, ivec3(0))); - uvec3 b16 = mix(uvec3(0u), uvec3(16u), bvec3((x & uvec3(4294901760u)))); + uvec3 x = tint_select(uvec3(v), uvec3(~(v)), lessThan(v, ivec3(0))); + uvec3 b16 = tint_select(uvec3(0u), uvec3(16u), bvec3((x & uvec3(4294901760u)))); x = (x >> b16); - uvec3 b8 = mix(uvec3(0u), uvec3(8u), bvec3((x & uvec3(65280u)))); + uvec3 b8 = tint_select(uvec3(0u), uvec3(8u), bvec3((x & uvec3(65280u)))); x = (x >> b8); - uvec3 b4 = mix(uvec3(0u), uvec3(4u), bvec3((x & uvec3(240u)))); + uvec3 b4 = tint_select(uvec3(0u), uvec3(4u), bvec3((x & uvec3(240u)))); x = (x >> b4); - uvec3 b2 = mix(uvec3(0u), uvec3(2u), bvec3((x & uvec3(12u)))); + uvec3 b2 = tint_select(uvec3(0u), uvec3(2u), bvec3((x & uvec3(12u)))); x = (x >> b2); - uvec3 b1 = mix(uvec3(0u), uvec3(1u), bvec3((x & uvec3(2u)))); - uvec3 is_zero = mix(uvec3(0u), uvec3(4294967295u), equal(x, uvec3(0u))); + uvec3 b1 = tint_select(uvec3(0u), uvec3(1u), bvec3((x & uvec3(2u)))); + uvec3 is_zero = tint_select(uvec3(0u), uvec3(4294967295u), equal(x, uvec3(0u))); return ivec3((((((b16 | b8) | b4) | b2) | b1) | is_zero)); } diff --git a/test/tint/builtins/gen/var/firstLeadingBit/3fd7d0.wgsl.expected.glsl b/test/tint/builtins/gen/var/firstLeadingBit/3fd7d0.wgsl.expected.glsl index d2240c75b1..e2906366a4 100644 --- a/test/tint/builtins/gen/var/firstLeadingBit/3fd7d0.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/firstLeadingBit/3fd7d0.wgsl.expected.glsl @@ -1,17 +1,22 @@ #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + uvec3 tint_first_leading_bit(uvec3 v) { uvec3 x = v; - uvec3 b16 = mix(uvec3(0u), uvec3(16u), bvec3((x & uvec3(4294901760u)))); + uvec3 b16 = tint_select(uvec3(0u), uvec3(16u), bvec3((x & uvec3(4294901760u)))); x = (x >> b16); - uvec3 b8 = mix(uvec3(0u), uvec3(8u), bvec3((x & uvec3(65280u)))); + uvec3 b8 = tint_select(uvec3(0u), uvec3(8u), bvec3((x & uvec3(65280u)))); x = (x >> b8); - uvec3 b4 = mix(uvec3(0u), uvec3(4u), bvec3((x & uvec3(240u)))); + uvec3 b4 = tint_select(uvec3(0u), uvec3(4u), bvec3((x & uvec3(240u)))); x = (x >> b4); - uvec3 b2 = mix(uvec3(0u), uvec3(2u), bvec3((x & uvec3(12u)))); + uvec3 b2 = tint_select(uvec3(0u), uvec3(2u), bvec3((x & uvec3(12u)))); x = (x >> b2); - uvec3 b1 = mix(uvec3(0u), uvec3(1u), bvec3((x & uvec3(2u)))); - uvec3 is_zero = mix(uvec3(0u), uvec3(4294967295u), equal(x, uvec3(0u))); + uvec3 b1 = tint_select(uvec3(0u), uvec3(1u), bvec3((x & uvec3(2u)))); + uvec3 is_zero = tint_select(uvec3(0u), uvec3(4294967295u), equal(x, uvec3(0u))); return uvec3((((((b16 | b8) | b4) | b2) | b1) | is_zero)); } @@ -41,18 +46,23 @@ void main() { #version 310 es precision mediump float; +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + uvec3 tint_first_leading_bit(uvec3 v) { uvec3 x = v; - uvec3 b16 = mix(uvec3(0u), uvec3(16u), bvec3((x & uvec3(4294901760u)))); + uvec3 b16 = tint_select(uvec3(0u), uvec3(16u), bvec3((x & uvec3(4294901760u)))); x = (x >> b16); - uvec3 b8 = mix(uvec3(0u), uvec3(8u), bvec3((x & uvec3(65280u)))); + uvec3 b8 = tint_select(uvec3(0u), uvec3(8u), bvec3((x & uvec3(65280u)))); x = (x >> b8); - uvec3 b4 = mix(uvec3(0u), uvec3(4u), bvec3((x & uvec3(240u)))); + uvec3 b4 = tint_select(uvec3(0u), uvec3(4u), bvec3((x & uvec3(240u)))); x = (x >> b4); - uvec3 b2 = mix(uvec3(0u), uvec3(2u), bvec3((x & uvec3(12u)))); + uvec3 b2 = tint_select(uvec3(0u), uvec3(2u), bvec3((x & uvec3(12u)))); x = (x >> b2); - uvec3 b1 = mix(uvec3(0u), uvec3(1u), bvec3((x & uvec3(2u)))); - uvec3 is_zero = mix(uvec3(0u), uvec3(4294967295u), equal(x, uvec3(0u))); + uvec3 b1 = tint_select(uvec3(0u), uvec3(1u), bvec3((x & uvec3(2u)))); + uvec3 is_zero = tint_select(uvec3(0u), uvec3(4294967295u), equal(x, uvec3(0u))); return uvec3((((((b16 | b8) | b4) | b2) | b1) | is_zero)); } @@ -76,18 +86,23 @@ void main() { } #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + uvec3 tint_first_leading_bit(uvec3 v) { uvec3 x = v; - uvec3 b16 = mix(uvec3(0u), uvec3(16u), bvec3((x & uvec3(4294901760u)))); + uvec3 b16 = tint_select(uvec3(0u), uvec3(16u), bvec3((x & uvec3(4294901760u)))); x = (x >> b16); - uvec3 b8 = mix(uvec3(0u), uvec3(8u), bvec3((x & uvec3(65280u)))); + uvec3 b8 = tint_select(uvec3(0u), uvec3(8u), bvec3((x & uvec3(65280u)))); x = (x >> b8); - uvec3 b4 = mix(uvec3(0u), uvec3(4u), bvec3((x & uvec3(240u)))); + uvec3 b4 = tint_select(uvec3(0u), uvec3(4u), bvec3((x & uvec3(240u)))); x = (x >> b4); - uvec3 b2 = mix(uvec3(0u), uvec3(2u), bvec3((x & uvec3(12u)))); + uvec3 b2 = tint_select(uvec3(0u), uvec3(2u), bvec3((x & uvec3(12u)))); x = (x >> b2); - uvec3 b1 = mix(uvec3(0u), uvec3(1u), bvec3((x & uvec3(2u)))); - uvec3 is_zero = mix(uvec3(0u), uvec3(4294967295u), equal(x, uvec3(0u))); + uvec3 b1 = tint_select(uvec3(0u), uvec3(1u), bvec3((x & uvec3(2u)))); + uvec3 is_zero = tint_select(uvec3(0u), uvec3(4294967295u), equal(x, uvec3(0u))); return uvec3((((((b16 | b8) | b4) | b2) | b1) | is_zero)); } diff --git a/test/tint/builtins/gen/var/firstLeadingBit/6fe804.wgsl.expected.glsl b/test/tint/builtins/gen/var/firstLeadingBit/6fe804.wgsl.expected.glsl index 21961cb3ce..2a81d48087 100644 --- a/test/tint/builtins/gen/var/firstLeadingBit/6fe804.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/firstLeadingBit/6fe804.wgsl.expected.glsl @@ -1,17 +1,22 @@ #version 310 es +uvec2 tint_select(uvec2 param_0, uvec2 param_1, bvec2 param_2) { + return uvec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + uvec2 tint_first_leading_bit(uvec2 v) { uvec2 x = v; - uvec2 b16 = mix(uvec2(0u), uvec2(16u), bvec2((x & uvec2(4294901760u)))); + uvec2 b16 = tint_select(uvec2(0u), uvec2(16u), bvec2((x & uvec2(4294901760u)))); x = (x >> b16); - uvec2 b8 = mix(uvec2(0u), uvec2(8u), bvec2((x & uvec2(65280u)))); + uvec2 b8 = tint_select(uvec2(0u), uvec2(8u), bvec2((x & uvec2(65280u)))); x = (x >> b8); - uvec2 b4 = mix(uvec2(0u), uvec2(4u), bvec2((x & uvec2(240u)))); + uvec2 b4 = tint_select(uvec2(0u), uvec2(4u), bvec2((x & uvec2(240u)))); x = (x >> b4); - uvec2 b2 = mix(uvec2(0u), uvec2(2u), bvec2((x & uvec2(12u)))); + uvec2 b2 = tint_select(uvec2(0u), uvec2(2u), bvec2((x & uvec2(12u)))); x = (x >> b2); - uvec2 b1 = mix(uvec2(0u), uvec2(1u), bvec2((x & uvec2(2u)))); - uvec2 is_zero = mix(uvec2(0u), uvec2(4294967295u), equal(x, uvec2(0u))); + uvec2 b1 = tint_select(uvec2(0u), uvec2(1u), bvec2((x & uvec2(2u)))); + uvec2 is_zero = tint_select(uvec2(0u), uvec2(4294967295u), equal(x, uvec2(0u))); return uvec2((((((b16 | b8) | b4) | b2) | b1) | is_zero)); } @@ -41,18 +46,23 @@ void main() { #version 310 es precision mediump float; +uvec2 tint_select(uvec2 param_0, uvec2 param_1, bvec2 param_2) { + return uvec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + uvec2 tint_first_leading_bit(uvec2 v) { uvec2 x = v; - uvec2 b16 = mix(uvec2(0u), uvec2(16u), bvec2((x & uvec2(4294901760u)))); + uvec2 b16 = tint_select(uvec2(0u), uvec2(16u), bvec2((x & uvec2(4294901760u)))); x = (x >> b16); - uvec2 b8 = mix(uvec2(0u), uvec2(8u), bvec2((x & uvec2(65280u)))); + uvec2 b8 = tint_select(uvec2(0u), uvec2(8u), bvec2((x & uvec2(65280u)))); x = (x >> b8); - uvec2 b4 = mix(uvec2(0u), uvec2(4u), bvec2((x & uvec2(240u)))); + uvec2 b4 = tint_select(uvec2(0u), uvec2(4u), bvec2((x & uvec2(240u)))); x = (x >> b4); - uvec2 b2 = mix(uvec2(0u), uvec2(2u), bvec2((x & uvec2(12u)))); + uvec2 b2 = tint_select(uvec2(0u), uvec2(2u), bvec2((x & uvec2(12u)))); x = (x >> b2); - uvec2 b1 = mix(uvec2(0u), uvec2(1u), bvec2((x & uvec2(2u)))); - uvec2 is_zero = mix(uvec2(0u), uvec2(4294967295u), equal(x, uvec2(0u))); + uvec2 b1 = tint_select(uvec2(0u), uvec2(1u), bvec2((x & uvec2(2u)))); + uvec2 is_zero = tint_select(uvec2(0u), uvec2(4294967295u), equal(x, uvec2(0u))); return uvec2((((((b16 | b8) | b4) | b2) | b1) | is_zero)); } @@ -76,18 +86,23 @@ void main() { } #version 310 es +uvec2 tint_select(uvec2 param_0, uvec2 param_1, bvec2 param_2) { + return uvec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + uvec2 tint_first_leading_bit(uvec2 v) { uvec2 x = v; - uvec2 b16 = mix(uvec2(0u), uvec2(16u), bvec2((x & uvec2(4294901760u)))); + uvec2 b16 = tint_select(uvec2(0u), uvec2(16u), bvec2((x & uvec2(4294901760u)))); x = (x >> b16); - uvec2 b8 = mix(uvec2(0u), uvec2(8u), bvec2((x & uvec2(65280u)))); + uvec2 b8 = tint_select(uvec2(0u), uvec2(8u), bvec2((x & uvec2(65280u)))); x = (x >> b8); - uvec2 b4 = mix(uvec2(0u), uvec2(4u), bvec2((x & uvec2(240u)))); + uvec2 b4 = tint_select(uvec2(0u), uvec2(4u), bvec2((x & uvec2(240u)))); x = (x >> b4); - uvec2 b2 = mix(uvec2(0u), uvec2(2u), bvec2((x & uvec2(12u)))); + uvec2 b2 = tint_select(uvec2(0u), uvec2(2u), bvec2((x & uvec2(12u)))); x = (x >> b2); - uvec2 b1 = mix(uvec2(0u), uvec2(1u), bvec2((x & uvec2(2u)))); - uvec2 is_zero = mix(uvec2(0u), uvec2(4294967295u), equal(x, uvec2(0u))); + uvec2 b1 = tint_select(uvec2(0u), uvec2(1u), bvec2((x & uvec2(2u)))); + uvec2 is_zero = tint_select(uvec2(0u), uvec2(4294967295u), equal(x, uvec2(0u))); return uvec2((((((b16 | b8) | b4) | b2) | b1) | is_zero)); } diff --git a/test/tint/builtins/gen/var/firstLeadingBit/a622c2.wgsl.expected.glsl b/test/tint/builtins/gen/var/firstLeadingBit/a622c2.wgsl.expected.glsl index ec78a1e7e3..c9b0feada6 100644 --- a/test/tint/builtins/gen/var/firstLeadingBit/a622c2.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/firstLeadingBit/a622c2.wgsl.expected.glsl @@ -1,17 +1,22 @@ #version 310 es +uvec2 tint_select(uvec2 param_0, uvec2 param_1, bvec2 param_2) { + return uvec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + ivec2 tint_first_leading_bit(ivec2 v) { - uvec2 x = mix(uvec2(v), uvec2(~(v)), lessThan(v, ivec2(0))); - uvec2 b16 = mix(uvec2(0u), uvec2(16u), bvec2((x & uvec2(4294901760u)))); + uvec2 x = tint_select(uvec2(v), uvec2(~(v)), lessThan(v, ivec2(0))); + uvec2 b16 = tint_select(uvec2(0u), uvec2(16u), bvec2((x & uvec2(4294901760u)))); x = (x >> b16); - uvec2 b8 = mix(uvec2(0u), uvec2(8u), bvec2((x & uvec2(65280u)))); + uvec2 b8 = tint_select(uvec2(0u), uvec2(8u), bvec2((x & uvec2(65280u)))); x = (x >> b8); - uvec2 b4 = mix(uvec2(0u), uvec2(4u), bvec2((x & uvec2(240u)))); + uvec2 b4 = tint_select(uvec2(0u), uvec2(4u), bvec2((x & uvec2(240u)))); x = (x >> b4); - uvec2 b2 = mix(uvec2(0u), uvec2(2u), bvec2((x & uvec2(12u)))); + uvec2 b2 = tint_select(uvec2(0u), uvec2(2u), bvec2((x & uvec2(12u)))); x = (x >> b2); - uvec2 b1 = mix(uvec2(0u), uvec2(1u), bvec2((x & uvec2(2u)))); - uvec2 is_zero = mix(uvec2(0u), uvec2(4294967295u), equal(x, uvec2(0u))); + uvec2 b1 = tint_select(uvec2(0u), uvec2(1u), bvec2((x & uvec2(2u)))); + uvec2 is_zero = tint_select(uvec2(0u), uvec2(4294967295u), equal(x, uvec2(0u))); return ivec2((((((b16 | b8) | b4) | b2) | b1) | is_zero)); } @@ -41,18 +46,23 @@ void main() { #version 310 es precision mediump float; +uvec2 tint_select(uvec2 param_0, uvec2 param_1, bvec2 param_2) { + return uvec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + ivec2 tint_first_leading_bit(ivec2 v) { - uvec2 x = mix(uvec2(v), uvec2(~(v)), lessThan(v, ivec2(0))); - uvec2 b16 = mix(uvec2(0u), uvec2(16u), bvec2((x & uvec2(4294901760u)))); + uvec2 x = tint_select(uvec2(v), uvec2(~(v)), lessThan(v, ivec2(0))); + uvec2 b16 = tint_select(uvec2(0u), uvec2(16u), bvec2((x & uvec2(4294901760u)))); x = (x >> b16); - uvec2 b8 = mix(uvec2(0u), uvec2(8u), bvec2((x & uvec2(65280u)))); + uvec2 b8 = tint_select(uvec2(0u), uvec2(8u), bvec2((x & uvec2(65280u)))); x = (x >> b8); - uvec2 b4 = mix(uvec2(0u), uvec2(4u), bvec2((x & uvec2(240u)))); + uvec2 b4 = tint_select(uvec2(0u), uvec2(4u), bvec2((x & uvec2(240u)))); x = (x >> b4); - uvec2 b2 = mix(uvec2(0u), uvec2(2u), bvec2((x & uvec2(12u)))); + uvec2 b2 = tint_select(uvec2(0u), uvec2(2u), bvec2((x & uvec2(12u)))); x = (x >> b2); - uvec2 b1 = mix(uvec2(0u), uvec2(1u), bvec2((x & uvec2(2u)))); - uvec2 is_zero = mix(uvec2(0u), uvec2(4294967295u), equal(x, uvec2(0u))); + uvec2 b1 = tint_select(uvec2(0u), uvec2(1u), bvec2((x & uvec2(2u)))); + uvec2 is_zero = tint_select(uvec2(0u), uvec2(4294967295u), equal(x, uvec2(0u))); return ivec2((((((b16 | b8) | b4) | b2) | b1) | is_zero)); } @@ -76,18 +86,23 @@ void main() { } #version 310 es +uvec2 tint_select(uvec2 param_0, uvec2 param_1, bvec2 param_2) { + return uvec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + ivec2 tint_first_leading_bit(ivec2 v) { - uvec2 x = mix(uvec2(v), uvec2(~(v)), lessThan(v, ivec2(0))); - uvec2 b16 = mix(uvec2(0u), uvec2(16u), bvec2((x & uvec2(4294901760u)))); + uvec2 x = tint_select(uvec2(v), uvec2(~(v)), lessThan(v, ivec2(0))); + uvec2 b16 = tint_select(uvec2(0u), uvec2(16u), bvec2((x & uvec2(4294901760u)))); x = (x >> b16); - uvec2 b8 = mix(uvec2(0u), uvec2(8u), bvec2((x & uvec2(65280u)))); + uvec2 b8 = tint_select(uvec2(0u), uvec2(8u), bvec2((x & uvec2(65280u)))); x = (x >> b8); - uvec2 b4 = mix(uvec2(0u), uvec2(4u), bvec2((x & uvec2(240u)))); + uvec2 b4 = tint_select(uvec2(0u), uvec2(4u), bvec2((x & uvec2(240u)))); x = (x >> b4); - uvec2 b2 = mix(uvec2(0u), uvec2(2u), bvec2((x & uvec2(12u)))); + uvec2 b2 = tint_select(uvec2(0u), uvec2(2u), bvec2((x & uvec2(12u)))); x = (x >> b2); - uvec2 b1 = mix(uvec2(0u), uvec2(1u), bvec2((x & uvec2(2u)))); - uvec2 is_zero = mix(uvec2(0u), uvec2(4294967295u), equal(x, uvec2(0u))); + uvec2 b1 = tint_select(uvec2(0u), uvec2(1u), bvec2((x & uvec2(2u)))); + uvec2 is_zero = tint_select(uvec2(0u), uvec2(4294967295u), equal(x, uvec2(0u))); return ivec2((((((b16 | b8) | b4) | b2) | b1) | is_zero)); } diff --git a/test/tint/builtins/gen/var/firstLeadingBit/c1f940.wgsl.expected.glsl b/test/tint/builtins/gen/var/firstLeadingBit/c1f940.wgsl.expected.glsl index 45f044a909..0ddc1e948b 100644 --- a/test/tint/builtins/gen/var/firstLeadingBit/c1f940.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/firstLeadingBit/c1f940.wgsl.expected.glsl @@ -1,17 +1,22 @@ #version 310 es +uvec4 tint_select(uvec4 param_0, uvec4 param_1, bvec4 param_2) { + return uvec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + ivec4 tint_first_leading_bit(ivec4 v) { - uvec4 x = mix(uvec4(v), uvec4(~(v)), lessThan(v, ivec4(0))); - uvec4 b16 = mix(uvec4(0u), uvec4(16u), bvec4((x & uvec4(4294901760u)))); + uvec4 x = tint_select(uvec4(v), uvec4(~(v)), lessThan(v, ivec4(0))); + uvec4 b16 = tint_select(uvec4(0u), uvec4(16u), bvec4((x & uvec4(4294901760u)))); x = (x >> b16); - uvec4 b8 = mix(uvec4(0u), uvec4(8u), bvec4((x & uvec4(65280u)))); + uvec4 b8 = tint_select(uvec4(0u), uvec4(8u), bvec4((x & uvec4(65280u)))); x = (x >> b8); - uvec4 b4 = mix(uvec4(0u), uvec4(4u), bvec4((x & uvec4(240u)))); + uvec4 b4 = tint_select(uvec4(0u), uvec4(4u), bvec4((x & uvec4(240u)))); x = (x >> b4); - uvec4 b2 = mix(uvec4(0u), uvec4(2u), bvec4((x & uvec4(12u)))); + uvec4 b2 = tint_select(uvec4(0u), uvec4(2u), bvec4((x & uvec4(12u)))); x = (x >> b2); - uvec4 b1 = mix(uvec4(0u), uvec4(1u), bvec4((x & uvec4(2u)))); - uvec4 is_zero = mix(uvec4(0u), uvec4(4294967295u), equal(x, uvec4(0u))); + uvec4 b1 = tint_select(uvec4(0u), uvec4(1u), bvec4((x & uvec4(2u)))); + uvec4 is_zero = tint_select(uvec4(0u), uvec4(4294967295u), equal(x, uvec4(0u))); return ivec4((((((b16 | b8) | b4) | b2) | b1) | is_zero)); } @@ -41,18 +46,23 @@ void main() { #version 310 es precision mediump float; +uvec4 tint_select(uvec4 param_0, uvec4 param_1, bvec4 param_2) { + return uvec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + ivec4 tint_first_leading_bit(ivec4 v) { - uvec4 x = mix(uvec4(v), uvec4(~(v)), lessThan(v, ivec4(0))); - uvec4 b16 = mix(uvec4(0u), uvec4(16u), bvec4((x & uvec4(4294901760u)))); + uvec4 x = tint_select(uvec4(v), uvec4(~(v)), lessThan(v, ivec4(0))); + uvec4 b16 = tint_select(uvec4(0u), uvec4(16u), bvec4((x & uvec4(4294901760u)))); x = (x >> b16); - uvec4 b8 = mix(uvec4(0u), uvec4(8u), bvec4((x & uvec4(65280u)))); + uvec4 b8 = tint_select(uvec4(0u), uvec4(8u), bvec4((x & uvec4(65280u)))); x = (x >> b8); - uvec4 b4 = mix(uvec4(0u), uvec4(4u), bvec4((x & uvec4(240u)))); + uvec4 b4 = tint_select(uvec4(0u), uvec4(4u), bvec4((x & uvec4(240u)))); x = (x >> b4); - uvec4 b2 = mix(uvec4(0u), uvec4(2u), bvec4((x & uvec4(12u)))); + uvec4 b2 = tint_select(uvec4(0u), uvec4(2u), bvec4((x & uvec4(12u)))); x = (x >> b2); - uvec4 b1 = mix(uvec4(0u), uvec4(1u), bvec4((x & uvec4(2u)))); - uvec4 is_zero = mix(uvec4(0u), uvec4(4294967295u), equal(x, uvec4(0u))); + uvec4 b1 = tint_select(uvec4(0u), uvec4(1u), bvec4((x & uvec4(2u)))); + uvec4 is_zero = tint_select(uvec4(0u), uvec4(4294967295u), equal(x, uvec4(0u))); return ivec4((((((b16 | b8) | b4) | b2) | b1) | is_zero)); } @@ -76,18 +86,23 @@ void main() { } #version 310 es +uvec4 tint_select(uvec4 param_0, uvec4 param_1, bvec4 param_2) { + return uvec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + ivec4 tint_first_leading_bit(ivec4 v) { - uvec4 x = mix(uvec4(v), uvec4(~(v)), lessThan(v, ivec4(0))); - uvec4 b16 = mix(uvec4(0u), uvec4(16u), bvec4((x & uvec4(4294901760u)))); + uvec4 x = tint_select(uvec4(v), uvec4(~(v)), lessThan(v, ivec4(0))); + uvec4 b16 = tint_select(uvec4(0u), uvec4(16u), bvec4((x & uvec4(4294901760u)))); x = (x >> b16); - uvec4 b8 = mix(uvec4(0u), uvec4(8u), bvec4((x & uvec4(65280u)))); + uvec4 b8 = tint_select(uvec4(0u), uvec4(8u), bvec4((x & uvec4(65280u)))); x = (x >> b8); - uvec4 b4 = mix(uvec4(0u), uvec4(4u), bvec4((x & uvec4(240u)))); + uvec4 b4 = tint_select(uvec4(0u), uvec4(4u), bvec4((x & uvec4(240u)))); x = (x >> b4); - uvec4 b2 = mix(uvec4(0u), uvec4(2u), bvec4((x & uvec4(12u)))); + uvec4 b2 = tint_select(uvec4(0u), uvec4(2u), bvec4((x & uvec4(12u)))); x = (x >> b2); - uvec4 b1 = mix(uvec4(0u), uvec4(1u), bvec4((x & uvec4(2u)))); - uvec4 is_zero = mix(uvec4(0u), uvec4(4294967295u), equal(x, uvec4(0u))); + uvec4 b1 = tint_select(uvec4(0u), uvec4(1u), bvec4((x & uvec4(2u)))); + uvec4 is_zero = tint_select(uvec4(0u), uvec4(4294967295u), equal(x, uvec4(0u))); return ivec4((((((b16 | b8) | b4) | b2) | b1) | is_zero)); } diff --git a/test/tint/builtins/gen/var/firstTrailingBit/110f2c.wgsl.expected.glsl b/test/tint/builtins/gen/var/firstTrailingBit/110f2c.wgsl.expected.glsl index a6c543178c..8c9092f464 100644 --- a/test/tint/builtins/gen/var/firstTrailingBit/110f2c.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/firstTrailingBit/110f2c.wgsl.expected.glsl @@ -1,17 +1,22 @@ #version 310 es +uvec4 tint_select(uvec4 param_0, uvec4 param_1, bvec4 param_2) { + return uvec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + uvec4 tint_first_trailing_bit(uvec4 v) { uvec4 x = uvec4(v); - uvec4 b16 = mix(uvec4(16u), uvec4(0u), bvec4((x & uvec4(65535u)))); + uvec4 b16 = tint_select(uvec4(16u), uvec4(0u), bvec4((x & uvec4(65535u)))); x = (x >> b16); - uvec4 b8 = mix(uvec4(8u), uvec4(0u), bvec4((x & uvec4(255u)))); + uvec4 b8 = tint_select(uvec4(8u), uvec4(0u), bvec4((x & uvec4(255u)))); x = (x >> b8); - uvec4 b4 = mix(uvec4(4u), uvec4(0u), bvec4((x & uvec4(15u)))); + uvec4 b4 = tint_select(uvec4(4u), uvec4(0u), bvec4((x & uvec4(15u)))); x = (x >> b4); - uvec4 b2 = mix(uvec4(2u), uvec4(0u), bvec4((x & uvec4(3u)))); + uvec4 b2 = tint_select(uvec4(2u), uvec4(0u), bvec4((x & uvec4(3u)))); x = (x >> b2); - uvec4 b1 = mix(uvec4(1u), uvec4(0u), bvec4((x & uvec4(1u)))); - uvec4 is_zero = mix(uvec4(0u), uvec4(4294967295u), equal(x, uvec4(0u))); + uvec4 b1 = tint_select(uvec4(1u), uvec4(0u), bvec4((x & uvec4(1u)))); + uvec4 is_zero = tint_select(uvec4(0u), uvec4(4294967295u), equal(x, uvec4(0u))); return uvec4((((((b16 | b8) | b4) | b2) | b1) | is_zero)); } @@ -41,18 +46,23 @@ void main() { #version 310 es precision mediump float; +uvec4 tint_select(uvec4 param_0, uvec4 param_1, bvec4 param_2) { + return uvec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + uvec4 tint_first_trailing_bit(uvec4 v) { uvec4 x = uvec4(v); - uvec4 b16 = mix(uvec4(16u), uvec4(0u), bvec4((x & uvec4(65535u)))); + uvec4 b16 = tint_select(uvec4(16u), uvec4(0u), bvec4((x & uvec4(65535u)))); x = (x >> b16); - uvec4 b8 = mix(uvec4(8u), uvec4(0u), bvec4((x & uvec4(255u)))); + uvec4 b8 = tint_select(uvec4(8u), uvec4(0u), bvec4((x & uvec4(255u)))); x = (x >> b8); - uvec4 b4 = mix(uvec4(4u), uvec4(0u), bvec4((x & uvec4(15u)))); + uvec4 b4 = tint_select(uvec4(4u), uvec4(0u), bvec4((x & uvec4(15u)))); x = (x >> b4); - uvec4 b2 = mix(uvec4(2u), uvec4(0u), bvec4((x & uvec4(3u)))); + uvec4 b2 = tint_select(uvec4(2u), uvec4(0u), bvec4((x & uvec4(3u)))); x = (x >> b2); - uvec4 b1 = mix(uvec4(1u), uvec4(0u), bvec4((x & uvec4(1u)))); - uvec4 is_zero = mix(uvec4(0u), uvec4(4294967295u), equal(x, uvec4(0u))); + uvec4 b1 = tint_select(uvec4(1u), uvec4(0u), bvec4((x & uvec4(1u)))); + uvec4 is_zero = tint_select(uvec4(0u), uvec4(4294967295u), equal(x, uvec4(0u))); return uvec4((((((b16 | b8) | b4) | b2) | b1) | is_zero)); } @@ -76,18 +86,23 @@ void main() { } #version 310 es +uvec4 tint_select(uvec4 param_0, uvec4 param_1, bvec4 param_2) { + return uvec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + uvec4 tint_first_trailing_bit(uvec4 v) { uvec4 x = uvec4(v); - uvec4 b16 = mix(uvec4(16u), uvec4(0u), bvec4((x & uvec4(65535u)))); + uvec4 b16 = tint_select(uvec4(16u), uvec4(0u), bvec4((x & uvec4(65535u)))); x = (x >> b16); - uvec4 b8 = mix(uvec4(8u), uvec4(0u), bvec4((x & uvec4(255u)))); + uvec4 b8 = tint_select(uvec4(8u), uvec4(0u), bvec4((x & uvec4(255u)))); x = (x >> b8); - uvec4 b4 = mix(uvec4(4u), uvec4(0u), bvec4((x & uvec4(15u)))); + uvec4 b4 = tint_select(uvec4(4u), uvec4(0u), bvec4((x & uvec4(15u)))); x = (x >> b4); - uvec4 b2 = mix(uvec4(2u), uvec4(0u), bvec4((x & uvec4(3u)))); + uvec4 b2 = tint_select(uvec4(2u), uvec4(0u), bvec4((x & uvec4(3u)))); x = (x >> b2); - uvec4 b1 = mix(uvec4(1u), uvec4(0u), bvec4((x & uvec4(1u)))); - uvec4 is_zero = mix(uvec4(0u), uvec4(4294967295u), equal(x, uvec4(0u))); + uvec4 b1 = tint_select(uvec4(1u), uvec4(0u), bvec4((x & uvec4(1u)))); + uvec4 is_zero = tint_select(uvec4(0u), uvec4(4294967295u), equal(x, uvec4(0u))); return uvec4((((((b16 | b8) | b4) | b2) | b1) | is_zero)); } diff --git a/test/tint/builtins/gen/var/firstTrailingBit/45eb10.wgsl.expected.glsl b/test/tint/builtins/gen/var/firstTrailingBit/45eb10.wgsl.expected.glsl index c4c367de93..67e55e889e 100644 --- a/test/tint/builtins/gen/var/firstTrailingBit/45eb10.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/firstTrailingBit/45eb10.wgsl.expected.glsl @@ -1,17 +1,22 @@ #version 310 es +uvec2 tint_select(uvec2 param_0, uvec2 param_1, bvec2 param_2) { + return uvec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + uvec2 tint_first_trailing_bit(uvec2 v) { uvec2 x = uvec2(v); - uvec2 b16 = mix(uvec2(16u), uvec2(0u), bvec2((x & uvec2(65535u)))); + uvec2 b16 = tint_select(uvec2(16u), uvec2(0u), bvec2((x & uvec2(65535u)))); x = (x >> b16); - uvec2 b8 = mix(uvec2(8u), uvec2(0u), bvec2((x & uvec2(255u)))); + uvec2 b8 = tint_select(uvec2(8u), uvec2(0u), bvec2((x & uvec2(255u)))); x = (x >> b8); - uvec2 b4 = mix(uvec2(4u), uvec2(0u), bvec2((x & uvec2(15u)))); + uvec2 b4 = tint_select(uvec2(4u), uvec2(0u), bvec2((x & uvec2(15u)))); x = (x >> b4); - uvec2 b2 = mix(uvec2(2u), uvec2(0u), bvec2((x & uvec2(3u)))); + uvec2 b2 = tint_select(uvec2(2u), uvec2(0u), bvec2((x & uvec2(3u)))); x = (x >> b2); - uvec2 b1 = mix(uvec2(1u), uvec2(0u), bvec2((x & uvec2(1u)))); - uvec2 is_zero = mix(uvec2(0u), uvec2(4294967295u), equal(x, uvec2(0u))); + uvec2 b1 = tint_select(uvec2(1u), uvec2(0u), bvec2((x & uvec2(1u)))); + uvec2 is_zero = tint_select(uvec2(0u), uvec2(4294967295u), equal(x, uvec2(0u))); return uvec2((((((b16 | b8) | b4) | b2) | b1) | is_zero)); } @@ -41,18 +46,23 @@ void main() { #version 310 es precision mediump float; +uvec2 tint_select(uvec2 param_0, uvec2 param_1, bvec2 param_2) { + return uvec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + uvec2 tint_first_trailing_bit(uvec2 v) { uvec2 x = uvec2(v); - uvec2 b16 = mix(uvec2(16u), uvec2(0u), bvec2((x & uvec2(65535u)))); + uvec2 b16 = tint_select(uvec2(16u), uvec2(0u), bvec2((x & uvec2(65535u)))); x = (x >> b16); - uvec2 b8 = mix(uvec2(8u), uvec2(0u), bvec2((x & uvec2(255u)))); + uvec2 b8 = tint_select(uvec2(8u), uvec2(0u), bvec2((x & uvec2(255u)))); x = (x >> b8); - uvec2 b4 = mix(uvec2(4u), uvec2(0u), bvec2((x & uvec2(15u)))); + uvec2 b4 = tint_select(uvec2(4u), uvec2(0u), bvec2((x & uvec2(15u)))); x = (x >> b4); - uvec2 b2 = mix(uvec2(2u), uvec2(0u), bvec2((x & uvec2(3u)))); + uvec2 b2 = tint_select(uvec2(2u), uvec2(0u), bvec2((x & uvec2(3u)))); x = (x >> b2); - uvec2 b1 = mix(uvec2(1u), uvec2(0u), bvec2((x & uvec2(1u)))); - uvec2 is_zero = mix(uvec2(0u), uvec2(4294967295u), equal(x, uvec2(0u))); + uvec2 b1 = tint_select(uvec2(1u), uvec2(0u), bvec2((x & uvec2(1u)))); + uvec2 is_zero = tint_select(uvec2(0u), uvec2(4294967295u), equal(x, uvec2(0u))); return uvec2((((((b16 | b8) | b4) | b2) | b1) | is_zero)); } @@ -76,18 +86,23 @@ void main() { } #version 310 es +uvec2 tint_select(uvec2 param_0, uvec2 param_1, bvec2 param_2) { + return uvec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + uvec2 tint_first_trailing_bit(uvec2 v) { uvec2 x = uvec2(v); - uvec2 b16 = mix(uvec2(16u), uvec2(0u), bvec2((x & uvec2(65535u)))); + uvec2 b16 = tint_select(uvec2(16u), uvec2(0u), bvec2((x & uvec2(65535u)))); x = (x >> b16); - uvec2 b8 = mix(uvec2(8u), uvec2(0u), bvec2((x & uvec2(255u)))); + uvec2 b8 = tint_select(uvec2(8u), uvec2(0u), bvec2((x & uvec2(255u)))); x = (x >> b8); - uvec2 b4 = mix(uvec2(4u), uvec2(0u), bvec2((x & uvec2(15u)))); + uvec2 b4 = tint_select(uvec2(4u), uvec2(0u), bvec2((x & uvec2(15u)))); x = (x >> b4); - uvec2 b2 = mix(uvec2(2u), uvec2(0u), bvec2((x & uvec2(3u)))); + uvec2 b2 = tint_select(uvec2(2u), uvec2(0u), bvec2((x & uvec2(3u)))); x = (x >> b2); - uvec2 b1 = mix(uvec2(1u), uvec2(0u), bvec2((x & uvec2(1u)))); - uvec2 is_zero = mix(uvec2(0u), uvec2(4294967295u), equal(x, uvec2(0u))); + uvec2 b1 = tint_select(uvec2(1u), uvec2(0u), bvec2((x & uvec2(1u)))); + uvec2 is_zero = tint_select(uvec2(0u), uvec2(4294967295u), equal(x, uvec2(0u))); return uvec2((((((b16 | b8) | b4) | b2) | b1) | is_zero)); } diff --git a/test/tint/builtins/gen/var/firstTrailingBit/50c072.wgsl.expected.glsl b/test/tint/builtins/gen/var/firstTrailingBit/50c072.wgsl.expected.glsl index f46b39fa01..ddb8997136 100644 --- a/test/tint/builtins/gen/var/firstTrailingBit/50c072.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/firstTrailingBit/50c072.wgsl.expected.glsl @@ -1,17 +1,22 @@ #version 310 es +uvec2 tint_select(uvec2 param_0, uvec2 param_1, bvec2 param_2) { + return uvec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + ivec2 tint_first_trailing_bit(ivec2 v) { uvec2 x = uvec2(v); - uvec2 b16 = mix(uvec2(16u), uvec2(0u), bvec2((x & uvec2(65535u)))); + uvec2 b16 = tint_select(uvec2(16u), uvec2(0u), bvec2((x & uvec2(65535u)))); x = (x >> b16); - uvec2 b8 = mix(uvec2(8u), uvec2(0u), bvec2((x & uvec2(255u)))); + uvec2 b8 = tint_select(uvec2(8u), uvec2(0u), bvec2((x & uvec2(255u)))); x = (x >> b8); - uvec2 b4 = mix(uvec2(4u), uvec2(0u), bvec2((x & uvec2(15u)))); + uvec2 b4 = tint_select(uvec2(4u), uvec2(0u), bvec2((x & uvec2(15u)))); x = (x >> b4); - uvec2 b2 = mix(uvec2(2u), uvec2(0u), bvec2((x & uvec2(3u)))); + uvec2 b2 = tint_select(uvec2(2u), uvec2(0u), bvec2((x & uvec2(3u)))); x = (x >> b2); - uvec2 b1 = mix(uvec2(1u), uvec2(0u), bvec2((x & uvec2(1u)))); - uvec2 is_zero = mix(uvec2(0u), uvec2(4294967295u), equal(x, uvec2(0u))); + uvec2 b1 = tint_select(uvec2(1u), uvec2(0u), bvec2((x & uvec2(1u)))); + uvec2 is_zero = tint_select(uvec2(0u), uvec2(4294967295u), equal(x, uvec2(0u))); return ivec2((((((b16 | b8) | b4) | b2) | b1) | is_zero)); } @@ -41,18 +46,23 @@ void main() { #version 310 es precision mediump float; +uvec2 tint_select(uvec2 param_0, uvec2 param_1, bvec2 param_2) { + return uvec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + ivec2 tint_first_trailing_bit(ivec2 v) { uvec2 x = uvec2(v); - uvec2 b16 = mix(uvec2(16u), uvec2(0u), bvec2((x & uvec2(65535u)))); + uvec2 b16 = tint_select(uvec2(16u), uvec2(0u), bvec2((x & uvec2(65535u)))); x = (x >> b16); - uvec2 b8 = mix(uvec2(8u), uvec2(0u), bvec2((x & uvec2(255u)))); + uvec2 b8 = tint_select(uvec2(8u), uvec2(0u), bvec2((x & uvec2(255u)))); x = (x >> b8); - uvec2 b4 = mix(uvec2(4u), uvec2(0u), bvec2((x & uvec2(15u)))); + uvec2 b4 = tint_select(uvec2(4u), uvec2(0u), bvec2((x & uvec2(15u)))); x = (x >> b4); - uvec2 b2 = mix(uvec2(2u), uvec2(0u), bvec2((x & uvec2(3u)))); + uvec2 b2 = tint_select(uvec2(2u), uvec2(0u), bvec2((x & uvec2(3u)))); x = (x >> b2); - uvec2 b1 = mix(uvec2(1u), uvec2(0u), bvec2((x & uvec2(1u)))); - uvec2 is_zero = mix(uvec2(0u), uvec2(4294967295u), equal(x, uvec2(0u))); + uvec2 b1 = tint_select(uvec2(1u), uvec2(0u), bvec2((x & uvec2(1u)))); + uvec2 is_zero = tint_select(uvec2(0u), uvec2(4294967295u), equal(x, uvec2(0u))); return ivec2((((((b16 | b8) | b4) | b2) | b1) | is_zero)); } @@ -76,18 +86,23 @@ void main() { } #version 310 es +uvec2 tint_select(uvec2 param_0, uvec2 param_1, bvec2 param_2) { + return uvec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + ivec2 tint_first_trailing_bit(ivec2 v) { uvec2 x = uvec2(v); - uvec2 b16 = mix(uvec2(16u), uvec2(0u), bvec2((x & uvec2(65535u)))); + uvec2 b16 = tint_select(uvec2(16u), uvec2(0u), bvec2((x & uvec2(65535u)))); x = (x >> b16); - uvec2 b8 = mix(uvec2(8u), uvec2(0u), bvec2((x & uvec2(255u)))); + uvec2 b8 = tint_select(uvec2(8u), uvec2(0u), bvec2((x & uvec2(255u)))); x = (x >> b8); - uvec2 b4 = mix(uvec2(4u), uvec2(0u), bvec2((x & uvec2(15u)))); + uvec2 b4 = tint_select(uvec2(4u), uvec2(0u), bvec2((x & uvec2(15u)))); x = (x >> b4); - uvec2 b2 = mix(uvec2(2u), uvec2(0u), bvec2((x & uvec2(3u)))); + uvec2 b2 = tint_select(uvec2(2u), uvec2(0u), bvec2((x & uvec2(3u)))); x = (x >> b2); - uvec2 b1 = mix(uvec2(1u), uvec2(0u), bvec2((x & uvec2(1u)))); - uvec2 is_zero = mix(uvec2(0u), uvec2(4294967295u), equal(x, uvec2(0u))); + uvec2 b1 = tint_select(uvec2(1u), uvec2(0u), bvec2((x & uvec2(1u)))); + uvec2 is_zero = tint_select(uvec2(0u), uvec2(4294967295u), equal(x, uvec2(0u))); return ivec2((((((b16 | b8) | b4) | b2) | b1) | is_zero)); } diff --git a/test/tint/builtins/gen/var/firstTrailingBit/7496d6.wgsl.expected.glsl b/test/tint/builtins/gen/var/firstTrailingBit/7496d6.wgsl.expected.glsl index 62b124a836..822977acf7 100644 --- a/test/tint/builtins/gen/var/firstTrailingBit/7496d6.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/firstTrailingBit/7496d6.wgsl.expected.glsl @@ -1,17 +1,22 @@ #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + ivec3 tint_first_trailing_bit(ivec3 v) { uvec3 x = uvec3(v); - uvec3 b16 = mix(uvec3(16u), uvec3(0u), bvec3((x & uvec3(65535u)))); + uvec3 b16 = tint_select(uvec3(16u), uvec3(0u), bvec3((x & uvec3(65535u)))); x = (x >> b16); - uvec3 b8 = mix(uvec3(8u), uvec3(0u), bvec3((x & uvec3(255u)))); + uvec3 b8 = tint_select(uvec3(8u), uvec3(0u), bvec3((x & uvec3(255u)))); x = (x >> b8); - uvec3 b4 = mix(uvec3(4u), uvec3(0u), bvec3((x & uvec3(15u)))); + uvec3 b4 = tint_select(uvec3(4u), uvec3(0u), bvec3((x & uvec3(15u)))); x = (x >> b4); - uvec3 b2 = mix(uvec3(2u), uvec3(0u), bvec3((x & uvec3(3u)))); + uvec3 b2 = tint_select(uvec3(2u), uvec3(0u), bvec3((x & uvec3(3u)))); x = (x >> b2); - uvec3 b1 = mix(uvec3(1u), uvec3(0u), bvec3((x & uvec3(1u)))); - uvec3 is_zero = mix(uvec3(0u), uvec3(4294967295u), equal(x, uvec3(0u))); + uvec3 b1 = tint_select(uvec3(1u), uvec3(0u), bvec3((x & uvec3(1u)))); + uvec3 is_zero = tint_select(uvec3(0u), uvec3(4294967295u), equal(x, uvec3(0u))); return ivec3((((((b16 | b8) | b4) | b2) | b1) | is_zero)); } @@ -41,18 +46,23 @@ void main() { #version 310 es precision mediump float; +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + ivec3 tint_first_trailing_bit(ivec3 v) { uvec3 x = uvec3(v); - uvec3 b16 = mix(uvec3(16u), uvec3(0u), bvec3((x & uvec3(65535u)))); + uvec3 b16 = tint_select(uvec3(16u), uvec3(0u), bvec3((x & uvec3(65535u)))); x = (x >> b16); - uvec3 b8 = mix(uvec3(8u), uvec3(0u), bvec3((x & uvec3(255u)))); + uvec3 b8 = tint_select(uvec3(8u), uvec3(0u), bvec3((x & uvec3(255u)))); x = (x >> b8); - uvec3 b4 = mix(uvec3(4u), uvec3(0u), bvec3((x & uvec3(15u)))); + uvec3 b4 = tint_select(uvec3(4u), uvec3(0u), bvec3((x & uvec3(15u)))); x = (x >> b4); - uvec3 b2 = mix(uvec3(2u), uvec3(0u), bvec3((x & uvec3(3u)))); + uvec3 b2 = tint_select(uvec3(2u), uvec3(0u), bvec3((x & uvec3(3u)))); x = (x >> b2); - uvec3 b1 = mix(uvec3(1u), uvec3(0u), bvec3((x & uvec3(1u)))); - uvec3 is_zero = mix(uvec3(0u), uvec3(4294967295u), equal(x, uvec3(0u))); + uvec3 b1 = tint_select(uvec3(1u), uvec3(0u), bvec3((x & uvec3(1u)))); + uvec3 is_zero = tint_select(uvec3(0u), uvec3(4294967295u), equal(x, uvec3(0u))); return ivec3((((((b16 | b8) | b4) | b2) | b1) | is_zero)); } @@ -76,18 +86,23 @@ void main() { } #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + ivec3 tint_first_trailing_bit(ivec3 v) { uvec3 x = uvec3(v); - uvec3 b16 = mix(uvec3(16u), uvec3(0u), bvec3((x & uvec3(65535u)))); + uvec3 b16 = tint_select(uvec3(16u), uvec3(0u), bvec3((x & uvec3(65535u)))); x = (x >> b16); - uvec3 b8 = mix(uvec3(8u), uvec3(0u), bvec3((x & uvec3(255u)))); + uvec3 b8 = tint_select(uvec3(8u), uvec3(0u), bvec3((x & uvec3(255u)))); x = (x >> b8); - uvec3 b4 = mix(uvec3(4u), uvec3(0u), bvec3((x & uvec3(15u)))); + uvec3 b4 = tint_select(uvec3(4u), uvec3(0u), bvec3((x & uvec3(15u)))); x = (x >> b4); - uvec3 b2 = mix(uvec3(2u), uvec3(0u), bvec3((x & uvec3(3u)))); + uvec3 b2 = tint_select(uvec3(2u), uvec3(0u), bvec3((x & uvec3(3u)))); x = (x >> b2); - uvec3 b1 = mix(uvec3(1u), uvec3(0u), bvec3((x & uvec3(1u)))); - uvec3 is_zero = mix(uvec3(0u), uvec3(4294967295u), equal(x, uvec3(0u))); + uvec3 b1 = tint_select(uvec3(1u), uvec3(0u), bvec3((x & uvec3(1u)))); + uvec3 is_zero = tint_select(uvec3(0u), uvec3(4294967295u), equal(x, uvec3(0u))); return ivec3((((((b16 | b8) | b4) | b2) | b1) | is_zero)); } diff --git a/test/tint/builtins/gen/var/firstTrailingBit/86551b.wgsl.expected.glsl b/test/tint/builtins/gen/var/firstTrailingBit/86551b.wgsl.expected.glsl index 2921255f76..e491ac234c 100644 --- a/test/tint/builtins/gen/var/firstTrailingBit/86551b.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/firstTrailingBit/86551b.wgsl.expected.glsl @@ -1,17 +1,22 @@ #version 310 es +uvec4 tint_select(uvec4 param_0, uvec4 param_1, bvec4 param_2) { + return uvec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + ivec4 tint_first_trailing_bit(ivec4 v) { uvec4 x = uvec4(v); - uvec4 b16 = mix(uvec4(16u), uvec4(0u), bvec4((x & uvec4(65535u)))); + uvec4 b16 = tint_select(uvec4(16u), uvec4(0u), bvec4((x & uvec4(65535u)))); x = (x >> b16); - uvec4 b8 = mix(uvec4(8u), uvec4(0u), bvec4((x & uvec4(255u)))); + uvec4 b8 = tint_select(uvec4(8u), uvec4(0u), bvec4((x & uvec4(255u)))); x = (x >> b8); - uvec4 b4 = mix(uvec4(4u), uvec4(0u), bvec4((x & uvec4(15u)))); + uvec4 b4 = tint_select(uvec4(4u), uvec4(0u), bvec4((x & uvec4(15u)))); x = (x >> b4); - uvec4 b2 = mix(uvec4(2u), uvec4(0u), bvec4((x & uvec4(3u)))); + uvec4 b2 = tint_select(uvec4(2u), uvec4(0u), bvec4((x & uvec4(3u)))); x = (x >> b2); - uvec4 b1 = mix(uvec4(1u), uvec4(0u), bvec4((x & uvec4(1u)))); - uvec4 is_zero = mix(uvec4(0u), uvec4(4294967295u), equal(x, uvec4(0u))); + uvec4 b1 = tint_select(uvec4(1u), uvec4(0u), bvec4((x & uvec4(1u)))); + uvec4 is_zero = tint_select(uvec4(0u), uvec4(4294967295u), equal(x, uvec4(0u))); return ivec4((((((b16 | b8) | b4) | b2) | b1) | is_zero)); } @@ -41,18 +46,23 @@ void main() { #version 310 es precision mediump float; +uvec4 tint_select(uvec4 param_0, uvec4 param_1, bvec4 param_2) { + return uvec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + ivec4 tint_first_trailing_bit(ivec4 v) { uvec4 x = uvec4(v); - uvec4 b16 = mix(uvec4(16u), uvec4(0u), bvec4((x & uvec4(65535u)))); + uvec4 b16 = tint_select(uvec4(16u), uvec4(0u), bvec4((x & uvec4(65535u)))); x = (x >> b16); - uvec4 b8 = mix(uvec4(8u), uvec4(0u), bvec4((x & uvec4(255u)))); + uvec4 b8 = tint_select(uvec4(8u), uvec4(0u), bvec4((x & uvec4(255u)))); x = (x >> b8); - uvec4 b4 = mix(uvec4(4u), uvec4(0u), bvec4((x & uvec4(15u)))); + uvec4 b4 = tint_select(uvec4(4u), uvec4(0u), bvec4((x & uvec4(15u)))); x = (x >> b4); - uvec4 b2 = mix(uvec4(2u), uvec4(0u), bvec4((x & uvec4(3u)))); + uvec4 b2 = tint_select(uvec4(2u), uvec4(0u), bvec4((x & uvec4(3u)))); x = (x >> b2); - uvec4 b1 = mix(uvec4(1u), uvec4(0u), bvec4((x & uvec4(1u)))); - uvec4 is_zero = mix(uvec4(0u), uvec4(4294967295u), equal(x, uvec4(0u))); + uvec4 b1 = tint_select(uvec4(1u), uvec4(0u), bvec4((x & uvec4(1u)))); + uvec4 is_zero = tint_select(uvec4(0u), uvec4(4294967295u), equal(x, uvec4(0u))); return ivec4((((((b16 | b8) | b4) | b2) | b1) | is_zero)); } @@ -76,18 +86,23 @@ void main() { } #version 310 es +uvec4 tint_select(uvec4 param_0, uvec4 param_1, bvec4 param_2) { + return uvec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + ivec4 tint_first_trailing_bit(ivec4 v) { uvec4 x = uvec4(v); - uvec4 b16 = mix(uvec4(16u), uvec4(0u), bvec4((x & uvec4(65535u)))); + uvec4 b16 = tint_select(uvec4(16u), uvec4(0u), bvec4((x & uvec4(65535u)))); x = (x >> b16); - uvec4 b8 = mix(uvec4(8u), uvec4(0u), bvec4((x & uvec4(255u)))); + uvec4 b8 = tint_select(uvec4(8u), uvec4(0u), bvec4((x & uvec4(255u)))); x = (x >> b8); - uvec4 b4 = mix(uvec4(4u), uvec4(0u), bvec4((x & uvec4(15u)))); + uvec4 b4 = tint_select(uvec4(4u), uvec4(0u), bvec4((x & uvec4(15u)))); x = (x >> b4); - uvec4 b2 = mix(uvec4(2u), uvec4(0u), bvec4((x & uvec4(3u)))); + uvec4 b2 = tint_select(uvec4(2u), uvec4(0u), bvec4((x & uvec4(3u)))); x = (x >> b2); - uvec4 b1 = mix(uvec4(1u), uvec4(0u), bvec4((x & uvec4(1u)))); - uvec4 is_zero = mix(uvec4(0u), uvec4(4294967295u), equal(x, uvec4(0u))); + uvec4 b1 = tint_select(uvec4(1u), uvec4(0u), bvec4((x & uvec4(1u)))); + uvec4 is_zero = tint_select(uvec4(0u), uvec4(4294967295u), equal(x, uvec4(0u))); return ivec4((((((b16 | b8) | b4) | b2) | b1) | is_zero)); } diff --git a/test/tint/builtins/gen/var/firstTrailingBit/cb51ce.wgsl.expected.glsl b/test/tint/builtins/gen/var/firstTrailingBit/cb51ce.wgsl.expected.glsl index d86aa929d4..b57b5e4425 100644 --- a/test/tint/builtins/gen/var/firstTrailingBit/cb51ce.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/firstTrailingBit/cb51ce.wgsl.expected.glsl @@ -1,17 +1,22 @@ #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + uvec3 tint_first_trailing_bit(uvec3 v) { uvec3 x = uvec3(v); - uvec3 b16 = mix(uvec3(16u), uvec3(0u), bvec3((x & uvec3(65535u)))); + uvec3 b16 = tint_select(uvec3(16u), uvec3(0u), bvec3((x & uvec3(65535u)))); x = (x >> b16); - uvec3 b8 = mix(uvec3(8u), uvec3(0u), bvec3((x & uvec3(255u)))); + uvec3 b8 = tint_select(uvec3(8u), uvec3(0u), bvec3((x & uvec3(255u)))); x = (x >> b8); - uvec3 b4 = mix(uvec3(4u), uvec3(0u), bvec3((x & uvec3(15u)))); + uvec3 b4 = tint_select(uvec3(4u), uvec3(0u), bvec3((x & uvec3(15u)))); x = (x >> b4); - uvec3 b2 = mix(uvec3(2u), uvec3(0u), bvec3((x & uvec3(3u)))); + uvec3 b2 = tint_select(uvec3(2u), uvec3(0u), bvec3((x & uvec3(3u)))); x = (x >> b2); - uvec3 b1 = mix(uvec3(1u), uvec3(0u), bvec3((x & uvec3(1u)))); - uvec3 is_zero = mix(uvec3(0u), uvec3(4294967295u), equal(x, uvec3(0u))); + uvec3 b1 = tint_select(uvec3(1u), uvec3(0u), bvec3((x & uvec3(1u)))); + uvec3 is_zero = tint_select(uvec3(0u), uvec3(4294967295u), equal(x, uvec3(0u))); return uvec3((((((b16 | b8) | b4) | b2) | b1) | is_zero)); } @@ -41,18 +46,23 @@ void main() { #version 310 es precision mediump float; +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + uvec3 tint_first_trailing_bit(uvec3 v) { uvec3 x = uvec3(v); - uvec3 b16 = mix(uvec3(16u), uvec3(0u), bvec3((x & uvec3(65535u)))); + uvec3 b16 = tint_select(uvec3(16u), uvec3(0u), bvec3((x & uvec3(65535u)))); x = (x >> b16); - uvec3 b8 = mix(uvec3(8u), uvec3(0u), bvec3((x & uvec3(255u)))); + uvec3 b8 = tint_select(uvec3(8u), uvec3(0u), bvec3((x & uvec3(255u)))); x = (x >> b8); - uvec3 b4 = mix(uvec3(4u), uvec3(0u), bvec3((x & uvec3(15u)))); + uvec3 b4 = tint_select(uvec3(4u), uvec3(0u), bvec3((x & uvec3(15u)))); x = (x >> b4); - uvec3 b2 = mix(uvec3(2u), uvec3(0u), bvec3((x & uvec3(3u)))); + uvec3 b2 = tint_select(uvec3(2u), uvec3(0u), bvec3((x & uvec3(3u)))); x = (x >> b2); - uvec3 b1 = mix(uvec3(1u), uvec3(0u), bvec3((x & uvec3(1u)))); - uvec3 is_zero = mix(uvec3(0u), uvec3(4294967295u), equal(x, uvec3(0u))); + uvec3 b1 = tint_select(uvec3(1u), uvec3(0u), bvec3((x & uvec3(1u)))); + uvec3 is_zero = tint_select(uvec3(0u), uvec3(4294967295u), equal(x, uvec3(0u))); return uvec3((((((b16 | b8) | b4) | b2) | b1) | is_zero)); } @@ -76,18 +86,23 @@ void main() { } #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + uvec3 tint_first_trailing_bit(uvec3 v) { uvec3 x = uvec3(v); - uvec3 b16 = mix(uvec3(16u), uvec3(0u), bvec3((x & uvec3(65535u)))); + uvec3 b16 = tint_select(uvec3(16u), uvec3(0u), bvec3((x & uvec3(65535u)))); x = (x >> b16); - uvec3 b8 = mix(uvec3(8u), uvec3(0u), bvec3((x & uvec3(255u)))); + uvec3 b8 = tint_select(uvec3(8u), uvec3(0u), bvec3((x & uvec3(255u)))); x = (x >> b8); - uvec3 b4 = mix(uvec3(4u), uvec3(0u), bvec3((x & uvec3(15u)))); + uvec3 b4 = tint_select(uvec3(4u), uvec3(0u), bvec3((x & uvec3(15u)))); x = (x >> b4); - uvec3 b2 = mix(uvec3(2u), uvec3(0u), bvec3((x & uvec3(3u)))); + uvec3 b2 = tint_select(uvec3(2u), uvec3(0u), bvec3((x & uvec3(3u)))); x = (x >> b2); - uvec3 b1 = mix(uvec3(1u), uvec3(0u), bvec3((x & uvec3(1u)))); - uvec3 is_zero = mix(uvec3(0u), uvec3(4294967295u), equal(x, uvec3(0u))); + uvec3 b1 = tint_select(uvec3(1u), uvec3(0u), bvec3((x & uvec3(1u)))); + uvec3 is_zero = tint_select(uvec3(0u), uvec3(4294967295u), equal(x, uvec3(0u))); return uvec3((((((b16 | b8) | b4) | b2) | b1) | is_zero)); } diff --git a/test/tint/builtins/gen/var/select/00b848.wgsl.expected.glsl b/test/tint/builtins/gen/var/select/00b848.wgsl.expected.glsl index 83368370e0..34f6617c9f 100644 --- a/test/tint/builtins/gen/var/select/00b848.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/select/00b848.wgsl.expected.glsl @@ -1,5 +1,10 @@ #version 310 es +ivec2 tint_select(ivec2 param_0, ivec2 param_1, bvec2 param_2) { + return ivec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { ivec2 inner; } prevent_dce; @@ -8,7 +13,7 @@ void select_00b848() { ivec2 arg_0 = ivec2(1); ivec2 arg_1 = ivec2(1); bvec2 arg_2 = bvec2(true); - ivec2 res = mix(arg_0, arg_1, arg_2); + ivec2 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = res; } @@ -28,6 +33,11 @@ void main() { #version 310 es precision mediump float; +ivec2 tint_select(ivec2 param_0, ivec2 param_1, bvec2 param_2) { + return ivec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { ivec2 inner; } prevent_dce; @@ -36,7 +46,7 @@ void select_00b848() { ivec2 arg_0 = ivec2(1); ivec2 arg_1 = ivec2(1); bvec2 arg_2 = bvec2(true); - ivec2 res = mix(arg_0, arg_1, arg_2); + ivec2 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = res; } @@ -50,6 +60,11 @@ void main() { } #version 310 es +ivec2 tint_select(ivec2 param_0, ivec2 param_1, bvec2 param_2) { + return ivec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { ivec2 inner; } prevent_dce; @@ -58,7 +73,7 @@ void select_00b848() { ivec2 arg_0 = ivec2(1); ivec2 arg_1 = ivec2(1); bvec2 arg_2 = bvec2(true); - ivec2 res = mix(arg_0, arg_1, arg_2); + ivec2 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = res; } diff --git a/test/tint/builtins/gen/var/select/01e2cd.wgsl.expected.glsl b/test/tint/builtins/gen/var/select/01e2cd.wgsl.expected.glsl index 0eac9de00f..ca709297b6 100644 --- a/test/tint/builtins/gen/var/select/01e2cd.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/select/01e2cd.wgsl.expected.glsl @@ -1,5 +1,10 @@ #version 310 es +ivec3 tint_select(ivec3 param_0, ivec3 param_1, bvec3 param_2) { + return ivec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { ivec3 inner; } prevent_dce; @@ -8,7 +13,7 @@ void select_01e2cd() { ivec3 arg_0 = ivec3(1); ivec3 arg_1 = ivec3(1); bvec3 arg_2 = bvec3(true); - ivec3 res = mix(arg_0, arg_1, arg_2); + ivec3 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = res; } @@ -28,6 +33,11 @@ void main() { #version 310 es precision mediump float; +ivec3 tint_select(ivec3 param_0, ivec3 param_1, bvec3 param_2) { + return ivec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { ivec3 inner; } prevent_dce; @@ -36,7 +46,7 @@ void select_01e2cd() { ivec3 arg_0 = ivec3(1); ivec3 arg_1 = ivec3(1); bvec3 arg_2 = bvec3(true); - ivec3 res = mix(arg_0, arg_1, arg_2); + ivec3 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = res; } @@ -50,6 +60,11 @@ void main() { } #version 310 es +ivec3 tint_select(ivec3 param_0, ivec3 param_1, bvec3 param_2) { + return ivec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { ivec3 inner; } prevent_dce; @@ -58,7 +73,7 @@ void select_01e2cd() { ivec3 arg_0 = ivec3(1); ivec3 arg_1 = ivec3(1); bvec3 arg_2 = bvec3(true); - ivec3 res = mix(arg_0, arg_1, arg_2); + ivec3 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = res; } diff --git a/test/tint/builtins/gen/var/select/1e960b.wgsl.expected.glsl b/test/tint/builtins/gen/var/select/1e960b.wgsl.expected.glsl index 142c5afbb6..ed90de5ebb 100644 --- a/test/tint/builtins/gen/var/select/1e960b.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/select/1e960b.wgsl.expected.glsl @@ -1,5 +1,10 @@ #version 310 es +uvec2 tint_select(uvec2 param_0, uvec2 param_1, bvec2 param_2) { + return uvec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { uvec2 inner; } prevent_dce; @@ -8,7 +13,7 @@ void select_1e960b() { uvec2 arg_0 = uvec2(1u); uvec2 arg_1 = uvec2(1u); bvec2 arg_2 = bvec2(true); - uvec2 res = mix(arg_0, arg_1, arg_2); + uvec2 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = res; } @@ -28,6 +33,11 @@ void main() { #version 310 es precision mediump float; +uvec2 tint_select(uvec2 param_0, uvec2 param_1, bvec2 param_2) { + return uvec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { uvec2 inner; } prevent_dce; @@ -36,7 +46,7 @@ void select_1e960b() { uvec2 arg_0 = uvec2(1u); uvec2 arg_1 = uvec2(1u); bvec2 arg_2 = bvec2(true); - uvec2 res = mix(arg_0, arg_1, arg_2); + uvec2 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = res; } @@ -50,6 +60,11 @@ void main() { } #version 310 es +uvec2 tint_select(uvec2 param_0, uvec2 param_1, bvec2 param_2) { + return uvec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { uvec2 inner; } prevent_dce; @@ -58,7 +73,7 @@ void select_1e960b() { uvec2 arg_0 = uvec2(1u); uvec2 arg_1 = uvec2(1u); bvec2 arg_2 = bvec2(true); - uvec2 res = mix(arg_0, arg_1, arg_2); + uvec2 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = res; } diff --git a/test/tint/builtins/gen/var/select/1f4d93.wgsl.expected.glsl b/test/tint/builtins/gen/var/select/1f4d93.wgsl.expected.glsl index 406d203844..68e04ae533 100644 --- a/test/tint/builtins/gen/var/select/1f4d93.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/select/1f4d93.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +vec2 tint_select(vec2 param_0, vec2 param_1, bvec2 param_2) { + return vec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + void select_1f4d93() { bvec2 arg_2 = bvec2(true); - vec2 res = mix(vec2(1.0f), vec2(1.0f), arg_2); + vec2 res = tint_select(vec2(1.0f), vec2(1.0f), arg_2); } vec4 vertex_main() { @@ -21,9 +26,14 @@ void main() { #version 310 es precision mediump float; +vec2 tint_select(vec2 param_0, vec2 param_1, bvec2 param_2) { + return vec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + void select_1f4d93() { bvec2 arg_2 = bvec2(true); - vec2 res = mix(vec2(1.0f), vec2(1.0f), arg_2); + vec2 res = tint_select(vec2(1.0f), vec2(1.0f), arg_2); } void fragment_main() { @@ -36,9 +46,14 @@ void main() { } #version 310 es +vec2 tint_select(vec2 param_0, vec2 param_1, bvec2 param_2) { + return vec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + void select_1f4d93() { bvec2 arg_2 = bvec2(true); - vec2 res = mix(vec2(1.0f), vec2(1.0f), arg_2); + vec2 res = tint_select(vec2(1.0f), vec2(1.0f), arg_2); } void compute_main() { diff --git a/test/tint/builtins/gen/var/select/266aff.wgsl.expected.glsl b/test/tint/builtins/gen/var/select/266aff.wgsl.expected.glsl index f9220035df..2143720d1a 100644 --- a/test/tint/builtins/gen/var/select/266aff.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/select/266aff.wgsl.expected.glsl @@ -1,5 +1,10 @@ #version 310 es +vec2 tint_select(vec2 param_0, vec2 param_1, bvec2 param_2) { + return vec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { vec2 inner; } prevent_dce; @@ -8,7 +13,7 @@ void select_266aff() { vec2 arg_0 = vec2(1.0f); vec2 arg_1 = vec2(1.0f); bvec2 arg_2 = bvec2(true); - vec2 res = mix(arg_0, arg_1, arg_2); + vec2 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = res; } @@ -28,6 +33,11 @@ void main() { #version 310 es precision mediump float; +vec2 tint_select(vec2 param_0, vec2 param_1, bvec2 param_2) { + return vec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { vec2 inner; } prevent_dce; @@ -36,7 +46,7 @@ void select_266aff() { vec2 arg_0 = vec2(1.0f); vec2 arg_1 = vec2(1.0f); bvec2 arg_2 = bvec2(true); - vec2 res = mix(arg_0, arg_1, arg_2); + vec2 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = res; } @@ -50,6 +60,11 @@ void main() { } #version 310 es +vec2 tint_select(vec2 param_0, vec2 param_1, bvec2 param_2) { + return vec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { vec2 inner; } prevent_dce; @@ -58,7 +73,7 @@ void select_266aff() { vec2 arg_0 = vec2(1.0f); vec2 arg_1 = vec2(1.0f); bvec2 arg_2 = bvec2(true); - vec2 res = mix(arg_0, arg_1, arg_2); + vec2 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = res; } diff --git a/test/tint/builtins/gen/var/select/28a27e.wgsl.expected.glsl b/test/tint/builtins/gen/var/select/28a27e.wgsl.expected.glsl index 2f8093bef4..6802318bc6 100644 --- a/test/tint/builtins/gen/var/select/28a27e.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/select/28a27e.wgsl.expected.glsl @@ -1,5 +1,10 @@ #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { uvec3 inner; } prevent_dce; @@ -8,7 +13,7 @@ void select_28a27e() { uvec3 arg_0 = uvec3(1u); uvec3 arg_1 = uvec3(1u); bvec3 arg_2 = bvec3(true); - uvec3 res = mix(arg_0, arg_1, arg_2); + uvec3 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = res; } @@ -28,6 +33,11 @@ void main() { #version 310 es precision mediump float; +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { uvec3 inner; } prevent_dce; @@ -36,7 +46,7 @@ void select_28a27e() { uvec3 arg_0 = uvec3(1u); uvec3 arg_1 = uvec3(1u); bvec3 arg_2 = bvec3(true); - uvec3 res = mix(arg_0, arg_1, arg_2); + uvec3 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = res; } @@ -50,6 +60,11 @@ void main() { } #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { uvec3 inner; } prevent_dce; @@ -58,7 +73,7 @@ void select_28a27e() { uvec3 arg_0 = uvec3(1u); uvec3 arg_1 = uvec3(1u); bvec3 arg_2 = bvec3(true); - uvec3 res = mix(arg_0, arg_1, arg_2); + uvec3 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = res; } diff --git a/test/tint/builtins/gen/var/select/2c96d4.wgsl.expected.glsl b/test/tint/builtins/gen/var/select/2c96d4.wgsl.expected.glsl index 12eb956cc6..31d3ede574 100644 --- a/test/tint/builtins/gen/var/select/2c96d4.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/select/2c96d4.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +vec3 tint_select(vec3 param_0, vec3 param_1, bvec3 param_2) { + return vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + void select_2c96d4() { bvec3 arg_2 = bvec3(true); - vec3 res = mix(vec3(1.0f), vec3(1.0f), arg_2); + vec3 res = tint_select(vec3(1.0f), vec3(1.0f), arg_2); } vec4 vertex_main() { @@ -21,9 +26,14 @@ void main() { #version 310 es precision mediump float; +vec3 tint_select(vec3 param_0, vec3 param_1, bvec3 param_2) { + return vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + void select_2c96d4() { bvec3 arg_2 = bvec3(true); - vec3 res = mix(vec3(1.0f), vec3(1.0f), arg_2); + vec3 res = tint_select(vec3(1.0f), vec3(1.0f), arg_2); } void fragment_main() { @@ -36,9 +46,14 @@ void main() { } #version 310 es +vec3 tint_select(vec3 param_0, vec3 param_1, bvec3 param_2) { + return vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + void select_2c96d4() { bvec3 arg_2 = bvec3(true); - vec3 res = mix(vec3(1.0f), vec3(1.0f), arg_2); + vec3 res = tint_select(vec3(1.0f), vec3(1.0f), arg_2); } void compute_main() { diff --git a/test/tint/builtins/gen/var/select/431dfb.wgsl.expected.glsl b/test/tint/builtins/gen/var/select/431dfb.wgsl.expected.glsl index 2809a08932..ce206d6112 100644 --- a/test/tint/builtins/gen/var/select/431dfb.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/select/431dfb.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +ivec2 tint_select(ivec2 param_0, ivec2 param_1, bvec2 param_2) { + return ivec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + void select_431dfb() { bvec2 arg_2 = bvec2(true); - ivec2 res = mix(ivec2(1), ivec2(1), arg_2); + ivec2 res = tint_select(ivec2(1), ivec2(1), arg_2); } vec4 vertex_main() { @@ -21,9 +26,14 @@ void main() { #version 310 es precision mediump float; +ivec2 tint_select(ivec2 param_0, ivec2 param_1, bvec2 param_2) { + return ivec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + void select_431dfb() { bvec2 arg_2 = bvec2(true); - ivec2 res = mix(ivec2(1), ivec2(1), arg_2); + ivec2 res = tint_select(ivec2(1), ivec2(1), arg_2); } void fragment_main() { @@ -36,9 +46,14 @@ void main() { } #version 310 es +ivec2 tint_select(ivec2 param_0, ivec2 param_1, bvec2 param_2) { + return ivec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + void select_431dfb() { bvec2 arg_2 = bvec2(true); - ivec2 res = mix(ivec2(1), ivec2(1), arg_2); + ivec2 res = tint_select(ivec2(1), ivec2(1), arg_2); } void compute_main() { diff --git a/test/tint/builtins/gen/var/select/43741e.wgsl.expected.glsl b/test/tint/builtins/gen/var/select/43741e.wgsl.expected.glsl index ad6e80ef38..f709f8a480 100644 --- a/test/tint/builtins/gen/var/select/43741e.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/select/43741e.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +vec4 tint_select(vec4 param_0, vec4 param_1, bvec4 param_2) { + return vec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + void select_43741e() { bvec4 arg_2 = bvec4(true); - vec4 res = mix(vec4(1.0f), vec4(1.0f), arg_2); + vec4 res = tint_select(vec4(1.0f), vec4(1.0f), arg_2); } vec4 vertex_main() { @@ -21,9 +26,14 @@ void main() { #version 310 es precision mediump float; +vec4 tint_select(vec4 param_0, vec4 param_1, bvec4 param_2) { + return vec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + void select_43741e() { bvec4 arg_2 = bvec4(true); - vec4 res = mix(vec4(1.0f), vec4(1.0f), arg_2); + vec4 res = tint_select(vec4(1.0f), vec4(1.0f), arg_2); } void fragment_main() { @@ -36,9 +46,14 @@ void main() { } #version 310 es +vec4 tint_select(vec4 param_0, vec4 param_1, bvec4 param_2) { + return vec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + void select_43741e() { bvec4 arg_2 = bvec4(true); - vec4 res = mix(vec4(1.0f), vec4(1.0f), arg_2); + vec4 res = tint_select(vec4(1.0f), vec4(1.0f), arg_2); } void compute_main() { diff --git a/test/tint/builtins/gen/var/select/4c4738.wgsl.expected.glsl b/test/tint/builtins/gen/var/select/4c4738.wgsl.expected.glsl index 699889b3c6..88de1f6792 100644 --- a/test/tint/builtins/gen/var/select/4c4738.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/select/4c4738.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +ivec4 tint_select(ivec4 param_0, ivec4 param_1, bvec4 param_2) { + return ivec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + void select_4c4738() { bvec4 arg_2 = bvec4(true); - ivec4 res = mix(ivec4(1), ivec4(1), arg_2); + ivec4 res = tint_select(ivec4(1), ivec4(1), arg_2); } vec4 vertex_main() { @@ -21,9 +26,14 @@ void main() { #version 310 es precision mediump float; +ivec4 tint_select(ivec4 param_0, ivec4 param_1, bvec4 param_2) { + return ivec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + void select_4c4738() { bvec4 arg_2 = bvec4(true); - ivec4 res = mix(ivec4(1), ivec4(1), arg_2); + ivec4 res = tint_select(ivec4(1), ivec4(1), arg_2); } void fragment_main() { @@ -36,9 +46,14 @@ void main() { } #version 310 es +ivec4 tint_select(ivec4 param_0, ivec4 param_1, bvec4 param_2) { + return ivec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + void select_4c4738() { bvec4 arg_2 = bvec4(true); - ivec4 res = mix(ivec4(1), ivec4(1), arg_2); + ivec4 res = tint_select(ivec4(1), ivec4(1), arg_2); } void compute_main() { diff --git a/test/tint/builtins/gen/var/select/53d518.wgsl.expected.glsl b/test/tint/builtins/gen/var/select/53d518.wgsl.expected.glsl index a35f1ddca5..5d506412a1 100644 --- a/test/tint/builtins/gen/var/select/53d518.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/select/53d518.wgsl.expected.glsl @@ -1,6 +1,11 @@ #version 310 es #extension GL_AMD_gpu_shader_half_float : require +f16vec3 tint_select(f16vec3 param_0, f16vec3 param_1, bvec3 param_2) { + return f16vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { f16vec3 inner; } prevent_dce; @@ -9,7 +14,7 @@ void select_53d518() { f16vec3 arg_0 = f16vec3(1.0hf); f16vec3 arg_1 = f16vec3(1.0hf); bvec3 arg_2 = bvec3(true); - f16vec3 res = mix(arg_0, arg_1, arg_2); + f16vec3 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = res; } @@ -30,6 +35,11 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require precision mediump float; +f16vec3 tint_select(f16vec3 param_0, f16vec3 param_1, bvec3 param_2) { + return f16vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { f16vec3 inner; } prevent_dce; @@ -38,7 +48,7 @@ void select_53d518() { f16vec3 arg_0 = f16vec3(1.0hf); f16vec3 arg_1 = f16vec3(1.0hf); bvec3 arg_2 = bvec3(true); - f16vec3 res = mix(arg_0, arg_1, arg_2); + f16vec3 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = res; } @@ -53,6 +63,11 @@ void main() { #version 310 es #extension GL_AMD_gpu_shader_half_float : require +f16vec3 tint_select(f16vec3 param_0, f16vec3 param_1, bvec3 param_2) { + return f16vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { f16vec3 inner; } prevent_dce; @@ -61,7 +76,7 @@ void select_53d518() { f16vec3 arg_0 = f16vec3(1.0hf); f16vec3 arg_1 = f16vec3(1.0hf); bvec3 arg_2 = bvec3(true); - f16vec3 res = mix(arg_0, arg_1, arg_2); + f16vec3 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = res; } diff --git a/test/tint/builtins/gen/var/select/80a9a9.wgsl.expected.glsl b/test/tint/builtins/gen/var/select/80a9a9.wgsl.expected.glsl index ae911fe1e8..b6bce8ab8b 100644 --- a/test/tint/builtins/gen/var/select/80a9a9.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/select/80a9a9.wgsl.expected.glsl @@ -1,5 +1,10 @@ #version 310 es +bvec3 tint_select(bvec3 param_0, bvec3 param_1, bvec3 param_2) { + return bvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { int inner; } prevent_dce; @@ -8,7 +13,7 @@ void select_80a9a9() { bvec3 arg_0 = bvec3(true); bvec3 arg_1 = bvec3(true); bvec3 arg_2 = bvec3(true); - bvec3 res = mix(arg_0, arg_1, arg_2); + bvec3 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = (all(equal(res, bvec3(false))) ? 1 : 0); } @@ -28,6 +33,11 @@ void main() { #version 310 es precision mediump float; +bvec3 tint_select(bvec3 param_0, bvec3 param_1, bvec3 param_2) { + return bvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { int inner; } prevent_dce; @@ -36,7 +46,7 @@ void select_80a9a9() { bvec3 arg_0 = bvec3(true); bvec3 arg_1 = bvec3(true); bvec3 arg_2 = bvec3(true); - bvec3 res = mix(arg_0, arg_1, arg_2); + bvec3 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = (all(equal(res, bvec3(false))) ? 1 : 0); } @@ -50,6 +60,11 @@ void main() { } #version 310 es +bvec3 tint_select(bvec3 param_0, bvec3 param_1, bvec3 param_2) { + return bvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { int inner; } prevent_dce; @@ -58,7 +73,7 @@ void select_80a9a9() { bvec3 arg_0 = bvec3(true); bvec3 arg_1 = bvec3(true); bvec3 arg_2 = bvec3(true); - bvec3 res = mix(arg_0, arg_1, arg_2); + bvec3 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = (all(equal(res, bvec3(false))) ? 1 : 0); } diff --git a/test/tint/builtins/gen/var/select/a081f1.wgsl.expected.glsl b/test/tint/builtins/gen/var/select/a081f1.wgsl.expected.glsl index e3122b210b..be587c12fd 100644 --- a/test/tint/builtins/gen/var/select/a081f1.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/select/a081f1.wgsl.expected.glsl @@ -1,6 +1,11 @@ #version 310 es #extension GL_AMD_gpu_shader_half_float : require +f16vec4 tint_select(f16vec4 param_0, f16vec4 param_1, bvec4 param_2) { + return f16vec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { f16vec4 inner; } prevent_dce; @@ -9,7 +14,7 @@ void select_a081f1() { f16vec4 arg_0 = f16vec4(1.0hf); f16vec4 arg_1 = f16vec4(1.0hf); bvec4 arg_2 = bvec4(true); - f16vec4 res = mix(arg_0, arg_1, arg_2); + f16vec4 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = res; } @@ -30,6 +35,11 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require precision mediump float; +f16vec4 tint_select(f16vec4 param_0, f16vec4 param_1, bvec4 param_2) { + return f16vec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { f16vec4 inner; } prevent_dce; @@ -38,7 +48,7 @@ void select_a081f1() { f16vec4 arg_0 = f16vec4(1.0hf); f16vec4 arg_1 = f16vec4(1.0hf); bvec4 arg_2 = bvec4(true); - f16vec4 res = mix(arg_0, arg_1, arg_2); + f16vec4 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = res; } @@ -53,6 +63,11 @@ void main() { #version 310 es #extension GL_AMD_gpu_shader_half_float : require +f16vec4 tint_select(f16vec4 param_0, f16vec4 param_1, bvec4 param_2) { + return f16vec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { f16vec4 inner; } prevent_dce; @@ -61,7 +76,7 @@ void select_a081f1() { f16vec4 arg_0 = f16vec4(1.0hf); f16vec4 arg_1 = f16vec4(1.0hf); bvec4 arg_2 = bvec4(true); - f16vec4 res = mix(arg_0, arg_1, arg_2); + f16vec4 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = res; } diff --git a/test/tint/builtins/gen/var/select/a2860e.wgsl.expected.glsl b/test/tint/builtins/gen/var/select/a2860e.wgsl.expected.glsl index 7700faa941..f71683af7c 100644 --- a/test/tint/builtins/gen/var/select/a2860e.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/select/a2860e.wgsl.expected.glsl @@ -1,5 +1,10 @@ #version 310 es +ivec4 tint_select(ivec4 param_0, ivec4 param_1, bvec4 param_2) { + return ivec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { ivec4 inner; } prevent_dce; @@ -8,7 +13,7 @@ void select_a2860e() { ivec4 arg_0 = ivec4(1); ivec4 arg_1 = ivec4(1); bvec4 arg_2 = bvec4(true); - ivec4 res = mix(arg_0, arg_1, arg_2); + ivec4 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = res; } @@ -28,6 +33,11 @@ void main() { #version 310 es precision mediump float; +ivec4 tint_select(ivec4 param_0, ivec4 param_1, bvec4 param_2) { + return ivec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { ivec4 inner; } prevent_dce; @@ -36,7 +46,7 @@ void select_a2860e() { ivec4 arg_0 = ivec4(1); ivec4 arg_1 = ivec4(1); bvec4 arg_2 = bvec4(true); - ivec4 res = mix(arg_0, arg_1, arg_2); + ivec4 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = res; } @@ -50,6 +60,11 @@ void main() { } #version 310 es +ivec4 tint_select(ivec4 param_0, ivec4 param_1, bvec4 param_2) { + return ivec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { ivec4 inner; } prevent_dce; @@ -58,7 +73,7 @@ void select_a2860e() { ivec4 arg_0 = ivec4(1); ivec4 arg_1 = ivec4(1); bvec4 arg_2 = bvec4(true); - ivec4 res = mix(arg_0, arg_1, arg_2); + ivec4 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = res; } diff --git a/test/tint/builtins/gen/var/select/b93806.wgsl.expected.glsl b/test/tint/builtins/gen/var/select/b93806.wgsl.expected.glsl index a3b90cd560..e30745869a 100644 --- a/test/tint/builtins/gen/var/select/b93806.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/select/b93806.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +ivec3 tint_select(ivec3 param_0, ivec3 param_1, bvec3 param_2) { + return ivec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + void select_b93806() { bvec3 arg_2 = bvec3(true); - ivec3 res = mix(ivec3(1), ivec3(1), arg_2); + ivec3 res = tint_select(ivec3(1), ivec3(1), arg_2); } vec4 vertex_main() { @@ -21,9 +26,14 @@ void main() { #version 310 es precision mediump float; +ivec3 tint_select(ivec3 param_0, ivec3 param_1, bvec3 param_2) { + return ivec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + void select_b93806() { bvec3 arg_2 = bvec3(true); - ivec3 res = mix(ivec3(1), ivec3(1), arg_2); + ivec3 res = tint_select(ivec3(1), ivec3(1), arg_2); } void fragment_main() { @@ -36,9 +46,14 @@ void main() { } #version 310 es +ivec3 tint_select(ivec3 param_0, ivec3 param_1, bvec3 param_2) { + return ivec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + void select_b93806() { bvec3 arg_2 = bvec3(true); - ivec3 res = mix(ivec3(1), ivec3(1), arg_2); + ivec3 res = tint_select(ivec3(1), ivec3(1), arg_2); } void compute_main() { diff --git a/test/tint/builtins/gen/var/select/bb8aae.wgsl.expected.glsl b/test/tint/builtins/gen/var/select/bb8aae.wgsl.expected.glsl index fa4c216570..41dcfae704 100644 --- a/test/tint/builtins/gen/var/select/bb8aae.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/select/bb8aae.wgsl.expected.glsl @@ -1,5 +1,10 @@ #version 310 es +vec4 tint_select(vec4 param_0, vec4 param_1, bvec4 param_2) { + return vec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { vec4 inner; } prevent_dce; @@ -8,7 +13,7 @@ void select_bb8aae() { vec4 arg_0 = vec4(1.0f); vec4 arg_1 = vec4(1.0f); bvec4 arg_2 = bvec4(true); - vec4 res = mix(arg_0, arg_1, arg_2); + vec4 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = res; } @@ -28,6 +33,11 @@ void main() { #version 310 es precision mediump float; +vec4 tint_select(vec4 param_0, vec4 param_1, bvec4 param_2) { + return vec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { vec4 inner; } prevent_dce; @@ -36,7 +46,7 @@ void select_bb8aae() { vec4 arg_0 = vec4(1.0f); vec4 arg_1 = vec4(1.0f); bvec4 arg_2 = bvec4(true); - vec4 res = mix(arg_0, arg_1, arg_2); + vec4 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = res; } @@ -50,6 +60,11 @@ void main() { } #version 310 es +vec4 tint_select(vec4 param_0, vec4 param_1, bvec4 param_2) { + return vec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { vec4 inner; } prevent_dce; @@ -58,7 +73,7 @@ void select_bb8aae() { vec4 arg_0 = vec4(1.0f); vec4 arg_1 = vec4(1.0f); bvec4 arg_2 = bvec4(true); - vec4 res = mix(arg_0, arg_1, arg_2); + vec4 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = res; } diff --git a/test/tint/builtins/gen/var/select/c4a4ef.wgsl.expected.glsl b/test/tint/builtins/gen/var/select/c4a4ef.wgsl.expected.glsl index eea27e016b..34cd123525 100644 --- a/test/tint/builtins/gen/var/select/c4a4ef.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/select/c4a4ef.wgsl.expected.glsl @@ -1,5 +1,10 @@ #version 310 es +uvec4 tint_select(uvec4 param_0, uvec4 param_1, bvec4 param_2) { + return uvec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { uvec4 inner; } prevent_dce; @@ -8,7 +13,7 @@ void select_c4a4ef() { uvec4 arg_0 = uvec4(1u); uvec4 arg_1 = uvec4(1u); bvec4 arg_2 = bvec4(true); - uvec4 res = mix(arg_0, arg_1, arg_2); + uvec4 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = res; } @@ -28,6 +33,11 @@ void main() { #version 310 es precision mediump float; +uvec4 tint_select(uvec4 param_0, uvec4 param_1, bvec4 param_2) { + return uvec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { uvec4 inner; } prevent_dce; @@ -36,7 +46,7 @@ void select_c4a4ef() { uvec4 arg_0 = uvec4(1u); uvec4 arg_1 = uvec4(1u); bvec4 arg_2 = bvec4(true); - uvec4 res = mix(arg_0, arg_1, arg_2); + uvec4 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = res; } @@ -50,6 +60,11 @@ void main() { } #version 310 es +uvec4 tint_select(uvec4 param_0, uvec4 param_1, bvec4 param_2) { + return uvec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { uvec4 inner; } prevent_dce; @@ -58,7 +73,7 @@ void select_c4a4ef() { uvec4 arg_0 = uvec4(1u); uvec4 arg_1 = uvec4(1u); bvec4 arg_2 = bvec4(true); - uvec4 res = mix(arg_0, arg_1, arg_2); + uvec4 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = res; } diff --git a/test/tint/builtins/gen/var/select/cb9301.wgsl.expected.glsl b/test/tint/builtins/gen/var/select/cb9301.wgsl.expected.glsl index d8a9f13b77..27d8377af7 100644 --- a/test/tint/builtins/gen/var/select/cb9301.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/select/cb9301.wgsl.expected.glsl @@ -1,5 +1,10 @@ #version 310 es +bvec2 tint_select(bvec2 param_0, bvec2 param_1, bvec2 param_2) { + return bvec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { int inner; } prevent_dce; @@ -8,7 +13,7 @@ void select_cb9301() { bvec2 arg_0 = bvec2(true); bvec2 arg_1 = bvec2(true); bvec2 arg_2 = bvec2(true); - bvec2 res = mix(arg_0, arg_1, arg_2); + bvec2 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = (all(equal(res, bvec2(false))) ? 1 : 0); } @@ -28,6 +33,11 @@ void main() { #version 310 es precision mediump float; +bvec2 tint_select(bvec2 param_0, bvec2 param_1, bvec2 param_2) { + return bvec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { int inner; } prevent_dce; @@ -36,7 +46,7 @@ void select_cb9301() { bvec2 arg_0 = bvec2(true); bvec2 arg_1 = bvec2(true); bvec2 arg_2 = bvec2(true); - bvec2 res = mix(arg_0, arg_1, arg_2); + bvec2 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = (all(equal(res, bvec2(false))) ? 1 : 0); } @@ -50,6 +60,11 @@ void main() { } #version 310 es +bvec2 tint_select(bvec2 param_0, bvec2 param_1, bvec2 param_2) { + return bvec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { int inner; } prevent_dce; @@ -58,7 +73,7 @@ void select_cb9301() { bvec2 arg_0 = bvec2(true); bvec2 arg_1 = bvec2(true); bvec2 arg_2 = bvec2(true); - bvec2 res = mix(arg_0, arg_1, arg_2); + bvec2 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = (all(equal(res, bvec2(false))) ? 1 : 0); } diff --git a/test/tint/builtins/gen/var/select/e3e028.wgsl.expected.glsl b/test/tint/builtins/gen/var/select/e3e028.wgsl.expected.glsl index 8e52828908..38837aa846 100644 --- a/test/tint/builtins/gen/var/select/e3e028.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/select/e3e028.wgsl.expected.glsl @@ -1,5 +1,10 @@ #version 310 es +bvec4 tint_select(bvec4 param_0, bvec4 param_1, bvec4 param_2) { + return bvec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { int inner; } prevent_dce; @@ -8,7 +13,7 @@ void select_e3e028() { bvec4 arg_0 = bvec4(true); bvec4 arg_1 = bvec4(true); bvec4 arg_2 = bvec4(true); - bvec4 res = mix(arg_0, arg_1, arg_2); + bvec4 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = (all(equal(res, bvec4(false))) ? 1 : 0); } @@ -28,6 +33,11 @@ void main() { #version 310 es precision mediump float; +bvec4 tint_select(bvec4 param_0, bvec4 param_1, bvec4 param_2) { + return bvec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { int inner; } prevent_dce; @@ -36,7 +46,7 @@ void select_e3e028() { bvec4 arg_0 = bvec4(true); bvec4 arg_1 = bvec4(true); bvec4 arg_2 = bvec4(true); - bvec4 res = mix(arg_0, arg_1, arg_2); + bvec4 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = (all(equal(res, bvec4(false))) ? 1 : 0); } @@ -50,6 +60,11 @@ void main() { } #version 310 es +bvec4 tint_select(bvec4 param_0, bvec4 param_1, bvec4 param_2) { + return bvec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { int inner; } prevent_dce; @@ -58,7 +73,7 @@ void select_e3e028() { bvec4 arg_0 = bvec4(true); bvec4 arg_1 = bvec4(true); bvec4 arg_2 = bvec4(true); - bvec4 res = mix(arg_0, arg_1, arg_2); + bvec4 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = (all(equal(res, bvec4(false))) ? 1 : 0); } diff --git a/test/tint/builtins/gen/var/select/ebfea2.wgsl.expected.glsl b/test/tint/builtins/gen/var/select/ebfea2.wgsl.expected.glsl index 3b4a3fe197..94aa5690d1 100644 --- a/test/tint/builtins/gen/var/select/ebfea2.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/select/ebfea2.wgsl.expected.glsl @@ -1,5 +1,10 @@ #version 310 es +vec3 tint_select(vec3 param_0, vec3 param_1, bvec3 param_2) { + return vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { vec3 inner; } prevent_dce; @@ -8,7 +13,7 @@ void select_ebfea2() { vec3 arg_0 = vec3(1.0f); vec3 arg_1 = vec3(1.0f); bvec3 arg_2 = bvec3(true); - vec3 res = mix(arg_0, arg_1, arg_2); + vec3 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = res; } @@ -28,6 +33,11 @@ void main() { #version 310 es precision mediump float; +vec3 tint_select(vec3 param_0, vec3 param_1, bvec3 param_2) { + return vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { vec3 inner; } prevent_dce; @@ -36,7 +46,7 @@ void select_ebfea2() { vec3 arg_0 = vec3(1.0f); vec3 arg_1 = vec3(1.0f); bvec3 arg_2 = bvec3(true); - vec3 res = mix(arg_0, arg_1, arg_2); + vec3 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = res; } @@ -50,6 +60,11 @@ void main() { } #version 310 es +vec3 tint_select(vec3 param_0, vec3 param_1, bvec3 param_2) { + return vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { vec3 inner; } prevent_dce; @@ -58,7 +73,7 @@ void select_ebfea2() { vec3 arg_0 = vec3(1.0f); vec3 arg_1 = vec3(1.0f); bvec3 arg_2 = bvec3(true); - vec3 res = mix(arg_0, arg_1, arg_2); + vec3 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = res; } diff --git a/test/tint/builtins/gen/var/select/ed7c13.wgsl.expected.glsl b/test/tint/builtins/gen/var/select/ed7c13.wgsl.expected.glsl index a63a36e96f..0d186fb045 100644 --- a/test/tint/builtins/gen/var/select/ed7c13.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/select/ed7c13.wgsl.expected.glsl @@ -1,6 +1,11 @@ #version 310 es #extension GL_AMD_gpu_shader_half_float : require +f16vec2 tint_select(f16vec2 param_0, f16vec2 param_1, bvec2 param_2) { + return f16vec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { f16vec2 inner; } prevent_dce; @@ -9,7 +14,7 @@ void select_ed7c13() { f16vec2 arg_0 = f16vec2(1.0hf); f16vec2 arg_1 = f16vec2(1.0hf); bvec2 arg_2 = bvec2(true); - f16vec2 res = mix(arg_0, arg_1, arg_2); + f16vec2 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = res; } @@ -30,6 +35,11 @@ void main() { #extension GL_AMD_gpu_shader_half_float : require precision mediump float; +f16vec2 tint_select(f16vec2 param_0, f16vec2 param_1, bvec2 param_2) { + return f16vec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { f16vec2 inner; } prevent_dce; @@ -38,7 +48,7 @@ void select_ed7c13() { f16vec2 arg_0 = f16vec2(1.0hf); f16vec2 arg_1 = f16vec2(1.0hf); bvec2 arg_2 = bvec2(true); - f16vec2 res = mix(arg_0, arg_1, arg_2); + f16vec2 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = res; } @@ -53,6 +63,11 @@ void main() { #version 310 es #extension GL_AMD_gpu_shader_half_float : require +f16vec2 tint_select(f16vec2 param_0, f16vec2 param_1, bvec2 param_2) { + return f16vec2(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1]); +} + + layout(binding = 0, std430) buffer prevent_dce_block_ssbo { f16vec2 inner; } prevent_dce; @@ -61,7 +76,7 @@ void select_ed7c13() { f16vec2 arg_0 = f16vec2(1.0hf); f16vec2 arg_1 = f16vec2(1.0hf); bvec2 arg_2 = bvec2(true); - f16vec2 res = mix(arg_0, arg_1, arg_2); + f16vec2 res = tint_select(arg_0, arg_1, arg_2); prevent_dce.inner = res; } diff --git a/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.glsl b/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.glsl index fc212c8021..8f1e2bfbc6 100644 --- a/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.glsl @@ -1,5 +1,10 @@ #version 310 es +vec3 tint_select(vec3 param_0, vec3 param_1, bvec3 param_2) { + return vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + struct GammaTransferParams { float G; float A; @@ -49,7 +54,7 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { bvec3 cond = lessThan(abs(v), vec3(params.D)); vec3 t = (sign(v) * ((params.C * abs(v)) + params.F)); vec3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3(params.G)) + params.E)); - return mix(f, t, cond); + return tint_select(f, t, cond); } vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, uvec2 coord, ExternalTextureParams params) { @@ -100,6 +105,11 @@ void main() { #version 310 es precision mediump float; +vec3 tint_select(vec3 param_0, vec3 param_1, bvec3 param_2) { + return vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + struct GammaTransferParams { float G; float A; @@ -149,7 +159,7 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { bvec3 cond = lessThan(abs(v), vec3(params.D)); vec3 t = (sign(v) * ((params.C * abs(v)) + params.F)); vec3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3(params.G)) + params.E)); - return mix(f, t, cond); + return tint_select(f, t, cond); } vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, uvec2 coord, ExternalTextureParams params) { @@ -194,6 +204,11 @@ void main() { } #version 310 es +vec3 tint_select(vec3 param_0, vec3 param_1, bvec3 param_2) { + return vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + struct GammaTransferParams { float G; float A; @@ -243,7 +258,7 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { bvec3 cond = lessThan(abs(v), vec3(params.D)); vec3 t = (sign(v) * ((params.C * abs(v)) + params.F)); vec3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3(params.G)) + params.E)); - return mix(f, t, cond); + return tint_select(f, t, cond); } vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, uvec2 coord, ExternalTextureParams params) { diff --git a/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.glsl b/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.glsl index 41ee7e5f64..71e9f395f7 100644 --- a/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.glsl @@ -1,5 +1,10 @@ #version 310 es +vec3 tint_select(vec3 param_0, vec3 param_1, bvec3 param_2) { + return vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + struct GammaTransferParams { float G; float A; @@ -49,7 +54,7 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { bvec3 cond = lessThan(abs(v), vec3(params.D)); vec3 t = (sign(v) * ((params.C * abs(v)) + params.F)); vec3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3(params.G)) + params.E)); - return mix(f, t, cond); + return tint_select(f, t, cond); } vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, ivec2 coord, ExternalTextureParams params) { @@ -100,6 +105,11 @@ void main() { #version 310 es precision mediump float; +vec3 tint_select(vec3 param_0, vec3 param_1, bvec3 param_2) { + return vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + struct GammaTransferParams { float G; float A; @@ -149,7 +159,7 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { bvec3 cond = lessThan(abs(v), vec3(params.D)); vec3 t = (sign(v) * ((params.C * abs(v)) + params.F)); vec3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3(params.G)) + params.E)); - return mix(f, t, cond); + return tint_select(f, t, cond); } vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, ivec2 coord, ExternalTextureParams params) { @@ -194,6 +204,11 @@ void main() { } #version 310 es +vec3 tint_select(vec3 param_0, vec3 param_1, bvec3 param_2) { + return vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + struct GammaTransferParams { float G; float A; @@ -243,7 +258,7 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { bvec3 cond = lessThan(abs(v), vec3(params.D)); vec3 t = (sign(v) * ((params.C * abs(v)) + params.F)); vec3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3(params.G)) + params.E)); - return mix(f, t, cond); + return tint_select(f, t, cond); } vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, ivec2 coord, ExternalTextureParams params) { diff --git a/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.glsl b/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.glsl index 6b17300044..cf69f935f7 100644 --- a/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.glsl @@ -1,5 +1,10 @@ #version 310 es +vec3 tint_select(vec3 param_0, vec3 param_1, bvec3 param_2) { + return vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + struct GammaTransferParams { float G; float A; @@ -49,7 +54,7 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { bvec3 cond = lessThan(abs(v), vec3(params.D)); vec3 t = (sign(v) * ((params.C * abs(v)) + params.F)); vec3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3(params.G)) + params.E)); - return mix(f, t, cond); + return tint_select(f, t, cond); } @@ -109,6 +114,11 @@ void main() { #version 310 es precision mediump float; +vec3 tint_select(vec3 param_0, vec3 param_1, bvec3 param_2) { + return vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + struct GammaTransferParams { float G; float A; @@ -158,7 +168,7 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { bvec3 cond = lessThan(abs(v), vec3(params.D)); vec3 t = (sign(v) * ((params.C * abs(v)) + params.F)); vec3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3(params.G)) + params.E)); - return mix(f, t, cond); + return tint_select(f, t, cond); } @@ -212,6 +222,11 @@ void main() { } #version 310 es +vec3 tint_select(vec3 param_0, vec3 param_1, bvec3 param_2) { + return vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + struct GammaTransferParams { float G; float A; @@ -261,7 +276,7 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { bvec3 cond = lessThan(abs(v), vec3(params.D)); vec3 t = (sign(v) * ((params.C * abs(v)) + params.F)); vec3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3(params.G)) + params.E)); - return mix(f, t, cond); + return tint_select(f, t, cond); } diff --git a/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.glsl b/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.glsl index 02da464d17..05f150c412 100644 --- a/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.glsl +++ b/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.glsl @@ -1,5 +1,10 @@ #version 310 es +vec3 tint_select(vec3 param_0, vec3 param_1, bvec3 param_2) { + return vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + struct GammaTransferParams { float G; float A; @@ -49,7 +54,7 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { bvec3 cond = lessThan(abs(v), vec3(params.D)); vec3 t = (sign(v) * ((params.C * abs(v)) + params.F)); vec3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3(params.G)) + params.E)); - return mix(f, t, cond); + return tint_select(f, t, cond); } vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, ivec2 coord, ExternalTextureParams params) { @@ -98,6 +103,11 @@ void main() { #version 310 es precision mediump float; +vec3 tint_select(vec3 param_0, vec3 param_1, bvec3 param_2) { + return vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + struct GammaTransferParams { float G; float A; @@ -147,7 +157,7 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { bvec3 cond = lessThan(abs(v), vec3(params.D)); vec3 t = (sign(v) * ((params.C * abs(v)) + params.F)); vec3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3(params.G)) + params.E)); - return mix(f, t, cond); + return tint_select(f, t, cond); } vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, ivec2 coord, ExternalTextureParams params) { @@ -190,6 +200,11 @@ void main() { } #version 310 es +vec3 tint_select(vec3 param_0, vec3 param_1, bvec3 param_2) { + return vec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + struct GammaTransferParams { float G; float A; @@ -239,7 +254,7 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { bvec3 cond = lessThan(abs(v), vec3(params.D)); vec3 t = (sign(v) * ((params.C * abs(v)) + params.F)); vec3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3(params.G)) + params.E)); - return mix(f, t, cond); + return tint_select(f, t, cond); } vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, ivec2 coord, ExternalTextureParams params) { diff --git a/test/tint/expressions/binary/div/scalar-vec3/i32.wgsl.expected.glsl b/test/tint/expressions/binary/div/scalar-vec3/i32.wgsl.expected.glsl index a136f22f51..4f71f45926 100644 --- a/test/tint/expressions/binary/div/scalar-vec3/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/div/scalar-vec3/i32.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +ivec3 tint_select(ivec3 param_0, ivec3 param_1, bvec3 param_2) { + return ivec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + 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((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1)))))))); + return (l / tint_select(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(l, ivec3((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1)))))))); } void f() { diff --git a/test/tint/expressions/binary/div/scalar-vec3/u32.wgsl.expected.glsl b/test/tint/expressions/binary/div/scalar-vec3/u32.wgsl.expected.glsl index 39dc7a7544..c43c106314 100644 --- a/test/tint/expressions/binary/div/scalar-vec3/u32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/div/scalar-vec3/u32.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + uvec3 tint_div(uint lhs, uvec3 rhs) { uvec3 l = uvec3(lhs); - return (l / mix(rhs, uvec3(1u), equal(rhs, uvec3(0u)))); + return (l / tint_select(rhs, uvec3(1u), equal(rhs, uvec3(0u)))); } void f() { diff --git a/test/tint/expressions/binary/div/vec3-scalar/i32.wgsl.expected.glsl b/test/tint/expressions/binary/div/vec3-scalar/i32.wgsl.expected.glsl index d2b60b8a45..4e3c8d5e63 100644 --- a/test/tint/expressions/binary/div/vec3-scalar/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/div/vec3-scalar/i32.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +ivec3 tint_select(ivec3 param_0, ivec3 param_1, bvec3 param_2) { + return ivec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + 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((-2147483647 - 1)))) & uvec3(equal(r, ivec3(-1)))))))); + return (lhs / tint_select(r, ivec3(1), bvec3(uvec3(equal(r, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3((-2147483647 - 1)))) & uvec3(equal(r, ivec3(-1)))))))); } void f() { diff --git a/test/tint/expressions/binary/div/vec3-scalar/u32.wgsl.expected.glsl b/test/tint/expressions/binary/div/vec3-scalar/u32.wgsl.expected.glsl index a64873331b..7b0456182d 100644 --- a/test/tint/expressions/binary/div/vec3-scalar/u32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/div/vec3-scalar/u32.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + uvec3 tint_div(uvec3 lhs, uint rhs) { uvec3 r = uvec3(rhs); - return (lhs / mix(r, uvec3(1u), equal(r, uvec3(0u)))); + return (lhs / tint_select(r, uvec3(1u), equal(r, uvec3(0u)))); } void f() { diff --git a/test/tint/expressions/binary/div/vec3-vec3/i32.wgsl.expected.glsl b/test/tint/expressions/binary/div/vec3-vec3/i32.wgsl.expected.glsl index ce3f657fa2..dc0f3962dd 100644 --- a/test/tint/expressions/binary/div/vec3-vec3/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/div/vec3-vec3/i32.wgsl.expected.glsl @@ -1,7 +1,12 @@ #version 310 es +ivec3 tint_select(ivec3 param_0, ivec3 param_1, bvec3 param_2) { + return ivec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + 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((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1)))))))); + return (lhs / tint_select(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1)))))))); } void f() { diff --git a/test/tint/expressions/binary/div/vec3-vec3/u32.wgsl.expected.glsl b/test/tint/expressions/binary/div/vec3-vec3/u32.wgsl.expected.glsl index 8320c3fe11..c95548928f 100644 --- a/test/tint/expressions/binary/div/vec3-vec3/u32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/div/vec3-vec3/u32.wgsl.expected.glsl @@ -1,7 +1,12 @@ #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + uvec3 tint_div(uvec3 lhs, uvec3 rhs) { - return (lhs / mix(rhs, uvec3(1u), equal(rhs, uvec3(0u)))); + return (lhs / tint_select(rhs, uvec3(1u), equal(rhs, uvec3(0u)))); } void f() { diff --git a/test/tint/expressions/binary/div_by_zero/by_constant/scalar-vec3/i32.wgsl.expected.glsl b/test/tint/expressions/binary/div_by_zero/by_constant/scalar-vec3/i32.wgsl.expected.glsl index cd04914329..389f1896e7 100644 --- a/test/tint/expressions/binary/div_by_zero/by_constant/scalar-vec3/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/div_by_zero/by_constant/scalar-vec3/i32.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +ivec3 tint_select(ivec3 param_0, ivec3 param_1, bvec3 param_2) { + return ivec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + 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((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1)))))))); + return (l / tint_select(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(l, ivec3((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1)))))))); } void f() { diff --git a/test/tint/expressions/binary/div_by_zero/by_constant/scalar-vec3/u32.wgsl.expected.glsl b/test/tint/expressions/binary/div_by_zero/by_constant/scalar-vec3/u32.wgsl.expected.glsl index 50ab5b37dd..b9caa1568e 100644 --- a/test/tint/expressions/binary/div_by_zero/by_constant/scalar-vec3/u32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/div_by_zero/by_constant/scalar-vec3/u32.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + uvec3 tint_div(uint lhs, uvec3 rhs) { uvec3 l = uvec3(lhs); - return (l / mix(rhs, uvec3(1u), equal(rhs, uvec3(0u)))); + return (l / tint_select(rhs, uvec3(1u), equal(rhs, uvec3(0u)))); } void f() { diff --git a/test/tint/expressions/binary/div_by_zero/by_constant/vec3-scalar/i32.wgsl.expected.glsl b/test/tint/expressions/binary/div_by_zero/by_constant/vec3-scalar/i32.wgsl.expected.glsl index 4afe9491fa..e4741ab0d2 100644 --- a/test/tint/expressions/binary/div_by_zero/by_constant/vec3-scalar/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/div_by_zero/by_constant/vec3-scalar/i32.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +ivec3 tint_select(ivec3 param_0, ivec3 param_1, bvec3 param_2) { + return ivec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + 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((-2147483647 - 1)))) & uvec3(equal(r, ivec3(-1)))))))); + return (lhs / tint_select(r, ivec3(1), bvec3(uvec3(equal(r, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3((-2147483647 - 1)))) & uvec3(equal(r, ivec3(-1)))))))); } void f() { diff --git a/test/tint/expressions/binary/div_by_zero/by_constant/vec3-scalar/u32.wgsl.expected.glsl b/test/tint/expressions/binary/div_by_zero/by_constant/vec3-scalar/u32.wgsl.expected.glsl index 926d784dc7..3242245e49 100644 --- a/test/tint/expressions/binary/div_by_zero/by_constant/vec3-scalar/u32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/div_by_zero/by_constant/vec3-scalar/u32.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + uvec3 tint_div(uvec3 lhs, uint rhs) { uvec3 r = uvec3(rhs); - return (lhs / mix(r, uvec3(1u), equal(r, uvec3(0u)))); + return (lhs / tint_select(r, uvec3(1u), equal(r, uvec3(0u)))); } void f() { diff --git a/test/tint/expressions/binary/div_by_zero/by_constant/vec3-vec3/i32.wgsl.expected.glsl b/test/tint/expressions/binary/div_by_zero/by_constant/vec3-vec3/i32.wgsl.expected.glsl index 1e3782678e..63d26f1396 100644 --- a/test/tint/expressions/binary/div_by_zero/by_constant/vec3-vec3/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/div_by_zero/by_constant/vec3-vec3/i32.wgsl.expected.glsl @@ -1,7 +1,12 @@ #version 310 es +ivec3 tint_select(ivec3 param_0, ivec3 param_1, bvec3 param_2) { + return ivec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + 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((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1)))))))); + return (lhs / tint_select(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1)))))))); } void f() { diff --git a/test/tint/expressions/binary/div_by_zero/by_constant/vec3-vec3/u32.wgsl.expected.glsl b/test/tint/expressions/binary/div_by_zero/by_constant/vec3-vec3/u32.wgsl.expected.glsl index 000bf89fc4..4390696de5 100644 --- a/test/tint/expressions/binary/div_by_zero/by_constant/vec3-vec3/u32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/div_by_zero/by_constant/vec3-vec3/u32.wgsl.expected.glsl @@ -1,7 +1,12 @@ #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + uvec3 tint_div(uvec3 lhs, uvec3 rhs) { - return (lhs / mix(rhs, uvec3(1u), equal(rhs, uvec3(0u)))); + return (lhs / tint_select(rhs, uvec3(1u), equal(rhs, uvec3(0u)))); } void f() { diff --git a/test/tint/expressions/binary/div_by_zero/by_expression/scalar-vec3/i32.wgsl.expected.glsl b/test/tint/expressions/binary/div_by_zero/by_expression/scalar-vec3/i32.wgsl.expected.glsl index 54021cdcb4..c77f6f4a78 100644 --- a/test/tint/expressions/binary/div_by_zero/by_expression/scalar-vec3/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/div_by_zero/by_expression/scalar-vec3/i32.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +ivec3 tint_select(ivec3 param_0, ivec3 param_1, bvec3 param_2) { + return ivec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + 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((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1)))))))); + return (l / tint_select(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(l, ivec3((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1)))))))); } void f() { diff --git a/test/tint/expressions/binary/div_by_zero/by_expression/scalar-vec3/u32.wgsl.expected.glsl b/test/tint/expressions/binary/div_by_zero/by_expression/scalar-vec3/u32.wgsl.expected.glsl index 187744bce9..22f1020b6e 100644 --- a/test/tint/expressions/binary/div_by_zero/by_expression/scalar-vec3/u32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/div_by_zero/by_expression/scalar-vec3/u32.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + uvec3 tint_div(uint lhs, uvec3 rhs) { uvec3 l = uvec3(lhs); - return (l / mix(rhs, uvec3(1u), equal(rhs, uvec3(0u)))); + return (l / tint_select(rhs, uvec3(1u), equal(rhs, uvec3(0u)))); } void f() { diff --git a/test/tint/expressions/binary/div_by_zero/by_expression/vec3-scalar/i32.wgsl.expected.glsl b/test/tint/expressions/binary/div_by_zero/by_expression/vec3-scalar/i32.wgsl.expected.glsl index de877e277f..cb852648ce 100644 --- a/test/tint/expressions/binary/div_by_zero/by_expression/vec3-scalar/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/div_by_zero/by_expression/vec3-scalar/i32.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +ivec3 tint_select(ivec3 param_0, ivec3 param_1, bvec3 param_2) { + return ivec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + 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((-2147483647 - 1)))) & uvec3(equal(r, ivec3(-1)))))))); + return (lhs / tint_select(r, ivec3(1), bvec3(uvec3(equal(r, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3((-2147483647 - 1)))) & uvec3(equal(r, ivec3(-1)))))))); } void f() { diff --git a/test/tint/expressions/binary/div_by_zero/by_expression/vec3-scalar/u32.wgsl.expected.glsl b/test/tint/expressions/binary/div_by_zero/by_expression/vec3-scalar/u32.wgsl.expected.glsl index 4f7e3f3a81..b54020f4aa 100644 --- a/test/tint/expressions/binary/div_by_zero/by_expression/vec3-scalar/u32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/div_by_zero/by_expression/vec3-scalar/u32.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + uvec3 tint_div(uvec3 lhs, uint rhs) { uvec3 r = uvec3(rhs); - return (lhs / mix(r, uvec3(1u), equal(r, uvec3(0u)))); + return (lhs / tint_select(r, uvec3(1u), equal(r, uvec3(0u)))); } void f() { diff --git a/test/tint/expressions/binary/div_by_zero/by_expression/vec3-vec3/i32.wgsl.expected.glsl b/test/tint/expressions/binary/div_by_zero/by_expression/vec3-vec3/i32.wgsl.expected.glsl index d6cb57eed5..105f8f4c2a 100644 --- a/test/tint/expressions/binary/div_by_zero/by_expression/vec3-vec3/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/div_by_zero/by_expression/vec3-vec3/i32.wgsl.expected.glsl @@ -1,7 +1,12 @@ #version 310 es +ivec3 tint_select(ivec3 param_0, ivec3 param_1, bvec3 param_2) { + return ivec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + 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((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1)))))))); + return (lhs / tint_select(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1)))))))); } void f() { diff --git a/test/tint/expressions/binary/div_by_zero/by_expression/vec3-vec3/u32.wgsl.expected.glsl b/test/tint/expressions/binary/div_by_zero/by_expression/vec3-vec3/u32.wgsl.expected.glsl index 22846e65bd..7485252226 100644 --- a/test/tint/expressions/binary/div_by_zero/by_expression/vec3-vec3/u32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/div_by_zero/by_expression/vec3-vec3/u32.wgsl.expected.glsl @@ -1,7 +1,12 @@ #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + uvec3 tint_div(uvec3 lhs, uvec3 rhs) { - return (lhs / mix(rhs, uvec3(1u), equal(rhs, uvec3(0u)))); + return (lhs / tint_select(rhs, uvec3(1u), equal(rhs, uvec3(0u)))); } void f() { diff --git a/test/tint/expressions/binary/div_by_zero/by_identifier/scalar-vec3/i32.wgsl.expected.glsl b/test/tint/expressions/binary/div_by_zero/by_identifier/scalar-vec3/i32.wgsl.expected.glsl index cd04914329..389f1896e7 100644 --- a/test/tint/expressions/binary/div_by_zero/by_identifier/scalar-vec3/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/div_by_zero/by_identifier/scalar-vec3/i32.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +ivec3 tint_select(ivec3 param_0, ivec3 param_1, bvec3 param_2) { + return ivec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + 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((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1)))))))); + return (l / tint_select(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(l, ivec3((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1)))))))); } void f() { diff --git a/test/tint/expressions/binary/div_by_zero/by_identifier/scalar-vec3/u32.wgsl.expected.glsl b/test/tint/expressions/binary/div_by_zero/by_identifier/scalar-vec3/u32.wgsl.expected.glsl index 50ab5b37dd..b9caa1568e 100644 --- a/test/tint/expressions/binary/div_by_zero/by_identifier/scalar-vec3/u32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/div_by_zero/by_identifier/scalar-vec3/u32.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + uvec3 tint_div(uint lhs, uvec3 rhs) { uvec3 l = uvec3(lhs); - return (l / mix(rhs, uvec3(1u), equal(rhs, uvec3(0u)))); + return (l / tint_select(rhs, uvec3(1u), equal(rhs, uvec3(0u)))); } void f() { diff --git a/test/tint/expressions/binary/div_by_zero/by_identifier/vec3-scalar/i32.wgsl.expected.glsl b/test/tint/expressions/binary/div_by_zero/by_identifier/vec3-scalar/i32.wgsl.expected.glsl index 4afe9491fa..e4741ab0d2 100644 --- a/test/tint/expressions/binary/div_by_zero/by_identifier/vec3-scalar/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/div_by_zero/by_identifier/vec3-scalar/i32.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +ivec3 tint_select(ivec3 param_0, ivec3 param_1, bvec3 param_2) { + return ivec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + 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((-2147483647 - 1)))) & uvec3(equal(r, ivec3(-1)))))))); + return (lhs / tint_select(r, ivec3(1), bvec3(uvec3(equal(r, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3((-2147483647 - 1)))) & uvec3(equal(r, ivec3(-1)))))))); } void f() { diff --git a/test/tint/expressions/binary/div_by_zero/by_identifier/vec3-scalar/u32.wgsl.expected.glsl b/test/tint/expressions/binary/div_by_zero/by_identifier/vec3-scalar/u32.wgsl.expected.glsl index 926d784dc7..3242245e49 100644 --- a/test/tint/expressions/binary/div_by_zero/by_identifier/vec3-scalar/u32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/div_by_zero/by_identifier/vec3-scalar/u32.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + uvec3 tint_div(uvec3 lhs, uint rhs) { uvec3 r = uvec3(rhs); - return (lhs / mix(r, uvec3(1u), equal(r, uvec3(0u)))); + return (lhs / tint_select(r, uvec3(1u), equal(r, uvec3(0u)))); } void f() { diff --git a/test/tint/expressions/binary/div_by_zero/by_identifier/vec3-vec3/i32.wgsl.expected.glsl b/test/tint/expressions/binary/div_by_zero/by_identifier/vec3-vec3/i32.wgsl.expected.glsl index 1e3782678e..63d26f1396 100644 --- a/test/tint/expressions/binary/div_by_zero/by_identifier/vec3-vec3/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/div_by_zero/by_identifier/vec3-vec3/i32.wgsl.expected.glsl @@ -1,7 +1,12 @@ #version 310 es +ivec3 tint_select(ivec3 param_0, ivec3 param_1, bvec3 param_2) { + return ivec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + 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((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1)))))))); + return (lhs / tint_select(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1)))))))); } void f() { diff --git a/test/tint/expressions/binary/div_by_zero/by_identifier/vec3-vec3/u32.wgsl.expected.glsl b/test/tint/expressions/binary/div_by_zero/by_identifier/vec3-vec3/u32.wgsl.expected.glsl index 000bf89fc4..4390696de5 100644 --- a/test/tint/expressions/binary/div_by_zero/by_identifier/vec3-vec3/u32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/div_by_zero/by_identifier/vec3-vec3/u32.wgsl.expected.glsl @@ -1,7 +1,12 @@ #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + uvec3 tint_div(uvec3 lhs, uvec3 rhs) { - return (lhs / mix(rhs, uvec3(1u), equal(rhs, uvec3(0u)))); + return (lhs / tint_select(rhs, uvec3(1u), equal(rhs, uvec3(0u)))); } void f() { diff --git a/test/tint/expressions/binary/mod/scalar-vec3/i32.wgsl.expected.glsl b/test/tint/expressions/binary/mod/scalar-vec3/i32.wgsl.expected.glsl index 28b2b1c4bc..2745da5432 100644 --- a/test/tint/expressions/binary/mod/scalar-vec3/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod/scalar-vec3/i32.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +ivec3 tint_select(ivec3 param_0, ivec3 param_1, bvec3 param_2) { + return ivec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + 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((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1))))))); + ivec3 rhs_or_one = tint_select(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 { diff --git a/test/tint/expressions/binary/mod/scalar-vec3/u32.wgsl.expected.glsl b/test/tint/expressions/binary/mod/scalar-vec3/u32.wgsl.expected.glsl index f8540889b5..ca3eb405ff 100644 --- a/test/tint/expressions/binary/mod/scalar-vec3/u32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod/scalar-vec3/u32.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + uvec3 tint_mod(uint lhs, uvec3 rhs) { uvec3 l = uvec3(lhs); - return (l % mix(rhs, uvec3(1u), equal(rhs, uvec3(0u)))); + return (l % tint_select(rhs, uvec3(1u), equal(rhs, uvec3(0u)))); } void f() { diff --git a/test/tint/expressions/binary/mod/vec3-scalar/i32.wgsl.expected.glsl b/test/tint/expressions/binary/mod/vec3-scalar/i32.wgsl.expected.glsl index 1178af2d36..20ac1092d4 100644 --- a/test/tint/expressions/binary/mod/vec3-scalar/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod/vec3-scalar/i32.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +ivec3 tint_select(ivec3 param_0, ivec3 param_1, bvec3 param_2) { + return ivec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + 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((-2147483647 - 1)))) & uvec3(equal(r, ivec3(-1))))))); + ivec3 rhs_or_one = tint_select(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 { diff --git a/test/tint/expressions/binary/mod/vec3-scalar/u32.wgsl.expected.glsl b/test/tint/expressions/binary/mod/vec3-scalar/u32.wgsl.expected.glsl index f7513275d1..f722a77edf 100644 --- a/test/tint/expressions/binary/mod/vec3-scalar/u32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod/vec3-scalar/u32.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + uvec3 tint_mod(uvec3 lhs, uint rhs) { uvec3 r = uvec3(rhs); - return (lhs % mix(r, uvec3(1u), equal(r, uvec3(0u)))); + return (lhs % tint_select(r, uvec3(1u), equal(r, uvec3(0u)))); } void f() { diff --git a/test/tint/expressions/binary/mod/vec3-vec3/i32.wgsl.expected.glsl b/test/tint/expressions/binary/mod/vec3-vec3/i32.wgsl.expected.glsl index f1c30a0d3b..1cf4c8e9f8 100644 --- a/test/tint/expressions/binary/mod/vec3-vec3/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod/vec3-vec3/i32.wgsl.expected.glsl @@ -1,7 +1,12 @@ #version 310 es +ivec3 tint_select(ivec3 param_0, ivec3 param_1, bvec3 param_2) { + return ivec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + 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((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1))))))); + ivec3 rhs_or_one = tint_select(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 { diff --git a/test/tint/expressions/binary/mod/vec3-vec3/u32.wgsl.expected.glsl b/test/tint/expressions/binary/mod/vec3-vec3/u32.wgsl.expected.glsl index 78f38034c1..2449b84a86 100644 --- a/test/tint/expressions/binary/mod/vec3-vec3/u32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod/vec3-vec3/u32.wgsl.expected.glsl @@ -1,7 +1,12 @@ #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + uvec3 tint_mod(uvec3 lhs, uvec3 rhs) { - return (lhs % mix(rhs, uvec3(1u), equal(rhs, uvec3(0u)))); + return (lhs % tint_select(rhs, uvec3(1u), equal(rhs, uvec3(0u)))); } void f() { diff --git a/test/tint/expressions/binary/mod_by_zero/by_constant/scalar-vec3/i32.wgsl.expected.glsl b/test/tint/expressions/binary/mod_by_zero/by_constant/scalar-vec3/i32.wgsl.expected.glsl index ef41fb8c54..cdbec37b09 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_constant/scalar-vec3/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod_by_zero/by_constant/scalar-vec3/i32.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +ivec3 tint_select(ivec3 param_0, ivec3 param_1, bvec3 param_2) { + return ivec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + 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((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1))))))); + ivec3 rhs_or_one = tint_select(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 { diff --git a/test/tint/expressions/binary/mod_by_zero/by_constant/scalar-vec3/u32.wgsl.expected.glsl b/test/tint/expressions/binary/mod_by_zero/by_constant/scalar-vec3/u32.wgsl.expected.glsl index 534cab7017..2b82a7771f 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_constant/scalar-vec3/u32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod_by_zero/by_constant/scalar-vec3/u32.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + uvec3 tint_mod(uint lhs, uvec3 rhs) { uvec3 l = uvec3(lhs); - return (l % mix(rhs, uvec3(1u), equal(rhs, uvec3(0u)))); + return (l % tint_select(rhs, uvec3(1u), equal(rhs, uvec3(0u)))); } void f() { diff --git a/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-scalar/i32.wgsl.expected.glsl b/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-scalar/i32.wgsl.expected.glsl index b1ddb82a12..8d45e86e40 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-scalar/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-scalar/i32.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +ivec3 tint_select(ivec3 param_0, ivec3 param_1, bvec3 param_2) { + return ivec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + 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((-2147483647 - 1)))) & uvec3(equal(r, ivec3(-1))))))); + ivec3 rhs_or_one = tint_select(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 { diff --git a/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-scalar/u32.wgsl.expected.glsl b/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-scalar/u32.wgsl.expected.glsl index 03f7867de4..82feba025f 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-scalar/u32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-scalar/u32.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + uvec3 tint_mod(uvec3 lhs, uint rhs) { uvec3 r = uvec3(rhs); - return (lhs % mix(r, uvec3(1u), equal(r, uvec3(0u)))); + return (lhs % tint_select(r, uvec3(1u), equal(r, uvec3(0u)))); } void f() { diff --git a/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-vec3/i32.wgsl.expected.glsl b/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-vec3/i32.wgsl.expected.glsl index fcb2b3731d..b117147e93 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-vec3/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-vec3/i32.wgsl.expected.glsl @@ -1,7 +1,12 @@ #version 310 es +ivec3 tint_select(ivec3 param_0, ivec3 param_1, bvec3 param_2) { + return ivec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + 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((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1))))))); + ivec3 rhs_or_one = tint_select(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 { diff --git a/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-vec3/u32.wgsl.expected.glsl b/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-vec3/u32.wgsl.expected.glsl index e6cd33b337..361f7c2e19 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-vec3/u32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-vec3/u32.wgsl.expected.glsl @@ -1,7 +1,12 @@ #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + uvec3 tint_mod(uvec3 lhs, uvec3 rhs) { - return (lhs % mix(rhs, uvec3(1u), equal(rhs, uvec3(0u)))); + return (lhs % tint_select(rhs, uvec3(1u), equal(rhs, uvec3(0u)))); } void f() { diff --git a/test/tint/expressions/binary/mod_by_zero/by_expression/scalar-vec3/i32.wgsl.expected.glsl b/test/tint/expressions/binary/mod_by_zero/by_expression/scalar-vec3/i32.wgsl.expected.glsl index b11b632cd7..255527a4f5 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_expression/scalar-vec3/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod_by_zero/by_expression/scalar-vec3/i32.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +ivec3 tint_select(ivec3 param_0, ivec3 param_1, bvec3 param_2) { + return ivec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + 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((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1))))))); + ivec3 rhs_or_one = tint_select(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 { diff --git a/test/tint/expressions/binary/mod_by_zero/by_expression/scalar-vec3/u32.wgsl.expected.glsl b/test/tint/expressions/binary/mod_by_zero/by_expression/scalar-vec3/u32.wgsl.expected.glsl index 47e9d7e393..939452d1eb 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_expression/scalar-vec3/u32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod_by_zero/by_expression/scalar-vec3/u32.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + uvec3 tint_mod(uint lhs, uvec3 rhs) { uvec3 l = uvec3(lhs); - return (l % mix(rhs, uvec3(1u), equal(rhs, uvec3(0u)))); + return (l % tint_select(rhs, uvec3(1u), equal(rhs, uvec3(0u)))); } void f() { diff --git a/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-scalar/i32.wgsl.expected.glsl b/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-scalar/i32.wgsl.expected.glsl index 405f4269d8..1e741c4e21 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-scalar/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-scalar/i32.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +ivec3 tint_select(ivec3 param_0, ivec3 param_1, bvec3 param_2) { + return ivec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + 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((-2147483647 - 1)))) & uvec3(equal(r, ivec3(-1))))))); + ivec3 rhs_or_one = tint_select(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 { diff --git a/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-scalar/u32.wgsl.expected.glsl b/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-scalar/u32.wgsl.expected.glsl index 82a5991ee3..c64f75ef4d 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-scalar/u32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-scalar/u32.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + uvec3 tint_mod(uvec3 lhs, uint rhs) { uvec3 r = uvec3(rhs); - return (lhs % mix(r, uvec3(1u), equal(r, uvec3(0u)))); + return (lhs % tint_select(r, uvec3(1u), equal(r, uvec3(0u)))); } void f() { diff --git a/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-vec3/i32.wgsl.expected.glsl b/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-vec3/i32.wgsl.expected.glsl index 56a740d61f..c34f70329c 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-vec3/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-vec3/i32.wgsl.expected.glsl @@ -1,7 +1,12 @@ #version 310 es +ivec3 tint_select(ivec3 param_0, ivec3 param_1, bvec3 param_2) { + return ivec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + 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((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1))))))); + ivec3 rhs_or_one = tint_select(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 { diff --git a/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-vec3/u32.wgsl.expected.glsl b/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-vec3/u32.wgsl.expected.glsl index 2f2985a34f..88876ddf4d 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-vec3/u32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-vec3/u32.wgsl.expected.glsl @@ -1,7 +1,12 @@ #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + uvec3 tint_mod(uvec3 lhs, uvec3 rhs) { - return (lhs % mix(rhs, uvec3(1u), equal(rhs, uvec3(0u)))); + return (lhs % tint_select(rhs, uvec3(1u), equal(rhs, uvec3(0u)))); } void f() { diff --git a/test/tint/expressions/binary/mod_by_zero/by_identifier/scalar-vec3/i32.wgsl.expected.glsl b/test/tint/expressions/binary/mod_by_zero/by_identifier/scalar-vec3/i32.wgsl.expected.glsl index ef41fb8c54..cdbec37b09 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_identifier/scalar-vec3/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod_by_zero/by_identifier/scalar-vec3/i32.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +ivec3 tint_select(ivec3 param_0, ivec3 param_1, bvec3 param_2) { + return ivec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + 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((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1))))))); + ivec3 rhs_or_one = tint_select(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 { diff --git a/test/tint/expressions/binary/mod_by_zero/by_identifier/scalar-vec3/u32.wgsl.expected.glsl b/test/tint/expressions/binary/mod_by_zero/by_identifier/scalar-vec3/u32.wgsl.expected.glsl index 534cab7017..2b82a7771f 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_identifier/scalar-vec3/u32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod_by_zero/by_identifier/scalar-vec3/u32.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + uvec3 tint_mod(uint lhs, uvec3 rhs) { uvec3 l = uvec3(lhs); - return (l % mix(rhs, uvec3(1u), equal(rhs, uvec3(0u)))); + return (l % tint_select(rhs, uvec3(1u), equal(rhs, uvec3(0u)))); } void f() { diff --git a/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-scalar/i32.wgsl.expected.glsl b/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-scalar/i32.wgsl.expected.glsl index b1ddb82a12..8d45e86e40 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-scalar/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-scalar/i32.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +ivec3 tint_select(ivec3 param_0, ivec3 param_1, bvec3 param_2) { + return ivec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + 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((-2147483647 - 1)))) & uvec3(equal(r, ivec3(-1))))))); + ivec3 rhs_or_one = tint_select(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 { diff --git a/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-scalar/u32.wgsl.expected.glsl b/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-scalar/u32.wgsl.expected.glsl index 03f7867de4..82feba025f 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-scalar/u32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-scalar/u32.wgsl.expected.glsl @@ -1,8 +1,13 @@ #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + uvec3 tint_mod(uvec3 lhs, uint rhs) { uvec3 r = uvec3(rhs); - return (lhs % mix(r, uvec3(1u), equal(r, uvec3(0u)))); + return (lhs % tint_select(r, uvec3(1u), equal(r, uvec3(0u)))); } void f() { diff --git a/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-vec3/i32.wgsl.expected.glsl b/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-vec3/i32.wgsl.expected.glsl index fcb2b3731d..b117147e93 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-vec3/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-vec3/i32.wgsl.expected.glsl @@ -1,7 +1,12 @@ #version 310 es +ivec3 tint_select(ivec3 param_0, ivec3 param_1, bvec3 param_2) { + return ivec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + 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((-2147483647 - 1)))) & uvec3(equal(rhs, ivec3(-1))))))); + ivec3 rhs_or_one = tint_select(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 { diff --git a/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-vec3/u32.wgsl.expected.glsl b/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-vec3/u32.wgsl.expected.glsl index e6cd33b337..361f7c2e19 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-vec3/u32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-vec3/u32.wgsl.expected.glsl @@ -1,7 +1,12 @@ #version 310 es +uvec3 tint_select(uvec3 param_0, uvec3 param_1, bvec3 param_2) { + return uvec3(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2]); +} + + uvec3 tint_mod(uvec3 lhs, uvec3 rhs) { - return (lhs % mix(rhs, uvec3(1u), equal(rhs, uvec3(0u)))); + return (lhs % tint_select(rhs, uvec3(1u), equal(rhs, uvec3(0u)))); } void f() { diff --git a/test/tint/statements/compound_assign/vector/divide.wgsl.expected.glsl b/test/tint/statements/compound_assign/vector/divide.wgsl.expected.glsl index 3eee1a510d..57f2f60801 100644 --- a/test/tint/statements/compound_assign/vector/divide.wgsl.expected.glsl +++ b/test/tint/statements/compound_assign/vector/divide.wgsl.expected.glsl @@ -1,5 +1,10 @@ #version 310 es +ivec4 tint_select(ivec4 param_0, ivec4 param_1, bvec4 param_2) { + return ivec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void unused_entry_point() { return; @@ -13,7 +18,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((-2147483647 - 1)))) & uvec4(equal(rhs, ivec4(-1)))))))); + return (lhs / tint_select(rhs, ivec4(1), bvec4(uvec4(equal(rhs, ivec4(0))) | uvec4(bvec4(uvec4(equal(lhs, ivec4((-2147483647 - 1)))) & uvec4(equal(rhs, ivec4(-1)))))))); } void foo() { diff --git a/test/tint/statements/compound_assign/vector/modulo-scalar.wgsl.expected.glsl b/test/tint/statements/compound_assign/vector/modulo-scalar.wgsl.expected.glsl index 8d04681c1e..9497586fd8 100644 --- a/test/tint/statements/compound_assign/vector/modulo-scalar.wgsl.expected.glsl +++ b/test/tint/statements/compound_assign/vector/modulo-scalar.wgsl.expected.glsl @@ -1,5 +1,10 @@ #version 310 es +ivec4 tint_select(ivec4 param_0, ivec4 param_1, bvec4 param_2) { + return ivec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void unused_entry_point() { return; @@ -14,7 +19,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((-2147483647 - 1)))) & uvec4(equal(r, ivec4(-1))))))); + ivec4 rhs_or_one = tint_select(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 { diff --git a/test/tint/statements/compound_assign/vector/modulo.wgsl.expected.glsl b/test/tint/statements/compound_assign/vector/modulo.wgsl.expected.glsl index c8745d46fd..58757ab864 100644 --- a/test/tint/statements/compound_assign/vector/modulo.wgsl.expected.glsl +++ b/test/tint/statements/compound_assign/vector/modulo.wgsl.expected.glsl @@ -1,5 +1,10 @@ #version 310 es +ivec4 tint_select(ivec4 param_0, ivec4 param_1, bvec4 param_2) { + return ivec4(param_2[0] ? param_1[0] : param_0[0], param_2[1] ? param_1[1] : param_0[1], param_2[2] ? param_1[2] : param_0[2], param_2[3] ? param_1[3] : param_0[3]); +} + + layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void unused_entry_point() { return; @@ -13,7 +18,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((-2147483647 - 1)))) & uvec4(equal(rhs, ivec4(-1))))))); + ivec4 rhs_or_one = tint_select(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 {