Skip to content
Open
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
7 changes: 4 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ libfuzzer-sys = ">0.4.0,<=0.4.7"
libloading = "0.8"
libm = { version = "0.2.6", default-features = false }
libtest-mimic = "0.8"
# Minimum version supported by parking_lot 0.12.3
lock_api = { version = "0.4.6", default-features = false }
log = "0.4.29"
macro_rules_attribute = "0.2"
nanoserde = "0.2"
Expand Down Expand Up @@ -196,6 +198,8 @@ serde_json = "1.0.143"
serde = { version = "1.0.225", default-features = false }
shell-words = "1"
smallvec = "1.14"
# NOTE: `crossbeam-deque` currently relies on this version of spin
spin = { version = "0.9.8", default-features = false }
spirv = "0.4"
static_assertions = "1.1"
strum = { version = "0.28", default-features = false, features = ["derive"] }
Expand Down
4 changes: 1 addition & 3 deletions tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ exhaust.workspace = true
futures-lite.workspace = true
libtest-mimic.workspace = true
log.workspace = true
parking_lot = { workspace = true, features = ["deadlock_detection"] }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This dependency was previously included in triplicate for wasm, not wasm, and for tests. Moved for the sake of clarity.

png.workspace = true
pollster.workspace = true
profiling.workspace = true
Expand All @@ -81,7 +82,6 @@ half = { workspace = true, features = ["bytemuck", "std"] }
itertools.workspace = true
image.workspace = true
nanorand.workspace = true
parking_lot.workspace = true
strum = { workspace = true, features = ["derive"] }
trybuild.workspace = true

Expand All @@ -90,7 +90,6 @@ trybuild.workspace = true
# Cargo-metadata doesn't compile on wasm due to old cargo-util-schemas dependency.
cargo_metadata.workspace = true
env_logger.workspace = true
parking_lot = { workspace = true, features = ["deadlock_detection"] }
ureq.workspace = true

[target.'cfg(not(any(target_arch = "wasm32", miri)))'.dependencies]
Expand All @@ -102,7 +101,6 @@ console_log.workspace = true
wasm-bindgen.workspace = true
wasm-bindgen-futures.workspace = true
web-sys = { workspace = true }
parking_lot = { workspace = true, features = ["deadlock_detection"] }

# Webassembly Dev Dependencies
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
Expand Down
5 changes: 3 additions & 2 deletions tests/src/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use std::{future::Future, pin::Pin};

use parking_lot::Mutex;
use wgpu_types::sync::Mutex;

