Skip to content

Commit

Permalink
[naga spv-out] Use HandleSet in ExpressionConstnessTracker.
Browse files Browse the repository at this point in the history
Change `naga::back::spv::ExpressionConstnessTracker::inner` from a
`BitSet` to a `HandleSet<Expression>`. Adjust uses.
  • Loading branch information
jimblandy authored and teoxoy committed Jun 25, 2024
1 parent 43f390e commit 71a52bd
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions naga/src/back/spv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,32 +537,32 @@ struct FunctionArgument {
/// - OpConstantComposite
/// - OpConstantNull
struct ExpressionConstnessTracker {
inner: bit_set::BitSet,
inner: crate::arena::HandleSet<crate::Expression>,
}

impl ExpressionConstnessTracker {
fn from_arena(arena: &crate::Arena<crate::Expression>) -> Self {
let mut inner = bit_set::BitSet::new();
let mut inner = crate::arena::HandleSet::for_arena(arena);
for (handle, expr) in arena.iter() {
let insert = match *expr {
crate::Expression::Literal(_)
| crate::Expression::ZeroValue(_)
| crate::Expression::Constant(_) => true,
crate::Expression::Compose { ref components, .. } => {
components.iter().all(|h| inner.contains(h.index()))
components.iter().all(|&h| inner.contains(h))
}
crate::Expression::Splat { value, .. } => inner.contains(value.index()),
crate::Expression::Splat { value, .. } => inner.contains(value),
_ => false,
};
if insert {
inner.insert(handle.index());
inner.insert(handle);
}
}
Self { inner }
}

fn is_const(&self, value: Handle<crate::Expression>) -> bool {
self.inner.contains(value.index())
self.inner.contains(value)
}
}

Expand Down

0 comments on commit 71a52bd

Please sign in to comment.