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

[valid] avoid OOM with large sparse resource bindings #2561

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
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
10 changes: 2 additions & 8 deletions src/valid/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -707,10 +707,6 @@ impl super::Validator {
return Err(EntryPointError::MissingVertexOutputPosition.with_span());
}

for bg in self.bind_group_masks.iter_mut() {
bg.clear();
}

#[cfg(feature = "validate")]
{
let used_push_constants = module
Expand All @@ -728,6 +724,7 @@ impl super::Validator {
}
}

self.ep_resource_bindings.clear();
#[cfg(feature = "validate")]
for (var_handle, var) in module.global_variables.iter() {
let usage = info[var_handle];
Expand Down Expand Up @@ -768,10 +765,7 @@ impl super::Validator {
}

if let Some(ref bind) = var.binding {
while self.bind_group_masks.len() <= bind.group as usize {
self.bind_group_masks.push(BitSet::new());
}
if !self.bind_group_masks[bind.group as usize].insert(bind.binding as usize) {
if !self.ep_resource_bindings.insert(bind.clone()) {
if self.flags.contains(super::ValidationFlags::BINDINGS) {
return Err(EntryPointError::BindingCollision(var_handle)
.with_span_handle(var_handle, &module.global_variables));
Expand Down
6 changes: 3 additions & 3 deletions src/valid/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ pub struct Validator {
types: Vec<r#type::TypeInfo>,
layouter: Layouter,
location_mask: BitSet,
bind_group_masks: Vec<BitSet>,
ep_resource_bindings: FastHashSet<crate::ResourceBinding>,
#[allow(dead_code)]
switch_values: FastHashSet<crate::SwitchValue>,
valid_expression_list: Vec<Handle<crate::Expression>>,
Expand Down Expand Up @@ -290,7 +290,7 @@ impl Validator {
types: Vec::new(),
layouter: Layouter::default(),
location_mask: BitSet::new(),
bind_group_masks: Vec::new(),
ep_resource_bindings: FastHashSet::default(),
switch_values: FastHashSet::default(),
valid_expression_list: Vec::new(),
valid_expression_set: BitSet::new(),
Expand All @@ -302,7 +302,7 @@ impl Validator {
self.types.clear();
self.layouter.clear();
self.location_mask.clear();
self.bind_group_masks.clear();
self.ep_resource_bindings.clear();
self.switch_values.clear();
self.valid_expression_list.clear();
self.valid_expression_set.clear();
Expand Down