use crate::{
config::GpuTestConfiguration, params::TestInfo, report::AdapterReport, run::execute_test,
Expand Down Expand Up @@ -87,7 +87,8 @@ impl NativeTest {
}

#[doc(hidden)]
pub static TEST_LIST: Mutex<Vec<crate::GpuTestConfiguration>> = Mutex::new(Vec::new());
pub static TEST_LIST: Mutex<Vec<crate::GpuTestConfiguration>> =
Mutex::const_new(wgpu_types::sync::RawMutex::new(), Vec::new());

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lock_api only made Mutex::new const in the current version, but it seems unnecessary to mandate a higher version when we only need to use this API in a couple of locations.


/// Return value for the main function.
pub type MainResult = anyhow::Result<()>;
Expand Down
2 changes: 1 addition & 1 deletion tests/tests/wgpu-gpu/regression/issue_4024.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::sync::Arc;

use parking_lot::Mutex;
use wgpu_test::{gpu_test, GpuTestConfiguration, GpuTestInitializer, TestParameters};
use wgpu_types::sync::Mutex;

use wgpu::*;

Expand Down
2 changes: 1 addition & 1 deletion tests/tests/wgpu-validation/api/error_scopes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{
sync::Arc,
};

use parking_lot::Mutex;
use wgpu_types::sync::Mutex;

const ERR: &str = "Buffer size 9223372036854775808 is greater than the maximum buffer size";
fn raise_validation_error(device: &wgpu::Device) {
Expand Down
1 change: 0 additions & 1 deletion wgpu-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ indexmap.workspace = true
log.workspace = true
macro_rules_attribute = { workspace = true, optional = true }
once_cell = { workspace = true, features = ["std"] }
parking_lot.workspace = true
profiling = { workspace = true, default-features = false }
raw-window-handle.workspace = true
ron = { workspace = true, optional = true }
Expand Down
2 changes: 1 addition & 1 deletion wgpu-core/src/command/compute.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use parking_lot::Mutex;
use thiserror::Error;
use wgpu_types::sync::Mutex;
use wgt::{
error::{ErrorType, WebGpuError},
BufferAddress, DynamicOffset,
Expand Down
2 changes: 1 addition & 1 deletion wgpu-core/src/command/render.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use alloc::{borrow::Cow, sync::Arc, vec::Vec};
use core::{convert::Infallible, fmt, num::NonZeroU32, ops::Range, str};
use parking_lot::Mutex;
use smallvec::SmallVec;
use wgpu_types::sync::Mutex;

use arrayvec::ArrayVec;
use thiserror::Error;
Expand Down
2 changes: 1 addition & 1 deletion wgpu-core/src/device/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,7 @@ impl Global {
// no lock rank here because only one thread should be using compute pass
// and it's only used by id variants of compute pass methods on global
// so no deadlock (or concurrent lock) should happen in practise
let id = fid.assign(Arc::new(parking_lot::Mutex::new(*render_bundle_encoder)));
let id = fid.assign(Arc::new(wgt::sync::Mutex::new(*render_bundle_encoder)));

(id, error)
}
Expand Down
2 changes: 1 addition & 1 deletion wgpu-core/src/hub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ use crate::{
},
};

use parking_lot::Mutex;
use wgpu_types::sync::Mutex;

#[derive(Debug, PartialEq, Eq)]
pub struct HubReport {
Expand Down
4 changes: 2 additions & 2 deletions wgpu-core/src/lock/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
//!
//! Otherwise, `wgpu-core` uses the [`vanilla`] module's locks.
//!
//! [`Mutex`]: parking_lot::Mutex
//! [`RwLock`]: parking_lot::RwLock
//! [`Mutex`]: wgpu_types::sync::Mutex
//! [`RwLock`]: wgpu_types::sync::RwLock
//! [`SnatchLock`]: crate::snatch::SnatchLock

pub mod rank;
Expand Down
24 changes: 12 additions & 12 deletions wgpu-core/src/lock/observing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +42,30 @@ pub type RankData = Option<HeldLock>;

/// A `Mutex` instrumented for lock acquisition order observation.
///
/// This is just a wrapper around a [`parking_lot::Mutex`], along with
/// This is just a wrapper around a [`wgpu_types::sync::Mutex`], along with
/// its rank in the `wgpu_core` lock ordering.
///
/// For details, see [the module documentation][self].
pub struct Mutex<T> {
inner: parking_lot::Mutex<T>,
inner: wgpu_types::sync::Mutex<T>,
rank: LockRank,
}

/// A guard produced by locking [`Mutex`].
///
/// This is just a wrapper around a [`parking_lot::MutexGuard`], along
/// This is just a wrapper around a [`wgpu_types::sync::MutexGuard`], along
/// with the state needed to track lock acquisition.
///
/// For details, see [the module documentation][self].
pub struct MutexGuard<'a, T> {
inner: parking_lot::MutexGuard<'a, T>,
inner: wgpu_types::sync::MutexGuard<'a, T>,
_state: LockStateGuard,
}

impl<T> Mutex<T> {
pub fn new(rank: LockRank, value: T) -> Mutex<T> {
Mutex {
inner: parking_lot::Mutex::new(value),
inner: wgpu_types::sync::Mutex::new(value),
rank,
}
}
Expand Down Expand Up @@ -106,41 +106,41 @@ impl<T: core::fmt::Debug> core::fmt::Debug for Mutex<T> {

/// An `RwLock` instrumented for lock acquisition order observation.
///
/// This is just a wrapper around a [`parking_lot::RwLock`], along with
/// This is just a wrapper around a [`wgpu_types::sync::RwLock`], along with
/// its rank in the `wgpu_core` lock ordering.
///
/// For details, see [the module documentation][self].
pub struct RwLock<T> {
inner: parking_lot::RwLock<T>,
inner: wgpu_types::sync::RwLock<T>,
rank: LockRank,
}

/// A read guard produced by locking [`RwLock`] for reading.
///
/// This is just a wrapper around a [`parking_lot::RwLockReadGuard`], along with
/// This is just a wrapper around a [`wgpu_types::sync::RwLockReadGuard`], along with
/// the state needed to track lock acquisition.
///
/// For details, see [the module documentation][self].
pub struct RwLockReadGuard<'a, T> {
inner: parking_lot::RwLockReadGuard<'a, T>,
inner: wgpu_types::sync::RwLockReadGuard<'a, T>,
_state: LockStateGuard,
}

/// A write guard produced by locking [`RwLock`] for writing.
///
/// This is just a wrapper around a [`parking_lot::RwLockWriteGuard`], along
/// This is just a wrapper around a [`wgpu_types::sync::RwLockWriteGuard`], along
/// with the state needed to track lock acquisition.
///
/// For details, see [the module documentation][self].
pub struct RwLockWriteGuard<'a, T> {
inner: parking_lot::RwLockWriteGuard<'a, T>,
inner: wgpu_types::sync::RwLockWriteGuard<'a, T>,
_state: LockStateGuard,
}

impl<T> RwLock<T> {
pub fn new(rank: LockRank, value: T) -> RwLock<T> {
RwLock {
inner: parking_lot::RwLock::new(value),
inner: wgpu_types::sync::RwLock::new(value),
rank,
}
}
Expand Down
4 changes: 2 additions & 2 deletions wgpu-core/src/lock/rank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
/// TODO(<https://github.com/gfx-rs/wgpu/issues/5572>): Resolve invalid
/// acquisitions of DEVICE_COMMAND_INDICES followed by COMMAND_BUFFER_DATA.
///
/// [`Mutex`]: parking_lot::Mutex
/// [`RwLock`]: parking_lot::RwLock
/// [`Mutex`]: wgpu_types::sync::Mutex
/// [`RwLock`]: wgpu_types::sync::RwLock
/// [`SnatchLock`]: crate::snatch::SnatchLock
/// [`CommandBuffer::data`]: crate::command::CommandBuffer::data
#[derive(Debug, Copy, Clone)]
Expand Down
24 changes: 12 additions & 12 deletions wgpu-core/src/lock/ranked.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,23 @@ pub use LockState as RankData;

/// A `Mutex` instrumented for deadlock prevention.
///
/// This is just a wrapper around a [`parking_lot::Mutex`], along with
/// This is just a wrapper around a [`wgpu_types::sync::Mutex`], along with
/// its rank in the `wgpu_core` lock ordering.
///
/// For details, see [the module documentation][self].
pub struct Mutex<T> {
inner: parking_lot::Mutex<T>,
inner: wgpu_types::sync::Mutex<T>,
rank: LockRank,
}

/// A guard produced by locking [`Mutex`].
///
/// This is just a wrapper around a [`parking_lot::MutexGuard`], along
/// This is just a wrapper around a [`wgpu_types::sync::MutexGuard`], along
/// with the state needed to track lock acquisition.
///
/// For details, see [the module documentation][self].
pub struct MutexGuard<'a, T> {
inner: parking_lot::MutexGuard<'a, T>,
inner: wgpu_types::sync::MutexGuard<'a, T>,
#[cfg_attr(not(miri), expect(unused))] // but `Drop` has important side effects
saved: LockStateGuard,
}
Expand Down Expand Up @@ -216,7 +216,7 @@ fn release(saved: LockState) {
impl<T> Mutex<T> {
pub fn new(rank: LockRank, value: T) -> Mutex<T> {
Mutex {
inner: parking_lot::Mutex::new(value),
inner: wgpu_types::sync::Mutex::new(value),
rank,
}
}
Expand Down Expand Up @@ -257,41 +257,41 @@ impl<T: fmt::Debug> fmt::Debug for Mutex<T> {

/// An `RwLock` instrumented for deadlock prevention.
///
/// This is just a wrapper around a [`parking_lot::RwLock`], along with
/// This is just a wrapper around a [`wgpu_types::sync::RwLock`], along with
/// its rank in the `wgpu_core` lock ordering.
///
/// For details, see [the module documentation][self].
pub struct RwLock<T> {
inner: parking_lot::RwLock<T>,
inner: wgpu_types::sync::RwLock<T>,
rank: LockRank,
}

/// A read guard produced by locking [`RwLock`] for reading.
///
/// This is just a wrapper around a [`parking_lot::RwLockReadGuard`], along with
/// This is just a wrapper around a [`wgpu_types::sync::RwLockReadGuard`], along with
/// the state needed to track lock acquisition.
///
/// For details, see [the module documentation][self].
pub struct RwLockReadGuard<'a, T> {
inner: parking_lot::RwLockReadGuard<'a, T>,
inner: wgpu_types::sync::RwLockReadGuard<'a, T>,
saved: LockStateGuard,
}

/// A write guard produced by locking [`RwLock`] for writing.
///
/// This is just a wrapper around a [`parking_lot::RwLockWriteGuard`], along
/// This is just a wrapper around a [`wgpu_types::sync::RwLockWriteGuard`], along
/// with the state needed to track lock acquisition.
///
/// For details, see [the module documentation][self].
pub struct RwLockWriteGuard<'a, T> {
inner: parking_lot::RwLockWriteGuard<'a, T>,
inner: wgpu_types::sync::RwLockWriteGuard<'a, T>,
saved: LockStateGuard,
}

impl<T> RwLock<T> {
pub fn new(rank: LockRank, value: T) -> RwLock<T> {
RwLock {
inner: parking_lot::RwLock::new(value),
inner: wgpu_types::sync::RwLock::new(value),
rank,
}
}
Expand Down
Loading
Loading