mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-20 06:21:13 +01:00
Skip invariant for gl_FragCoord on WebGL2 (#2254)
This commit is contained in:
1 parent
dce689cf58
commit
f48b6bf2a7
7 files changed
+74
-5
No files matched your search
+21
-5
@@ -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(());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
(
|
||||
glsl: (
|
||||
version: Embedded (
|
||||
version: 300,
|
||||
is_webgl: true
|
||||
),
|
||||
writer_flags: (bits: 0),
|
||||
binding_map: {},
|
||||
zero_initialize_workgroup_memory: true,
|
||||
),
|
||||
)
|
||||
@@ -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>) { }
|
||||
@@ -0,0 +1,11 @@
|
||||
#version 300 es
|
||||
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
|
||||
|
||||
void main() {
|
||||
vec4 position = gl_FragCoord;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
#version 300 es
|
||||
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
|
||||
|
||||
void main() {
|
||||
vec4 position = gl_FragCoord;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -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