diff --git a/src/back/glsl/mod.rs b/src/back/glsl/mod.rs index a9fe8ce043..c74011a68d 100644 --- a/src/back/glsl/mod.rs +++ b/src/back/glsl/mod.rs @@ -1527,8 +1527,11 @@ impl<'a, W: Write> Writer<'a, W> { }; match *resolved { - TypeInner::Vector { .. } - | TypeInner::Matrix { .. } + TypeInner::Vector { .. } => { + // Write vector access as a swizzle + write!(self.out, ".{}", COMPONENTS[index as usize])? + } + TypeInner::Matrix { .. } | TypeInner::Array { .. } | TypeInner::ValuePointer { .. } => write!(self.out, "[{}]", index)?, TypeInner::Struct { .. } => { diff --git a/tests/out/boids.Compute.glsl b/tests/out/boids.Compute.glsl index 343e25bc35..e518b6cc76 100644 --- a/tests/out/boids.Compute.glsl +++ b/tests/out/boids.Compute.glsl @@ -40,11 +40,11 @@ void main() { vec2 pos1; vec2 vel1; uint i = 0u; - if((global_invocation_id[0] >= 1500u)) { + if((global_invocation_id.x >= 1500u)) { return; } - vPos = _group_0_binding_1.particles[global_invocation_id[0]].pos; - vVel = _group_0_binding_1.particles[global_invocation_id[0]].vel; + vPos = _group_0_binding_1.particles[global_invocation_id.x].pos; + vVel = _group_0_binding_1.particles[global_invocation_id.x].vel; cMass = vec2(0.0, 0.0); cVel = vec2(0.0, 0.0); colVel = vec2(0.0, 0.0); @@ -52,7 +52,7 @@ void main() { if((i >= 1500u)) { break; } - if((i == global_invocation_id[0])) { + if((i == global_invocation_id.x)) { continue; } pos1 = _group_0_binding_1.particles[i].pos; @@ -79,20 +79,20 @@ void main() { vVel = (((vVel + (cMass * _group_0_binding_0.rule1Scale)) + (colVel * _group_0_binding_0.rule2Scale)) + (cVel * _group_0_binding_0.rule3Scale)); vVel = (normalize(vVel) * clamp(length(vVel), 0.0, 0.1)); vPos = (vPos + (vVel * _group_0_binding_0.deltaT)); - if((vPos[0] < -1.0)) { - vPos[0] = 1.0; + if((vPos.x < -1.0)) { + vPos.x = 1.0; } - if((vPos[0] > 1.0)) { - vPos[0] = -1.0; + if((vPos.x > 1.0)) { + vPos.x = -1.0; } - if((vPos[1] < -1.0)) { - vPos[1] = 1.0; + if((vPos.y < -1.0)) { + vPos.y = 1.0; } - if((vPos[1] > 1.0)) { - vPos[1] = -1.0; + if((vPos.y > 1.0)) { + vPos.y = -1.0; } - _group_0_binding_2.particles[global_invocation_id[0]].pos = vPos; - _group_0_binding_2.particles[global_invocation_id[0]].vel = vVel; + _group_0_binding_2.particles[global_invocation_id.x].pos = vPos; + _group_0_binding_2.particles[global_invocation_id.x].vel = vVel; return; } diff --git a/tests/out/quad-vert.Vertex.glsl b/tests/out/quad-vert.Vertex.glsl index 3f3bb13ad6..e1b9853b05 100644 --- a/tests/out/quad-vert.Vertex.glsl +++ b/tests/out/quad-vert.Vertex.glsl @@ -30,7 +30,7 @@ smooth layout(location = 0) out vec2 _vs2fs_location0; void main1() { v_uv = a_uv; vec2 _expr13 = a_pos; - perVertexStruct.gen_gl_Position = vec4(_expr13[0], _expr13[1], 0.0, 1.0); + perVertexStruct.gen_gl_Position = vec4(_expr13.x, _expr13.y, 0.0, 1.0); return; } diff --git a/tests/out/quad.Fragment.glsl b/tests/out/quad.Fragment.glsl index 8062e3d200..825f9bd4d3 100644 --- a/tests/out/quad.Fragment.glsl +++ b/tests/out/quad.Fragment.glsl @@ -15,10 +15,10 @@ layout(location = 0) out vec4 _fs2p_location0; void main() { vec2 uv2 = _vs2fs_location0; vec4 _expr4 = texture(_group_0_binding_0, vec2(uv2)); - if((_expr4[3] == 0.0)) { + if((_expr4.w == 0.0)) { discard; } - _fs2p_location0 = (_expr4[3] * _expr4); + _fs2p_location0 = (_expr4.w * _expr4); return; } diff --git a/tests/out/shadow.Fragment.glsl b/tests/out/shadow.Fragment.glsl index e1310ca34f..2042b5f22d 100644 --- a/tests/out/shadow.Fragment.glsl +++ b/tests/out/shadow.Fragment.glsl @@ -23,10 +23,10 @@ smooth layout(location = 1) in vec4 _vs2fs_location1; layout(location = 0) out vec4 _fs2p_location0; float fetch_shadow(uint light_id, vec4 homogeneous_coords) { - if((homogeneous_coords[3] <= 0.0)) { + if((homogeneous_coords.w <= 0.0)) { return 1.0; } - float _expr26 = textureGrad(_group_0_binding_2, vec4((((homogeneous_coords.xy * vec2(0.5, -0.5)) / vec2(homogeneous_coords[3])) + vec2(0.5, 0.5)), int(light_id), (homogeneous_coords[2] / homogeneous_coords[3])), vec2(0, 0), vec2(0,0)); + float _expr26 = textureGrad(_group_0_binding_2, vec4((((homogeneous_coords.xy * vec2(0.5, -0.5)) / vec2(homogeneous_coords.w)) + vec2(0.5, 0.5)), int(light_id), (homogeneous_coords.z / homogeneous_coords.w)), vec2(0, 0), vec2(0,0)); return _expr26; } @@ -36,7 +36,7 @@ void main() { vec3 color1 = vec3(0.05, 0.05, 0.05); uint i = 0u; while(true) { - if((i >= min(_group_0_binding_0.num_lights[0], 10u))) { + if((i >= min(_group_0_binding_0.num_lights.x, 10u))) { break; } Light _expr21 = _group_0_binding_1.data[i];