Skip to content

Commit

Permalink
Fix BufferMapRange not being Send/Sync (on native) (#4818)
Browse files Browse the repository at this point in the history
* Make `BufferMappedRange` trait WasmNotSendSync

* make QueueWriteBuffer trait Debug

* add changelog

* fix pr numbers in changelog

* missing send/sync on web.rs on BufferMappedRange for fragile-send-sync-non-atomic-wasm + !atomics
  • Loading branch information
Wumpf authored Dec 9, 2023
1 parent 0a81ec3 commit d801c61
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ This feature allowed you to call `global_id` on any wgpu opaque handle to get a

#### General
- Added `DownlevelFlags::VERTEX_AND_INSTANCE_INDEX_RESPECTS_RESPECTIVE_FIRST_VALUE_IN_INDIRECT_DRAW` to know if `@builtin(vertex_index)` and `@builtin(instance_index)` will respect the `first_vertex` / `first_instance` in indirect calls. If this is not present, both will always start counting from 0. Currently enabled on all backends except DX12. By @cwfitzgerald in [#4722](https://github.com/gfx-rs/wgpu/pull/4722)
- No longer validate surfaces against their allowed extent range on configure. This caused warnings that were almost impossible to avoid. As before, the resulting behavior depends on the compositor. By @wumpf in [#????](https://github.com/gfx-rs/wgpu/pull/????)
- No longer validate surfaces against their allowed extent range on configure. This caused warnings that were almost impossible to avoid. As before, the resulting behavior depends on the compositor. By @wumpf in [#4796](https://github.com/gfx-rs/wgpu/pull/4796)
- Added support for the float32-filterable feature. By @almarklein in [#4759](https://github.com/gfx-rs/wgpu/pull/4759)

#### OpenGL
Expand Down Expand Up @@ -157,6 +157,10 @@ Passing an owned value `window` to `Surface` will return a `Surface<'static>`. S

### Bug Fixes

#### General

- `BufferMappedRange` trait is now `WasmNotSendSync`, i.e. it is `Send`/`Sync` if not on wasm or `fragile-send-sync-non-atomic-wasm` is enabled. By @wumpf in [#4818](https://github.com/gfx-rs/wgpu/pull/4818)

#### Vulkan

- Use `VK_EXT_robustness2` only when not using an outdated intel iGPU driver. By @TheoDulka in [#4602](https://github.com/gfx-rs/wgpu/pull/4602).
Expand Down
10 changes: 10 additions & 0 deletions wgpu/src/backend/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ unsafe impl Send for Context {}
not(target_feature = "atomics")
))]
unsafe impl Sync for Context {}
#[cfg(all(
feature = "fragile-send-sync-non-atomic-wasm",
not(target_feature = "atomics")
))]
unsafe impl Send for BufferMappedRange {}
#[cfg(all(
feature = "fragile-send-sync-non-atomic-wasm",
not(target_feature = "atomics")
))]
unsafe impl Sync for BufferMappedRange {}

impl fmt::Debug for Context {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand Down
4 changes: 2 additions & 2 deletions wgpu/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4089,15 +4089,15 @@ where
}
}

pub trait QueueWriteBuffer: WasmNotSendSync {
pub trait QueueWriteBuffer: WasmNotSendSync + Debug {
fn slice(&self) -> &[u8];

fn slice_mut(&mut self) -> &mut [u8];

fn as_any(&self) -> &dyn Any;
}

pub trait BufferMappedRange: Debug {
pub trait BufferMappedRange: WasmNotSendSync + Debug {
fn slice(&self) -> &[u8];
fn slice_mut(&mut self) -> &mut [u8];
}
Expand Down

0 comments on commit d801c61

Please sign in to comment.