From 0a81ec377aed08a6bbcd8e7cdd4d92e3f293573d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 7 Dec 2023 23:47:27 -0500 Subject: [PATCH 1/4] Bump once_cell from 1.18.0 to 1.19.0 (#4847) Bumps [once_cell](https://github.com/matklad/once_cell) from 1.18.0 to 1.19.0. - [Changelog](https://github.com/matklad/once_cell/blob/master/CHANGELOG.md) - [Commits](https://github.com/matklad/once_cell/compare/v1.18.0...v1.19.0) --- updated-dependencies: - dependency-name: once_cell dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- wgpu-hal/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cf9387f636..4c1a4803e2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2441,9 +2441,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "oorandom" diff --git a/wgpu-hal/Cargo.toml b/wgpu-hal/Cargo.toml index 5ca8445e25..ad09625ab7 100644 --- a/wgpu-hal/Cargo.toml +++ b/wgpu-hal/Cargo.toml @@ -77,7 +77,7 @@ parking_lot = ">=0.11,<0.13" profiling = { version = "1", default-features = false } raw-window-handle = "0.6" thiserror = "1" -once_cell = "1.18.0" +once_cell = "1.19.0" # backends common arrayvec = "0.7" From d801c6111d2e6b51402539e4eec26957f2060b4d Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Sat, 9 Dec 2023 12:25:27 +0100 Subject: [PATCH 2/4] Fix `BufferMapRange` not being Send/Sync (on native) (#4818) * 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 --- CHANGELOG.md | 6 +++++- wgpu/src/backend/web.rs | 10 ++++++++++ wgpu/src/context.rs | 4 ++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 90f747f79f..00d53de0c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -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). diff --git a/wgpu/src/backend/web.rs b/wgpu/src/backend/web.rs index 4b6e527ab2..82b31c6f6a 100644 --- a/wgpu/src/backend/web.rs +++ b/wgpu/src/backend/web.rs @@ -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 { diff --git a/wgpu/src/context.rs b/wgpu/src/context.rs index f81867a2ea..46ba86cdbe 100644 --- a/wgpu/src/context.rs +++ b/wgpu/src/context.rs @@ -4089,7 +4089,7 @@ where } } -pub trait QueueWriteBuffer: WasmNotSendSync { +pub trait QueueWriteBuffer: WasmNotSendSync + Debug { fn slice(&self) -> &[u8]; fn slice_mut(&mut self) -> &mut [u8]; @@ -4097,7 +4097,7 @@ pub trait QueueWriteBuffer: WasmNotSendSync { 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]; } From af701fb26d881dfa272712f984c8f4e7ad56d4c9 Mon Sep 17 00:00:00 2001 From: Nicolas Silva Date: Sat, 9 Dec 2023 23:43:53 +0100 Subject: [PATCH 3/4] Format extent and origin types as tuples. (#4853) * Format extent and origin types as tuples. * Update wgpu-types/src/lib.rs Co-authored-by: Andreas Reich --------- Co-authored-by: Andreas Reich --- wgpu-types/src/lib.rs | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index 86a2666663..e76bebe625 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -5274,7 +5274,7 @@ pub enum TextureDimension { /// Corresponds to [WebGPU `GPUOrigin2D`]( /// https://gpuweb.github.io/gpuweb/#dictdef-gpuorigin2ddict). #[repr(C)] -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] +#[derive(Clone, Copy, PartialEq, Eq, Hash)] #[cfg_attr(feature = "trace", derive(Serialize))] #[cfg_attr(feature = "replay", derive(Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] @@ -5299,12 +5299,18 @@ impl Origin2d { } } +impl std::fmt::Debug for Origin2d { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + (self.x, self.y).fmt(f) + } +} + /// Origin of a copy to/from a texture. /// /// Corresponds to [WebGPU `GPUOrigin3D`]( /// https://gpuweb.github.io/gpuweb/#dictdef-gpuorigin3ddict). #[repr(C)] -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] +#[derive(Clone, Copy, PartialEq, Eq, Hash)] #[cfg_attr(feature = "trace", derive(Serialize))] #[cfg_attr(feature = "replay", derive(Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] @@ -5336,12 +5342,18 @@ impl Default for Origin3d { } } +impl std::fmt::Debug for Origin3d { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + (self.x, self.y, self.z).fmt(f) + } +} + /// Extent of a texture related operation. /// /// Corresponds to [WebGPU `GPUExtent3D`]( /// https://gpuweb.github.io/gpuweb/#dictdef-gpuextent3ddict). #[repr(C)] -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] +#[derive(Clone, Copy, PartialEq, Eq, Hash)] #[cfg_attr(feature = "trace", derive(Serialize))] #[cfg_attr(feature = "replay", derive(Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] @@ -5355,6 +5367,12 @@ pub struct Extent3d { pub depth_or_array_layers: u32, } +impl std::fmt::Debug for Extent3d { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + (self.width, self.height, self.depth_or_array_layers).fmt(f) + } +} + #[cfg(feature = "serde")] fn default_depth() -> u32 { 1 From 6c4128b4e7ba7696f014a04a87dfd1fd8ec31ddc Mon Sep 17 00:00:00 2001 From: Valaphee The Meerkat <32491319+valaphee@users.noreply.github.com> Date: Sat, 9 Dec 2023 23:56:09 +0100 Subject: [PATCH 4/4] [wgpu] correct doc for resolve query set (#4849) * Correct doc for resolve query set * Add note about wgpu::QUERY_SIZE --------- Co-authored-by: Andreas Reich --- wgpu/src/lib.rs | 50 ++++++++++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs index f5668881bb..48e7262bcc 100644 --- a/wgpu/src/lib.rs +++ b/wgpu/src/lib.rs @@ -3671,34 +3671,11 @@ impl CommandEncoder { let id = self.id.as_ref().unwrap(); DynContext::command_encoder_pop_debug_group(&*self.context, id, self.data.as_ref()); } -} - -/// [`Features::TIMESTAMP_QUERY`] must be enabled on the device in order to call these functions. -impl CommandEncoder { - /// Issue a timestamp command at this point in the queue. - /// The timestamp will be written to the specified query set, at the specified index. - /// - /// Must be multiplied by [`Queue::get_timestamp_period`] to get - /// the value in nanoseconds. Absolute values have no meaning, - /// but timestamps can be subtracted to get the time it takes - /// for a string of operations to complete. - pub fn write_timestamp(&mut self, query_set: &QuerySet, query_index: u32) { - DynContext::command_encoder_write_timestamp( - &*self.context, - self.id.as_ref().unwrap(), - self.data.as_mut(), - &query_set.id, - query_set.data.as_ref(), - query_index, - ) - } -} -/// [`Features::TIMESTAMP_QUERY`] or [`Features::PIPELINE_STATISTICS_QUERY`] must be enabled on the device in order to call these functions. -impl CommandEncoder { - /// Resolve a query set, writing the results into the supplied destination buffer. + /// Resolves a query set, writing the results into the supplied destination buffer. /// - /// Queries may be between 8 and 40 bytes each. See [`PipelineStatisticsTypes`] for more information. + /// Occlusion and timestamp queries are 8 bytes each (see [`crate::QUERY_SIZE`]). For pipeline statistics queries, + /// see [`PipelineStatisticsTypes`] for more information. pub fn resolve_query_set( &mut self, query_set: &QuerySet, @@ -3721,6 +3698,27 @@ impl CommandEncoder { } } +/// [`Features::TIMESTAMP_QUERY`] must be enabled on the device in order to call these functions. +impl CommandEncoder { + /// Issue a timestamp command at this point in the queue. + /// The timestamp will be written to the specified query set, at the specified index. + /// + /// Must be multiplied by [`Queue::get_timestamp_period`] to get + /// the value in nanoseconds. Absolute values have no meaning, + /// but timestamps can be subtracted to get the time it takes + /// for a string of operations to complete. + pub fn write_timestamp(&mut self, query_set: &QuerySet, query_index: u32) { + DynContext::command_encoder_write_timestamp( + &*self.context, + self.id.as_ref().unwrap(), + self.data.as_mut(), + &query_set.id, + query_set.data.as_ref(), + query_index, + ) + } +} + impl<'a> RenderPass<'a> { /// Sets the active bind group for a given bind group index. The bind group layout /// in the active pipeline when any `draw_*()` method is called must match the layout of