[naga] In compaction, fix array lengths as part of type adjustment. (#6790)

Adjust the `Handle<Expression>` values that appear in
`TypeInner::Array` via `PendingArraySize::Expression` as part of the
normal type adjustment process in `ModuleMap::adjust_type`, rather
than cloning the type arena so we can iterate over it and call
`UniqueArena::replace`.

Fixes #6789.
This commit is contained in:
Jim Blandy
2024-12-20 07:33:29 -08:00
committed by GitHub
parent a5c3be575e
commit 2587db1c9b
2 changed files with 10 additions and 26 deletions

View File

@@ -216,30 +216,6 @@ pub fn compact(module: &mut crate::Module) {
}
}
for (handle, ty) in module.types.clone().iter() {
if let crate::TypeInner::Array {
base,
size: crate::ArraySize::Pending(crate::PendingArraySize::Expression(mut size_expr)),
stride,
} = ty.inner
{
module_map.global_expressions.adjust(&mut size_expr);
module.types.replace(
handle,
crate::Type {
name: None,
inner: crate::TypeInner::Array {
base,
size: crate::ArraySize::Pending(crate::PendingArraySize::Expression(
size_expr,
)),
stride,
},
},
);
}
}
// Temporary storage to help us reuse allocations of existing
// named expression tables.
let mut reused_named_expressions = crate::NamedExpressions::default();

View File

@@ -82,9 +82,17 @@ impl ModuleMap {
} => adjust(base),
Ti::Array {
ref mut base,
size: _,
ref mut size,
stride: _,
} => adjust(base),
} => {
adjust(base);
if let crate::ArraySize::Pending(crate::PendingArraySize::Expression(
ref mut size_expr,
)) = *size
{
self.global_expressions.adjust(size_expr);
}
}
Ti::Struct {
ref mut members,
span: _,