mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-02-17 09:22:39 +00:00
glsl-out: fix emission of location/binding attributes (#1100)
This commit is contained in:
parent
602368d9f0
commit
e76824aba3
@ -101,9 +101,14 @@ impl Version {
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks if the version supports explicit `layout(location=)` qualifiers.
|
||||
/// Checks if the version supports all of the explicit layouts:
|
||||
/// - `location=` qualifiers for bindings
|
||||
/// - `binding=` qualifiers for resources
|
||||
///
|
||||
/// Note: `location=` for vertex inputs and fragment outputs is supported
|
||||
/// unconditionally for GLES 300.
|
||||
fn supports_explicit_locations(&self) -> bool {
|
||||
*self >= Version::Embedded(300) || *self >= Version::Desktop(410)
|
||||
*self >= Version::Embedded(310) || *self >= Version::Desktop(410)
|
||||
}
|
||||
}
|
||||
|
||||
@ -865,19 +870,21 @@ impl<'a, W: Write> Writer<'a, W> {
|
||||
ShaderStage::Fragment => !output,
|
||||
_ => false,
|
||||
};
|
||||
|
||||
// Write the I/O locations, if allowed
|
||||
if self.options.version.supports_explicit_locations()
|
||||
|| !emit_interpolation_and_auxiliary
|
||||
{
|
||||
write!(self.out, "layout(location = {}) ", location)?;
|
||||
}
|
||||
|
||||
// Write the interpolation qualifier.
|
||||
if let Some(interp) = interpolation {
|
||||
if emit_interpolation_and_auxiliary {
|
||||
write!(self.out, "{} ", glsl_interpolation(interp))?;
|
||||
}
|
||||
}
|
||||
|
||||
// Write the storage class
|
||||
if !emit_interpolation_and_auxiliary
|
||||
&& self.options.version.supports_explicit_locations()
|
||||
{
|
||||
write!(self.out, "layout(location = {}) ", location)?;
|
||||
}
|
||||
|
||||
// Write the sampling auxiliary qualifier.
|
||||
//
|
||||
// Before GLSL 4.2, the `centroid` and `sample` qualifiers were required to appear
|
||||
|
@ -2,4 +2,9 @@
|
||||
spv_version: (1, 0),
|
||||
spv_debug: true,
|
||||
spv_adjust_coordinate_space: true,
|
||||
glsl: (
|
||||
version: Embedded(300),
|
||||
writer_flags: (bits: 0),
|
||||
binding_map: {},
|
||||
),
|
||||
)
|
||||
|
@ -25,7 +25,7 @@ vec2 a_pos1 = vec2(0, 0);
|
||||
|
||||
layout(location = 1) in vec2 _p2vs_location1;
|
||||
layout(location = 0) in vec2 _p2vs_location0;
|
||||
smooth out vec2 _vs2fs_location0;
|
||||
layout(location = 0) smooth out vec2 _vs2fs_location0;
|
||||
|
||||
void main2() {
|
||||
vec2 _expr12 = a_uv1;
|
||||
|
@ -1,4 +1,4 @@
|
||||
#version 310 es
|
||||
#version 300 es
|
||||
|
||||
precision highp float;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#version 310 es
|
||||
#version 300 es
|
||||
|
||||
precision highp float;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#version 310 es
|
||||
#version 300 es
|
||||
|
||||
precision highp float;
|
||||
|
||||
@ -17,7 +17,6 @@ void main() {
|
||||
VertexOutput _tmp_return = VertexOutput(uv, vec4((1.2 * pos), 0.0, 1.0));
|
||||
_vs2fs_location0 = _tmp_return.uv;
|
||||
gl_Position = _tmp_return.position;
|
||||
gl_Position.yz = vec2(-gl_Position.y, gl_Position.z * 2.0 - gl_Position.w);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -18,8 +18,8 @@ readonly buffer Lights_block_1 {
|
||||
|
||||
uniform highp sampler2DArrayShadow _group_0_binding_2;
|
||||
|
||||
smooth in vec3 _vs2fs_location0;
|
||||
smooth in vec4 _vs2fs_location1;
|
||||
layout(location = 0) smooth in vec3 _vs2fs_location0;
|
||||
layout(location = 1) smooth in vec4 _vs2fs_location1;
|
||||
layout(location = 0) out vec4 _fs2p_location0;
|
||||
|
||||
float fetch_shadow(uint light_id, vec4 homogeneous_coords) {
|
||||
|
@ -9,7 +9,7 @@ struct VertexOutput {
|
||||
|
||||
layout(binding = 0) uniform highp samplerCube _group_0_binding_1;
|
||||
|
||||
smooth in vec3 _vs2fs_location0;
|
||||
layout(location = 0) smooth in vec3 _vs2fs_location0;
|
||||
layout(location = 0) out vec4 _fs2p_location0;
|
||||
|
||||
void main() {
|
||||
|
@ -12,7 +12,7 @@ layout(binding = 0) uniform Data_block_0 {
|
||||
mat4x4 view;
|
||||
} _group_0_binding_0;
|
||||
|
||||
smooth out vec3 _vs2fs_location0;
|
||||
layout(location = 0) smooth out vec3 _vs2fs_location0;
|
||||
|
||||
void main() {
|
||||
uint vertex_index = uint(gl_VertexID);
|
||||
|
Loading…
Reference in New Issue
Block a user