Skip to content

Commit

Permalink
Remove unnecessary chunk size field from StagingBelt.
Browse files Browse the repository at this point in the history
  • Loading branch information
kpreid authored and cwfitzgerald committed Feb 13, 2025
1 parent ec6c722 commit 2f50426
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions wgpu/src/util/belt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,13 @@ impl StagingBelt {
{
self.free_chunks.swap_remove(index)
} else {
let size = self.chunk_size.max(size.get());
Chunk {
buffer: device.create_buffer(&BufferDescriptor {
label: Some("(wgpu internal) StagingBelt staging buffer"),
size,
size: self.chunk_size.max(size.get()),
usage: BufferUsages::MAP_WRITE | BufferUsages::COPY_SRC,
mapped_at_creation: true,
}),
size,
offset: 0,
}
}
Expand Down Expand Up @@ -231,7 +229,6 @@ impl fmt::Debug for StagingBelt {

struct Chunk {
buffer: Buffer,
size: BufferAddress,
offset: BufferAddress,
}

Expand All @@ -240,14 +237,14 @@ impl Chunk {
let alloc_start = align_to(self.offset, alignment);
let alloc_end = alloc_start + size.get();

alloc_end <= self.size
alloc_end <= self.buffer.size()
}

fn allocate(&mut self, size: BufferSize, alignment: BufferAddress) -> BufferAddress {
let alloc_start = align_to(self.offset, alignment);
let alloc_end = alloc_start + size.get();

assert!(alloc_end <= self.size);
assert!(alloc_end <= self.buffer.size());
self.offset = alloc_end;
alloc_start
}
Expand Down

0 comments on commit 2f50426

Please sign in to comment.