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
|
### 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
|
#### General
|
||||||
|
|
||||||
- Reject fragment shader output `location`s > `max_color_attachments` limit. By @ErichDonGubler in [#8316](https://github.com/gfx-rs/wgpu/pull/8316).
|
- 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
|
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)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
enum RangeMappingKind {
|
enum RangeMappingKind {
|
||||||
Mutable,
|
Mutable,
|
||||||
@ -786,7 +790,7 @@ impl MapContext {
|
|||||||
if self.mapped_range.is_empty() {
|
if self.mapped_range.is_empty() {
|
||||||
panic!("tried to call get_mapped_range(_mut) on an unmapped buffer");
|
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!(
|
panic!(
|
||||||
"tried to call get_mapped_range(_mut) on a range that is not entirely mapped. \
|
"tried to call get_mapped_range(_mut) on a range that is not entirely mapped. \
|
||||||
Attempted to get range {}, but the mapped range is {}..{}",
|
Attempted to get range {}, but the mapped range is {}..{}",
|
||||||
|
|||||||
@ -1221,7 +1221,7 @@ pub struct WebBuffer {
|
|||||||
/// The associated GPU buffer.
|
/// The associated GPU buffer.
|
||||||
inner: webgpu_sys::GpuBuffer,
|
inner: webgpu_sys::GpuBuffer,
|
||||||
/// The mapped array buffer and mapped range.
|
/// The mapped array buffer and mapped range.
|
||||||
mapping: RefCell<WebBufferMapState>,
|
mapping: Rc<RefCell<WebBufferMapState>>,
|
||||||
/// Unique identifier for this Buffer.
|
/// Unique identifier for this Buffer.
|
||||||
ident: crate::cmp::Identifier,
|
ident: crate::cmp::Identifier,
|
||||||
}
|
}
|
||||||
@ -1231,10 +1231,10 @@ impl WebBuffer {
|
|||||||
fn new(inner: webgpu_sys::GpuBuffer, desc: &crate::BufferDescriptor<'_>) -> Self {
|
fn new(inner: webgpu_sys::GpuBuffer, desc: &crate::BufferDescriptor<'_>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
inner,
|
inner,
|
||||||
mapping: RefCell::new(WebBufferMapState {
|
mapping: Rc::new(RefCell::new(WebBufferMapState {
|
||||||
mapped_buffer: None,
|
mapped_buffer: None,
|
||||||
range: 0..desc.size,
|
range: 0..desc.size,
|
||||||
}),
|
})),
|
||||||
ident: crate::cmp::Identifier::create(),
|
ident: crate::cmp::Identifier::create(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user