Remove unnecessary "gl_PerVertex" name check so unused builtins will be

handled even when this name is not in the input SPIRV.
This commit is contained in:
Imbris 2024-02-08 21:26:58 -05:00 committed by Teodor Tanasoaia
parent 18b7904b8e
commit b704132b4c
3 changed files with 29 additions and 31 deletions

View File

@ -121,6 +121,7 @@ Bottom level categories:
#### Naga #### Naga
- Make use of `GL_EXT_texture_shadow_lod` to support sampling a cube depth texture with an explicit LOD. By @cmrschwarz in #[5171](https://github.com/gfx-rs/wgpu/pull/5171). - Make use of `GL_EXT_texture_shadow_lod` to support sampling a cube depth texture with an explicit LOD. By @cmrschwarz in #[5171](https://github.com/gfx-rs/wgpu/pull/5171).
- In spv-in, remove unnecessary "gl_PerVertex" name check so unused builtins will always be skipped. By @Imberflur in [#5227](https://github.com/gfx-rs/wgpu/pull/5227).
#### Tests #### Tests

View File

@ -376,34 +376,33 @@ impl<I: Iterator<Item = u32>> super::Frontend<I> {
// See the docs for `Frontend::gl_per_vertex_builtin_access`. // See the docs for `Frontend::gl_per_vertex_builtin_access`.
{ {
let ty = &module.types[result.ty]; let ty = &module.types[result.ty];
match ty.inner { if let crate::TypeInner::Struct {
crate::TypeInner::Struct { members: ref original_members,
members: ref original_members, span,
span, } = ty.inner
} if ty.name.as_deref() == Some("gl_PerVertex") => { {
let mut new_members = original_members.clone(); let mut new_members = None;
for member in &mut new_members { for (idx, member) in original_members.iter().enumerate() {
if let Some(crate::Binding::BuiltIn(built_in)) = member.binding if let Some(crate::Binding::BuiltIn(built_in)) = member.binding {
{ if !self.gl_per_vertex_builtin_access.contains(&built_in) {
if !self.gl_per_vertex_builtin_access.contains(&built_in) { new_members
member.binding = None .get_or_insert_with(|| original_members.clone())[idx]
} .binding = None;
} }
} }
if &new_members != original_members {
module.types.replace(
result.ty,
crate::Type {
name: ty.name.clone(),
inner: crate::TypeInner::Struct {
members: new_members,
span,
},
},
);
}
} }
_ => {} if let Some(new_members) = new_members {
module.types.replace(
result.ty,
crate::Type {
name: ty.name.clone(),
inner: crate::TypeInner::Struct {
members: new_members,
span,
},
},
);
}
} }
} }

View File

@ -1561,12 +1561,10 @@ impl<I: Iterator<Item = u32>> Frontend<I> {
span, span,
); );
if ty.name.as_deref() == Some("gl_PerVertex") { if let Some(crate::Binding::BuiltIn(built_in)) =
if let Some(crate::Binding::BuiltIn(built_in)) = members[index as usize].binding
members[index as usize].binding {
{ self.gl_per_vertex_builtin_access.insert(built_in);
self.gl_per_vertex_builtin_access.insert(built_in);
}
} }
AccessExpression { AccessExpression {