Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 31 additions & 42 deletions naga/src/back/glsl/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,49 +557,38 @@ impl<'a, W> Writer<'a, W> {
}

fn varying_required_features(&mut self, binding: Option<&Binding>, ty: Handle<Type>) {
match self.module.types[ty].inner {
TypeInner::Struct { ref members, .. } => {
for member in members {
self.varying_required_features(member.binding.as_ref(), member.ty);
}
if let TypeInner::Struct { ref members, .. } = self.module.types[ty].inner {
for member in members {
self.varying_required_features(member.binding.as_ref(), member.ty);
}
_ => {
if let Some(binding) = binding {
match *binding {
Binding::BuiltIn(built_in) => match built_in {
crate::BuiltIn::ClipDistance => {
self.features.request(Features::CLIP_DISTANCE)
}
crate::BuiltIn::CullDistance => {
self.features.request(Features::CULL_DISTANCE)
}
crate::BuiltIn::SampleIndex => {
self.features.request(Features::SAMPLE_VARIABLES)
}
crate::BuiltIn::ViewIndex => {
self.features.request(Features::MULTI_VIEW)
}
crate::BuiltIn::InstanceIndex | crate::BuiltIn::DrawID => {
self.features.request(Features::INSTANCE_INDEX)
}
_ => {}
},
Binding::Location {
location: _,
interpolation,
sampling,
second_blend_source,
} => {
if interpolation == Some(Interpolation::Linear) {
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);
}
}
} else if let Some(binding) = binding {
match *binding {
Binding::BuiltIn(built_in) => match built_in {
crate::BuiltIn::ClipDistance => self.features.request(Features::CLIP_DISTANCE),
crate::BuiltIn::CullDistance => self.features.request(Features::CULL_DISTANCE),
crate::BuiltIn::SampleIndex => {
self.features.request(Features::SAMPLE_VARIABLES)
}
crate::BuiltIn::ViewIndex => self.features.request(Features::MULTI_VIEW),
crate::BuiltIn::InstanceIndex | crate::BuiltIn::DrawID => {
self.features.request(Features::INSTANCE_INDEX)
}
_ => {}
},
Binding::Location {
location: _,
interpolation,
sampling,
second_blend_source,
} => {
if interpolation == Some(Interpolation::Linear) {
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);
}
}
}
Expand Down