refactor(glsl-out): hoist new if let TypeInner::Struct out of varying_required_features (#6230)

This commit is contained in:
Erich Gubler 2024-10-14 06:45:32 -04:00 committed by GitHub
parent f842d80f52
commit f2faf609af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -557,49 +557,38 @@ impl<'a, W> Writer<'a, W> {
} }
fn varying_required_features(&mut self, binding: Option<&Binding>, ty: Handle<Type>) { fn varying_required_features(&mut self, binding: Option<&Binding>, ty: Handle<Type>) {
match self.module.types[ty].inner { if let TypeInner::Struct { ref members, .. } = self.module.types[ty].inner {
TypeInner::Struct { ref members, .. } => { for member in members {
for member in members { self.varying_required_features(member.binding.as_ref(), member.ty);
self.varying_required_features(member.binding.as_ref(), member.ty);
}
} }
_ => { } else if let Some(binding) = binding {
if let Some(binding) = binding { match *binding {
match *binding { Binding::BuiltIn(built_in) => match built_in {
Binding::BuiltIn(built_in) => match built_in { crate::BuiltIn::ClipDistance => self.features.request(Features::CLIP_DISTANCE),
crate::BuiltIn::ClipDistance => { crate::BuiltIn::CullDistance => self.features.request(Features::CULL_DISTANCE),
self.features.request(Features::CLIP_DISTANCE) crate::BuiltIn::SampleIndex => {
} self.features.request(Features::SAMPLE_VARIABLES)
crate::BuiltIn::CullDistance => { }
self.features.request(Features::CULL_DISTANCE) crate::BuiltIn::ViewIndex => self.features.request(Features::MULTI_VIEW),
} crate::BuiltIn::InstanceIndex | crate::BuiltIn::DrawID => {
crate::BuiltIn::SampleIndex => { self.features.request(Features::INSTANCE_INDEX)
self.features.request(Features::SAMPLE_VARIABLES) }
} _ => {}
crate::BuiltIn::ViewIndex => { },
self.features.request(Features::MULTI_VIEW) Binding::Location {
} location: _,
crate::BuiltIn::InstanceIndex | crate::BuiltIn::DrawID => { interpolation,
self.features.request(Features::INSTANCE_INDEX) sampling,
} second_blend_source,
_ => {} } => {
}, if interpolation == Some(Interpolation::Linear) {
Binding::Location { self.features.request(Features::NOPERSPECTIVE_QUALIFIER);
location: _, }
interpolation, if sampling == Some(Sampling::Sample) {
sampling, self.features.request(Features::SAMPLE_QUALIFIER);
second_blend_source, }
} => { if second_blend_source {
if interpolation == Some(Interpolation::Linear) { self.features.request(Features::DUAL_SOURCE_BLENDING);
self.features.request(Features::NOPERSPECTIVE_QUALIFIER);
}
if sampling == Some(Sampling::Sample) {
self.features.request(Features::SAMPLE_QUALIFIER);
}
if second_blend_source {
self.features.request(Features::DUAL_SOURCE_BLENDING);
}
}
} }
} }
} }