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
- 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

View File

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

View File

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