mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
Fix bug where mapped range in WebBuffer is not cloned correctly (#8349)
Co-authored-by: Ryan Kaplan <ryan@Ryans-M2>
This commit is contained in:
parent
f0209e3db8
commit
756dd3c089
@ -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).
|
||||
|
||||
@ -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,
|
||||
@ -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) {
|
||||
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 {}..{}",
|
||||
|
||||
@ -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,
|
||||
}
|
||||
@ -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(),
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user