mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-22 07:21:04 +01:00
[glsl-out] emit sample variables extension
This commit is contained in:
1 parent
1233d7c1f0
commit
571ab96752
1 file changed
+44
-11
+44
-11
@@ -28,6 +28,10 @@ bitflags::bitflags! {
|
||||
/// Centroid are available in all GLSL versions we support.
|
||||
const NOPERSPECTIVE_QUALIFIER = 1 << 11;
|
||||
const SAMPLE_QUALIFIER = 1 << 12;
|
||||
const CLIP_DISTANCE = 1 << 13;
|
||||
const CULL_DISTANCE = 1 << 14;
|
||||
// Sample ID
|
||||
const SAMPLE_VARIABLES = 1 << 15;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,6 +94,10 @@ impl FeaturesManager {
|
||||
check_feature!(TEXTURE_1D, 0);
|
||||
check_feature!(NOPERSPECTIVE_QUALIFIER, 130);
|
||||
check_feature!(SAMPLE_QUALIFIER, 400, 320);
|
||||
// gl_ClipDistance is supported by core versions > 1.3 and aren't supported by an es versions without extensions
|
||||
check_feature!(CLIP_DISTANCE, 130, 300);
|
||||
check_feature!(CULL_DISTANCE, 450, 300);
|
||||
check_feature!(SAMPLE_VARIABLES, 300, 300);
|
||||
|
||||
// Return an error if there are missing features
|
||||
if missing.is_empty() {
|
||||
@@ -170,6 +178,19 @@ impl FeaturesManager {
|
||||
}
|
||||
}
|
||||
|
||||
if (self.0.contains(Features::CLIP_DISTANCE) || self.0.contains(Features::CULL_DISTANCE))
|
||||
&& version.is_es()
|
||||
{
|
||||
// TODO: handle gl_ClipDistance and gl_CullDistance usage in better way
|
||||
// https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_clip_cull_distance.txt
|
||||
// writeln!(out, "#extension GL_EXT_clip_cull_distance : require")?;
|
||||
}
|
||||
|
||||
if self.0.contains(Features::SAMPLE_VARIABLES) && version.is_es() {
|
||||
// https://www.khronos.org/registry/OpenGL/extensions/OES/OES_sample_variables.txt
|
||||
writeln!(out, "#extension GL_OES_sample_variables : require")?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -288,17 +309,29 @@ impl<'a, W> Writer<'a, W> {
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
if let Some(&Binding::Location {
|
||||
interpolation,
|
||||
sampling,
|
||||
..
|
||||
}) = binding
|
||||
{
|
||||
if interpolation == Some(Interpolation::Linear) {
|
||||
self.features.request(Features::NOPERSPECTIVE_QUALIFIER);
|
||||
}
|
||||
if sampling == Some(Sampling::Sample) {
|
||||
self.features.request(Features::SAMPLE_QUALIFIER);
|
||||
if let Some(binding) = binding {
|
||||
match *binding {
|
||||
Binding::BuiltIn(builtin) => match builtin {
|
||||
crate::BuiltIn::ClipDistance => {
|
||||
self.features.request(Features::CLIP_DISTANCE)
|
||||
}
|
||||
crate::BuiltIn::SampleIndex => {
|
||||
self.features.request(Features::SAMPLE_VARIABLES)
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
Binding::Location {
|
||||
location: _,
|
||||
interpolation,
|
||||
sampling,
|
||||
} => {
|
||||
if interpolation == Some(Interpolation::Linear) {
|
||||
self.features.request(Features::NOPERSPECTIVE_QUALIFIER);
|
||||
}
|
||||
if sampling == Some(Sampling::Sample) {
|
||||
self.features.request(Features::SAMPLE_QUALIFIER);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user