diff --git a/src/writer/glsl/generator_impl.cc b/src/writer/glsl/generator_impl.cc index f43509eae5..805fcbb304 100644 --- a/src/writer/glsl/generator_impl.cc +++ b/src/writer/glsl/generator_impl.cc @@ -563,12 +563,6 @@ bool GeneratorImpl::EmitTypeConstructor(std::ostream& out, return EmitZeroValue(out, type); } - // For single-value vector initializers, swizzle the scalar to the right - // vector dimension using .x - const bool is_single_value_vector_init = - type->is_scalar_vector() && call->Arguments().size() == 1 && - call->Arguments()[0]->Type()->UnwrapRef()->is_scalar(); - auto it = structure_builders_.find(As(type)); if (it != structure_builders_.end()) { out << it->second << "("; @@ -580,10 +574,6 @@ bool GeneratorImpl::EmitTypeConstructor(std::ostream& out, out << "("; } - if (is_single_value_vector_init) { - out << "("; - } - bool first = true; for (auto* arg : call->Arguments()) { if (!first) { @@ -596,10 +586,6 @@ bool GeneratorImpl::EmitTypeConstructor(std::ostream& out, } } - if (is_single_value_vector_init) { - out << ")." << std::string(type->As()->Width(), 'x'); - } - out << ")"; return true; } diff --git a/src/writer/glsl/generator_impl_constructor_test.cc b/src/writer/glsl/generator_impl_constructor_test.cc index f70b5f3979..f6f0cd234f 100644 --- a/src/writer/glsl/generator_impl_constructor_test.cc +++ b/src/writer/glsl/generator_impl_constructor_test.cc @@ -122,7 +122,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, GeneratorImpl& gen = Build(); ASSERT_TRUE(gen.Generate()) << gen.error(); - EXPECT_THAT(gen.result(), HasSubstr("vec3((2.0f).xxx)")); + EXPECT_THAT(gen.result(), HasSubstr("vec3(2.0f)")); } TEST_F(GlslGeneratorImplTest_Constructor, @@ -132,7 +132,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, GeneratorImpl& gen = Build(); ASSERT_TRUE(gen.Generate()) << gen.error(); - EXPECT_THAT(gen.result(), HasSubstr("bvec3((true).xxx)")); + EXPECT_THAT(gen.result(), HasSubstr("bvec3(true)")); } TEST_F(GlslGeneratorImplTest_Constructor, @@ -142,7 +142,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, GeneratorImpl& gen = Build(); ASSERT_TRUE(gen.Generate()) << gen.error(); - EXPECT_THAT(gen.result(), HasSubstr("ivec3((2).xxx)")); + EXPECT_THAT(gen.result(), HasSubstr("ivec3(2)")); } TEST_F(GlslGeneratorImplTest_Constructor, @@ -152,7 +152,7 @@ TEST_F(GlslGeneratorImplTest_Constructor, GeneratorImpl& gen = Build(); ASSERT_TRUE(gen.Generate()) << gen.error(); - EXPECT_THAT(gen.result(), HasSubstr("uvec3((2u).xxx)")); + EXPECT_THAT(gen.result(), HasSubstr("uvec3(2u)")); } TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Type_Mat) { diff --git a/test/bug/tint/1121.wgsl.expected.glsl b/test/bug/tint/1121.wgsl.expected.glsl index 1dad2dbcf2..fbdcc648e4 100644 --- a/test/bug/tint/1121.wgsl.expected.glsl +++ b/test/bug/tint/1121.wgsl.expected.glsl @@ -1,5 +1,3 @@ -SKIP: FAILED - #version 310 es precision mediump float; @@ -59,8 +57,8 @@ void tint_symbol_2_inner(uvec3 GlobalInvocationID) { lightPos = (uniforms.viewMatrix * lightPos); lightPos = (lightPos / lightPos.w); float lightRadius = lightsBuffer.lights[index].radius; - vec4 boxMin = (lightPos - vec4(vec3((lightRadius).xxx), 0.0f)); - vec4 boxMax = (lightPos + vec4(vec3((lightRadius).xxx), 0.0f)); + vec4 boxMin = (lightPos - vec4(vec3(lightRadius), 0.0f)); + vec4 boxMax = (lightPos + vec4(vec3(lightRadius), 0.0f)); vec4 frustumPlanes[6] = vec4[6](vec4(0.0f, 0.0f, 0.0f, 0.0f), vec4(0.0f, 0.0f, 0.0f, 0.0f), vec4(0.0f, 0.0f, 0.0f, 0.0f), vec4(0.0f, 0.0f, 0.0f, 0.0f), vec4(0.0f, 0.0f, 0.0f, 0.0f), vec4(0.0f, 0.0f, 0.0f, 0.0f)); frustumPlanes[4] = vec4(0.0f, 0.0f, -1.0f, viewNear); frustumPlanes[5] = vec4(0.0f, 0.0f, 1.0f, -(viewFar)); @@ -71,8 +69,8 @@ void tint_symbol_2_inner(uvec3 GlobalInvocationID) { { for(int x_1 = 0; (x_1 < TILE_COUNT_X); x_1 = (x_1 + 1)) { ivec2 tilePixel0Idx = ivec2((x_1 * TILE_SIZE), (y_1 * TILE_SIZE)); - vec2 floorCoord = (((2.0f * vec2(tilePixel0Idx)) / uniforms.fullScreenSize.xy) - vec2((1.0f).xx)); - vec2 ceilCoord = (((2.0f * vec2((tilePixel0Idx + ivec2((TILE_SIZE).xx)))) / uniforms.fullScreenSize.xy) - vec2((1.0f).xx)); + vec2 floorCoord = (((2.0f * vec2(tilePixel0Idx)) / uniforms.fullScreenSize.xy) - vec2(1.0f)); + vec2 ceilCoord = (((2.0f * vec2((tilePixel0Idx + ivec2(TILE_SIZE)))) / uniforms.fullScreenSize.xy) - vec2(1.0f)); vec2 viewFloorCoord = vec2((((-(viewNear) * floorCoord.x) - (M[2][0] * viewNear)) / M[0][0]), (((-(viewNear) * floorCoord.y) - (M[2][1] * viewNear)) / M[1][1])); vec2 viewCeilCoord = vec2((((-(viewNear) * ceilCoord.x) - (M[2][0] * viewNear)) / M[0][0]), (((-(viewNear) * ceilCoord.y) - (M[2][1] * viewNear)) / M[1][1])); frustumPlanes[0] = vec4(1.0f, 0.0f, (-(viewFloorCoord.x) / viewNear), 0.0f); @@ -135,10 +133,3 @@ void main() { } -Error parsing GLSL shader: -ERROR: 0:60: 'scalar swizzle' : not supported with this profile: es -ERROR: 0:60: '' : compilation terminated -ERROR: 2 compilation errors. No code generated. - - - diff --git a/test/bug/tint/980.wgsl.expected.glsl b/test/bug/tint/980.wgsl.expected.glsl index 84a31015d5..3f7cc010b3 100644 --- a/test/bug/tint/980.wgsl.expected.glsl +++ b/test/bug/tint/980.wgsl.expected.glsl @@ -1,10 +1,8 @@ -SKIP: FAILED - #version 310 es precision mediump float; vec3 Bad(uint index, vec3 rd) { - vec3 normal = vec3((0.0f).xxx); + vec3 normal = vec3(0.0f); normal[index] = -(sign(rd[index])); return normalize(normal); } @@ -34,10 +32,3 @@ void main() { } -Error parsing GLSL shader: -ERROR: 0:5: 'scalar swizzle' : not supported with this profile: es -ERROR: 0:5: '' : compilation terminated -ERROR: 2 compilation errors. No code generated. - - - diff --git a/test/bug/tint/992.wgsl.expected.glsl b/test/bug/tint/992.wgsl.expected.glsl index cf090d074f..b9fed97ef1 100644 --- a/test/bug/tint/992.wgsl.expected.glsl +++ b/test/bug/tint/992.wgsl.expected.glsl @@ -1,5 +1,3 @@ -SKIP: FAILED - #version 310 es precision mediump float; @@ -9,7 +7,7 @@ struct tint_symbol { vec4 frag_main_inner() { float b = 0.0f; - vec3 v = vec3((b).xxx); + vec3 v = vec3(b); return vec4(v, 1.0f); } @@ -27,10 +25,3 @@ void main() { } -Error parsing GLSL shader: -ERROR: 0:10: 'scalar swizzle' : not supported with this profile: es -ERROR: 0:10: '' : compilation terminated -ERROR: 2 compilation errors. No code generated. - - - diff --git a/test/intrinsics/repeated_use.wgsl.expected.glsl b/test/intrinsics/repeated_use.wgsl.expected.glsl index 51cea440f5..de8612d4c2 100644 --- a/test/intrinsics/repeated_use.wgsl.expected.glsl +++ b/test/intrinsics/repeated_use.wgsl.expected.glsl @@ -31,13 +31,13 @@ bool tint_isNormal_3(float param_0) { layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void tint_symbol() { tint_isNormal(vec4(0.0f, 0.0f, 0.0f, 0.0f)); - tint_isNormal(vec4((1.0f).xxxx)); + tint_isNormal(vec4(1.0f)); tint_isNormal(vec4(1.0f, 2.0f, 3.0f, 4.0f)); tint_isNormal_1(vec3(0.0f, 0.0f, 0.0f)); - tint_isNormal_1(vec3((1.0f).xxx)); + tint_isNormal_1(vec3(1.0f)); tint_isNormal_1(vec3(1.0f, 2.0f, 3.0f)); tint_isNormal_2(vec2(0.0f, 0.0f)); - tint_isNormal_2(vec2((1.0f).xx)); + tint_isNormal_2(vec2(1.0f)); tint_isNormal_2(vec2(1.0f, 2.0f)); tint_isNormal_3(1.0f); tint_isNormal_3(2.0f); diff --git a/test/types/function_scope_var_conversions.wgsl.expected.glsl b/test/types/function_scope_var_conversions.wgsl.expected.glsl index bc199a8460..088c30bfeb 100644 --- a/test/types/function_scope_var_conversions.wgsl.expected.glsl +++ b/test/types/function_scope_var_conversions.wgsl.expected.glsl @@ -1,5 +1,3 @@ -SKIP: FAILED - #version 310 es precision mediump float; @@ -14,17 +12,17 @@ void tint_symbol() { uint u32_var1 = uint(123); uint u32_var2 = uint(123.0f); uint u32_var3 = uint(true); - bvec3 v3bool_var1 = bvec3(uvec3((123u).xxx)); - bvec3 v3bool_var11 = bvec3(uvec3((1234u).xxx)); - bvec3 v3bool_var2 = bvec3(ivec3((123).xxx)); - bvec3 v3bool_var3 = bvec3(vec3((123.0f).xxx)); - ivec3 v3i32_var1 = ivec3(uvec3((123u).xxx)); - ivec3 v3i32_var2 = ivec3(vec3((123.0f).xxx)); - ivec3 v3i32_var3 = ivec3(bvec3((true).xxx)); - uvec3 v3u32_var1 = uvec3(ivec3((123).xxx)); - uvec3 v3u32_var2 = uvec3(vec3((123.0f).xxx)); - uvec3 v3u32_var3 = uvec3(bvec3((true).xxx)); - bvec3 v3bool_var4 = bvec3(bvec2(vec2((123.0f).xx)), true); + bvec3 v3bool_var1 = bvec3(uvec3(123u)); + bvec3 v3bool_var11 = bvec3(uvec3(1234u)); + bvec3 v3bool_var2 = bvec3(ivec3(123)); + bvec3 v3bool_var3 = bvec3(vec3(123.0f)); + ivec3 v3i32_var1 = ivec3(uvec3(123u)); + ivec3 v3i32_var2 = ivec3(vec3(123.0f)); + ivec3 v3i32_var3 = ivec3(bvec3(true)); + uvec3 v3u32_var1 = uvec3(ivec3(123)); + uvec3 v3u32_var2 = uvec3(vec3(123.0f)); + uvec3 v3u32_var3 = uvec3(bvec3(true)); + bvec3 v3bool_var4 = bvec3(bvec2(vec2(123.0f)), true); bvec4 v4bool_var5 = bvec4(bvec2(vec2(123.0f, 0.0f)), bvec2(true, bool(float(0.0f)))); return; } @@ -33,10 +31,3 @@ void main() { } -Error parsing GLSL shader: -ERROR: 0:15: 'scalar swizzle' : not supported with this profile: es -ERROR: 0:15: '' : compilation terminated -ERROR: 2 compilation errors. No code generated. - - - diff --git a/test/types/module_scope_var_conversions.wgsl.expected.glsl b/test/types/module_scope_var_conversions.wgsl.expected.glsl index f846718b31..422c557cce 100644 --- a/test/types/module_scope_var_conversions.wgsl.expected.glsl +++ b/test/types/module_scope_var_conversions.wgsl.expected.glsl @@ -1,5 +1,3 @@ -SKIP: FAILED - #version 310 es precision mediump float; @@ -12,16 +10,16 @@ int i32_var3 = int(true); uint u32_var1 = uint(1); uint u32_var2 = uint(1.0f); uint u32_var3 = uint(true); -bvec3 v3bool_var1 = bvec3(uvec3((1u).xxx)); -bvec3 v3bool_var2 = bvec3(ivec3((1).xxx)); -bvec3 v3bool_var3 = bvec3(vec3((1.0f).xxx)); -ivec3 v3i32_var1 = ivec3(uvec3((1u).xxx)); -ivec3 v3i32_var2 = ivec3(vec3((1.0f).xxx)); -ivec3 v3i32_var3 = ivec3(bvec3((true).xxx)); -uvec3 v3u32_var1 = uvec3(ivec3((1).xxx)); -uvec3 v3u32_var2 = uvec3(vec3((1.0f).xxx)); -uvec3 v3u32_var3 = uvec3(bvec3((true).xxx)); -bvec3 v3bool_var4 = bvec3(bvec2(vec2((123.0f).xx)), true); +bvec3 v3bool_var1 = bvec3(uvec3(1u)); +bvec3 v3bool_var2 = bvec3(ivec3(1)); +bvec3 v3bool_var3 = bvec3(vec3(1.0f)); +ivec3 v3i32_var1 = ivec3(uvec3(1u)); +ivec3 v3i32_var2 = ivec3(vec3(1.0f)); +ivec3 v3i32_var3 = ivec3(bvec3(true)); +uvec3 v3u32_var1 = uvec3(ivec3(1)); +uvec3 v3u32_var2 = uvec3(vec3(1.0f)); +uvec3 v3u32_var3 = uvec3(bvec3(true)); +bvec3 v3bool_var4 = bvec3(bvec2(vec2(123.0f)), true); bvec4 v4bool_var5 = bvec4(bvec2(vec2(123.0f, 0.0f)), bvec2(true, bool(float(0.0f)))); layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; @@ -53,10 +51,3 @@ void main() { } -Error parsing GLSL shader: -ERROR: 0:13: 'scalar swizzle' : not supported with this profile: es -ERROR: 0:13: '' : compilation terminated -ERROR: 2 compilation errors. No code generated. - - -