mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
[valid] avoid OOM with large sparse resource bindings
This commit is contained in:
@@ -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
|
||||
@@ -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];
|
||||
@@ -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));
|
||||
|
||||
@@ -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>>,
|
||||
@@ -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(),
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user