mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-25 08:13:27 +00:00
[hal, core] Introduce wgpu_hal::AtomicFenceValue
, and use it.
Introduce the new type alias `wgpu_hal::AtomicFenceValue`, which is the atomic version of `wgpu_hal::FenceValue`. Use this type alias in `wgpu_core`. Remove `as` conversions made unnecessary since we're not conflating `usize` with `u64` any more.
This commit is contained in:
parent
a47ed5dc1e
commit
2bc328c46f
@ -88,8 +88,7 @@ pub struct Device<A: HalApi> {
|
||||
label: String,
|
||||
|
||||
pub(crate) command_allocator: command::CommandAllocator<A>,
|
||||
//Note: The submission index here corresponds to the last submission that is done.
|
||||
pub(crate) active_submission_index: AtomicU64, //SubmissionIndex,
|
||||
pub(crate) active_submission_index: hal::AtomicFenceValue,
|
||||
// NOTE: if both are needed, the `snatchable_lock` must be consistently acquired before the
|
||||
// `fence` lock to avoid deadlocks.
|
||||
pub(crate) fence: RwLock<Option<A::Fence>>,
|
||||
|
@ -28,10 +28,7 @@ use std::{
|
||||
mem::{self, ManuallyDrop},
|
||||
ops::Range,
|
||||
ptr::NonNull,
|
||||
sync::{
|
||||
atomic::{AtomicUsize, Ordering},
|
||||
Arc, Weak,
|
||||
},
|
||||
sync::{atomic::Ordering, Arc, Weak},
|
||||
};
|
||||
|
||||
/// Information about the wgpu-core resource.
|
||||
@ -64,7 +61,7 @@ pub(crate) struct TrackingData {
|
||||
/// sequentially. Thus, when a queue submission completes, we know any
|
||||
/// resources used in that submission and any lower-numbered submissions are
|
||||
/// no longer in use by the GPU.
|
||||
submission_index: AtomicUsize,
|
||||
submission_index: hal::AtomicFenceValue,
|
||||
}
|
||||
|
||||
impl Drop for TrackingData {
|
||||
@ -78,7 +75,7 @@ impl TrackingData {
|
||||
Self {
|
||||
tracker_index: tracker_indices.alloc(),
|
||||
tracker_indices,
|
||||
submission_index: AtomicUsize::new(0),
|
||||
submission_index: hal::AtomicFenceValue::new(0),
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,12 +86,11 @@ impl TrackingData {
|
||||
/// Record that this resource will be used by the queue submission with the
|
||||
/// given index.
|
||||
pub(crate) fn use_at(&self, submit_index: SubmissionIndex) {
|
||||
self.submission_index
|
||||
.store(submit_index as _, Ordering::Release);
|
||||
self.submission_index.store(submit_index, Ordering::Release);
|
||||
}
|
||||
|
||||
pub(crate) fn submission_index(&self) -> SubmissionIndex {
|
||||
self.submission_index.load(Ordering::Acquire) as _
|
||||
self.submission_index.load(Ordering::Acquire)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -294,6 +294,7 @@ pub const QUERY_SIZE: wgt::BufferAddress = 8;
|
||||
pub type Label<'a> = Option<&'a str>;
|
||||
pub type MemoryRange = Range<wgt::BufferAddress>;
|
||||
pub type FenceValue = u64;
|
||||
pub type AtomicFenceValue = std::sync::atomic::AtomicU64;
|
||||
|
||||
/// Drop guard to signal wgpu-hal is no longer using an externally created object.
|
||||
pub type DropGuard = Box<dyn std::any::Any + Send + Sync>;
|
||||
|
Loading…
Reference in New Issue
Block a user