mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
Skip invariant for gl_FragCoord on WebGL2 (#2254)
This commit is contained in:
@@ -1264,11 +1264,27 @@ impl<'a, W: Write> Writer<'a, W> {
|
||||
} => (location, interpolation, sampling),
|
||||
crate::Binding::BuiltIn(built_in) => {
|
||||
if let crate::BuiltIn::Position { invariant: true } = built_in {
|
||||
writeln!(
|
||||
self.out,
|
||||
"invariant {};",
|
||||
glsl_built_in(built_in, output, self.options.version.is_webgl())
|
||||
)?;
|
||||
match (self.options.version, self.entry_point.stage) {
|
||||
(
|
||||
Version::Embedded {
|
||||
version: 300,
|
||||
is_webgl: true,
|
||||
},
|
||||
ShaderStage::Fragment,
|
||||
) => {
|
||||
// `invariant gl_FragCoord` is not allowed in WebGL2 and possibly
|
||||
// OpenGL ES in general (waiting on confirmation).
|
||||
//
|
||||
// See https://github.com/KhronosGroup/WebGL/issues/3518
|
||||
}
|
||||
_ => {
|
||||
writeln!(
|
||||
self.out,
|
||||
"invariant {};",
|
||||
glsl_built_in(built_in, output, self.options.version.is_webgl())
|
||||
)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
11
tests/in/invariant.param.ron
Normal file
11
tests/in/invariant.param.ron
Normal file
@@ -0,0 +1,11 @@
|
||||
(
|
||||
glsl: (
|
||||
version: Embedded (
|
||||
version: 300,
|
||||
is_webgl: true
|
||||
),
|
||||
writer_flags: (bits: 0),
|
||||
binding_map: {},
|
||||
zero_initialize_workgroup_memory: true,
|
||||
),
|
||||
)
|
||||
7
tests/in/invariant.wgsl
Normal file
7
tests/in/invariant.wgsl
Normal file
@@ -0,0 +1,7 @@
|
||||
@vertex
|
||||
fn vs() -> @builtin(position) @invariant vec4<f32> {
|
||||
return vec4<f32>(0.0);
|
||||
}
|
||||
|
||||
@fragment
|
||||
fn fs(@builtin(position) @invariant position: vec4<f32>) { }
|
||||
11
tests/out/glsl/invariant.frag_main.Fragment.glsl
Normal file
11
tests/out/glsl/invariant.frag_main.Fragment.glsl
Normal file
@@ -0,0 +1,11 @@
|
||||
#version 300 es
|
||||
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
|
||||
|
||||
void main() {
|
||||
vec4 position = gl_FragCoord;
|
||||
return;
|
||||
}
|
||||
|
||||
11
tests/out/glsl/invariant.fs.Fragment.glsl
Normal file
11
tests/out/glsl/invariant.fs.Fragment.glsl
Normal file
@@ -0,0 +1,11 @@
|
||||
#version 300 es
|
||||
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
|
||||
|
||||
void main() {
|
||||
vec4 position = gl_FragCoord;
|
||||
return;
|
||||
}
|
||||
|
||||
12
tests/out/glsl/invariant.vs.Vertex.glsl
Normal file
12
tests/out/glsl/invariant.vs.Vertex.glsl
Normal file
@@ -0,0 +1,12 @@
|
||||
#version 300 es
|
||||
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
|
||||
invariant gl_Position;
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4(0.0);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -558,6 +558,7 @@ fn convert_wgsl() {
|
||||
),
|
||||
("sprite", Targets::SPIRV),
|
||||
("force_point_size_vertex_shader_webgl", Targets::GLSL),
|
||||
("invariant", Targets::GLSL),
|
||||
];
|
||||
|
||||
for &(name, targets) in inputs.iter() {
|
||||
|
||||
Reference in New Issue
Block a user