Skip to content

Commit

Permalink
refactor: extract new fn BoundBindGroupLayouts::num_valid_entries
Browse files Browse the repository at this point in the history
  • Loading branch information
teoxoy committed Oct 14, 2024
1 parent c0e3972 commit 6619f3a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions wgpu-core/src/command/bind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,17 @@ mod compat {
entries: (0..hal::MAX_BIND_GROUPS).map(|_| Entry::empty()).collect(),
}
}
fn make_range(&self, start_index: usize) -> Range<usize> {

pub fn num_valid_entries(&self) -> usize {
// find first incompatible entry
let end = self
.entries
self.entries
.iter()
.position(|e| e.is_incompatible())
.unwrap_or(self.entries.len());
.unwrap_or(self.entries.len())
}

fn make_range(&self, start_index: usize) -> Range<usize> {
let end = self.num_valid_entries();
start_index..end.max(start_index)
}

Expand Down

0 comments on commit 6619f3a

Please sign in to comment.