Skip to content
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ SamplerDescriptor {

### Bug Fixes

- Fixed bug where mapping sub-ranges of a buffer on web would fail with `OperationError: GPUBuffer.getMappedRange: GetMappedRange range extends beyond buffer's mapped range`. By @ryankaplan in [#8349](https://github.com/gfx-rs/wgpu/pull/8349)

#### General

- Reject fragment shader output `location`s > `max_color_attachments` limit. By @ErichDonGubler in [#8316](https://github.com/gfx-rs/wgpu/pull/8316).
Expand Down
6 changes: 5 additions & 1 deletion wgpu/src/api/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,10 @@ fn range_overlaps(a: &Range<BufferAddress>, b: &Range<BufferAddress>) -> bool {
a.start < b.end && b.start < a.end
}

fn range_contains(a: &Range<BufferAddress>, b: &Range<BufferAddress>) -> bool {
a.start <= b.start && a.end >= b.end
}

#[derive(Debug, Copy, Clone)]
enum RangeMappingKind {
Mutable,
Expand Down Expand Up @@ -786,7 +790,7 @@ impl MapContext {
if self.mapped_range.is_empty() {
panic!("tried to call get_mapped_range(_mut) on an unmapped buffer");
}
if !range_overlaps(&self.mapped_range, &new_sub.index) {
if !range_contains(&self.mapped_range, &new_sub.index) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unrelated but seemed wrong

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm yeah, weird. I wonder why the tests were passing.

panic!(
"tried to call get_mapped_range(_mut) on a range that is not entirely mapped. \
Attempted to get range {}, but the mapped range is {}..{}",
Expand Down
6 changes: 3 additions & 3 deletions wgpu/src/backend/webgpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,7 @@ pub struct WebBuffer {
/// The associated GPU buffer.
inner: webgpu_sys::GpuBuffer,
/// The mapped array buffer and mapped range.
mapping: RefCell<WebBufferMapState>,
mapping: Rc<RefCell<WebBufferMapState>>,
/// Unique identifier for this Buffer.
ident: crate::cmp::Identifier,
}
Expand All @@ -1231,10 +1231,10 @@ impl WebBuffer {
fn new(inner: webgpu_sys::GpuBuffer, desc: &crate::BufferDescriptor<'_>) -> Self {
Self {
inner,
mapping: RefCell::new(WebBufferMapState {
mapping: Rc::new(RefCell::new(WebBufferMapState {
mapped_buffer: None,
range: 0..desc.size,
}),
})),
ident: crate::cmp::Identifier::create(),
}
}
Expand Down