@@ -62,6 +62,17 @@ use core::sync::atomic::AtomicU64;
62
62
#[ cfg( not( supports_64bit_atomics) ) ]
63
63
use portable_atomic:: AtomicU64 ;
64
64
65
+ pub ( crate ) struct CommandIndices {
66
+ /// The index of the last command submission that was attempted.
67
+ ///
68
+ /// Note that `fence` may never be signalled with this value, if the command
69
+ /// submission failed. If you need to wait for everything running on a
70
+ /// `Queue` to complete, wait for [`last_successful_submission_index`].
71
+ ///
72
+ /// [`last_successful_submission_index`]: Device::last_successful_submission_index
73
+ pub ( crate ) active_submission_index : hal:: FenceValue ,
74
+ }
75
+
65
76
/// Structure describing a logical device. Some members are internally mutable,
66
77
/// stored behind mutexes.
67
78
pub struct Device {
@@ -74,14 +85,7 @@ pub struct Device {
74
85
75
86
pub ( crate ) command_allocator : command:: CommandAllocator ,
76
87
77
- /// The index of the last command submission that was attempted.
78
- ///
79
- /// Note that `fence` may never be signalled with this value, if the command
80
- /// submission failed. If you need to wait for everything running on a
81
- /// `Queue` to complete, wait for [`last_successful_submission_index`].
82
- ///
83
- /// [`last_successful_submission_index`]: Device::last_successful_submission_index
84
- pub ( crate ) active_submission_index : hal:: AtomicFenceValue ,
88
+ pub ( crate ) command_indices : RwLock < CommandIndices > ,
85
89
86
90
/// The index of the last successful submission to this device's
87
91
/// [`hal::Queue`].
@@ -91,7 +95,7 @@ pub struct Device {
91
95
/// so waiting for this value won't hang waiting for work that was never
92
96
/// submitted.
93
97
///
94
- /// [`active_submission_index`]: Device ::active_submission_index
98
+ /// [`active_submission_index`]: CommandIndices ::active_submission_index
95
99
pub ( crate ) last_successful_submission_index : hal:: AtomicFenceValue ,
96
100
97
101
// NOTE: if both are needed, the `snatchable_lock` must be consistently acquired before the
@@ -276,7 +280,13 @@ impl Device {
276
280
zero_buffer : ManuallyDrop :: new ( zero_buffer) ,
277
281
label : desc. label . to_string ( ) ,
278
282
command_allocator,
279
- active_submission_index : AtomicU64 :: new ( 0 ) ,
283
+ command_indices : RwLock :: new (
284
+ rank:: DEVICE_COMMAND_INDICES ,
285
+ CommandIndices {
286
+ active_submission_index : 0 ,
287
+ // By starting at one, we can put the result in a NonZeroU64.
288
+ } ,
289
+ ) ,
280
290
last_successful_submission_index : AtomicU64 :: new ( 0 ) ,
281
291
fence : RwLock :: new ( rank:: DEVICE_FENCE , ManuallyDrop :: new ( fence) ) ,
282
292
snatchable_lock : unsafe { SnatchLock :: new ( rank:: DEVICE_SNATCHABLE_LOCK ) } ,
0 commit comments