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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ By @andyleiserson in [#9321](https://github.com/gfx-rs/wgpu/pull/9321).

- Fix `SYNC-HAZARD-WRITE-AFTER-PRESENT` on Vulkan when a surface texture is presented without being rendered to. By @inner-daemons and @atlv24 in [#9361](https://github.com/gfx-rs/wgpu/pull/9361).
- Fix incorrect checks for dynamic binding bounds when calling an encoder's `set_bind_group` in passes and bundles. By @ErichDonGubler in [#9308](https://github.com/gfx-rs/wgpu/pull/9308).
- Writes from `Queue::write_buffer` are now flushed by calls to `Buffer::map_async` for that same buffer, to prevent reading stale data. `on_submitted_work_done` also now flushes pending writes. By @andyleiserson in [#9307](https://github.com/gfx-rs/wgpu/pull/9307).

#### naga

Expand Down
2 changes: 2 additions & 0 deletions cts_runner/test.lst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ unittests:*

webgpu:api,operation,adapter,requestAdapter:*
webgpu:api,operation,buffers,createBindGroup:buffer_binding_resource:*
webgpu:api,operation,buffers,map:mapAsync,read,*
webgpu:api,operation,buffers,map:mapAsync,write,*
webgpu:api,operation,command_buffer,basic:*
webgpu:api,operation,command_buffer,copyBufferToBuffer:*
fails-if(vulkan) webgpu:api,operation,command_buffer,copyTextureToTexture:copy_depth_stencil:format="depth16unorm"
Expand Down
43 changes: 43 additions & 0 deletions tests/tests/wgpu-gpu/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub fn all_tests(vec: &mut Vec<GpuTestInitializer>) {
vec.extend([
EMPTY_BUFFER,
MAP_OFFSET,
MAP_WITHOUT_SUBMIT,
MINIMUM_BUFFER_BINDING_SIZE_LAYOUT,
MINIMUM_BUFFER_BINDING_SIZE_DISPATCH,
CLEAR_OFFSET_OUTSIDE_RESOURCE_BOUNDS,
Expand Down Expand Up @@ -184,6 +185,48 @@ static MAP_OFFSET: GpuTestConfiguration = GpuTestConfiguration::new()
}
});

/// Mapping a buffer should see data previously written to the buffer, even if there was no
/// intervening submit.
///
/// Regression test for [#5173](https://github.com/gfx-rs/wgpu/issues/5173).
#[gpu_test]
static MAP_WITHOUT_SUBMIT: GpuTestConfiguration =
GpuTestConfiguration::new().run_async(|ctx| async move {
let buffer = ctx.device.create_buffer(&wgpu::BufferDescriptor {
label: None,
size: 12,
usage: wgpu::BufferUsages::MAP_READ | wgpu::BufferUsages::COPY_DST,
mapped_at_creation: true,
});

{
let data = (0..12).map(|i| (i % 255) as u8).collect::<Vec<u8>>();
let mut mapped = buffer.slice(0..12).get_mapped_range_mut().unwrap();
assert!(mapped.len() == 12);
mapped.copy_from_slice(&data);
}

buffer.unmap();

buffer
.slice(0..12)
.map_async(wgpu::MapMode::Read, Result::unwrap);

ctx.async_poll(wgpu::PollType::wait_indefinitely())
.await
.unwrap();

{
let mapped = buffer.slice(0..12).get_mapped_range().unwrap();
assert!(mapped.len() == 12);
for (i, elt) in mapped.iter().enumerate() {
assert_eq!(*elt, (i % 255) as u8);
}
}

buffer.unmap();
});

/// The WebGPU algorithm [validating shader binding][vsb] requires
/// implementations to check that buffer bindings are large enough to
/// hold the WGSL `storage` or `uniform` variables they're bound to.
Expand Down
1 change: 1 addition & 0 deletions wgpu-core/src/device/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub mod ray_tracing;
pub mod resource;
#[cfg(any(feature = "trace", feature = "replay"))]
pub mod trace;
pub(crate) use resource::{FenceReadGuard, FenceWriteGuard};
pub use {life::WaitIdleError, resource::Device};

pub const SHADER_STAGE_COUNT: usize = hal::MAX_CONCURRENT_SHADER_STAGES;
Expand Down
Loading