From 2295508f0e0d68e9160501b9a32201dd7a65e810 Mon Sep 17 00:00:00 2001 From: Frizi Date: Wed, 2 Jun 2021 01:46:17 +0200 Subject: [PATCH] Insert attribute glsl location qualifier for opengl ES 3.0 --- src/back/glsl/mod.rs | 6 ++++-- tests/out/quad-vert.Vertex.glsl | 2 +- tests/out/quad.Fragment.glsl | 2 +- tests/out/quad.Vertex.glsl | 2 +- tests/out/shadow.Fragment.glsl | 4 ++-- tests/out/skybox.Fragment.glsl | 2 +- tests/out/skybox.Vertex.glsl | 2 +- 7 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/back/glsl/mod.rs b/src/back/glsl/mod.rs index 985c385c0..6a4147149 100644 --- a/src/back/glsl/mod.rs +++ b/src/back/glsl/mod.rs @@ -106,7 +106,7 @@ impl Version { /// Checks if the version supports explicit `layout(location=)` qualifiers. fn supports_explicit_locations(&self) -> bool { - *self >= Version::Embedded(310) || *self >= Version::Desktop(410) + *self >= Version::Embedded(300) || *self >= Version::Desktop(410) } } @@ -825,7 +825,9 @@ impl<'a, W: Write> Writer<'a, W> { } // Write the storage class - if self.options.version.supports_explicit_locations() { + if !emit_interpolation_and_auxiliary + && self.options.version.supports_explicit_locations() + { write!(self.out, "layout(location = {}) ", location)?; } diff --git a/tests/out/quad-vert.Vertex.glsl b/tests/out/quad-vert.Vertex.glsl index c2f59e712..40d321619 100644 --- a/tests/out/quad-vert.Vertex.glsl +++ b/tests/out/quad-vert.Vertex.glsl @@ -21,7 +21,7 @@ struct gen_gl_PerVertex_block_0 { vec2 a_pos = vec2(0, 0); layout(location = 1) in vec2 _p2vs_location1; layout(location = 0) in vec2 _p2vs_location0; -smooth layout(location = 0) out vec2 _vs2fs_location0; +smooth out vec2 _vs2fs_location0; void main1() { v_uv = a_uv; diff --git a/tests/out/quad.Fragment.glsl b/tests/out/quad.Fragment.glsl index 825f9bd4d..ff24336cf 100644 --- a/tests/out/quad.Fragment.glsl +++ b/tests/out/quad.Fragment.glsl @@ -9,7 +9,7 @@ struct VertexOutput { uniform highp sampler2D _group_0_binding_0; -smooth layout(location = 0) in vec2 _vs2fs_location0; +smooth in vec2 _vs2fs_location0; layout(location = 0) out vec4 _fs2p_location0; void main() { diff --git a/tests/out/quad.Vertex.glsl b/tests/out/quad.Vertex.glsl index 95ce41427..873bbf39b 100644 --- a/tests/out/quad.Vertex.glsl +++ b/tests/out/quad.Vertex.glsl @@ -9,7 +9,7 @@ struct VertexOutput { layout(location = 0) in vec2 _p2vs_location0; layout(location = 1) in vec2 _p2vs_location1; -smooth layout(location = 0) out vec2 _vs2fs_location0; +smooth out vec2 _vs2fs_location0; void main() { vec2 pos = _p2vs_location0; diff --git a/tests/out/shadow.Fragment.glsl b/tests/out/shadow.Fragment.glsl index 5b9c58de0..df9f71c64 100644 --- a/tests/out/shadow.Fragment.glsl +++ b/tests/out/shadow.Fragment.glsl @@ -16,8 +16,8 @@ readonly buffer Lights_block_1 { } _group_0_binding_1; uniform highp sampler2DArrayShadow _group_0_binding_2; -smooth layout(location = 0) in vec3 _vs2fs_location0; -smooth layout(location = 1) in vec4 _vs2fs_location1; +smooth in vec3 _vs2fs_location0; +smooth in vec4 _vs2fs_location1; layout(location = 0) out vec4 _fs2p_location0; float fetch_shadow(uint light_id, vec4 homogeneous_coords) { diff --git a/tests/out/skybox.Fragment.glsl b/tests/out/skybox.Fragment.glsl index c8a25b448..1a8488c2a 100644 --- a/tests/out/skybox.Fragment.glsl +++ b/tests/out/skybox.Fragment.glsl @@ -9,7 +9,7 @@ struct VertexOutput { uniform highp samplerCube _group_0_binding_1; -smooth layout(location = 0) in vec3 _vs2fs_location0; +smooth in vec3 _vs2fs_location0; layout(location = 0) out vec4 _fs2p_location0; void main() { diff --git a/tests/out/skybox.Vertex.glsl b/tests/out/skybox.Vertex.glsl index 2d35107bc..1b7b6167c 100644 --- a/tests/out/skybox.Vertex.glsl +++ b/tests/out/skybox.Vertex.glsl @@ -11,7 +11,7 @@ uniform Data_block_0 { mat4x4 proj_inv; mat4x4 view; } _group_0_binding_0; -smooth layout(location = 0) out vec3 _vs2fs_location0; +smooth out vec3 _vs2fs_location0; void main() { uint vertex_index = uint(gl_VertexID);