@@ -86,6 +86,19 @@ pub struct WrappedSubmissionIndex {
86
86
pub index : SubmissionIndex ,
87
87
}
88
88
89
+ /// A texture or buffer to be freed soon.
90
+ ///
91
+ /// This is just a tagged raw texture or buffer, generally about to be added to
92
+ /// some other more specific container like:
93
+ ///
94
+ /// - `PendingWrites::temp_resources`: resources used by queue writes and
95
+ /// unmaps, waiting to be folded in with the next queue submission
96
+ ///
97
+ /// - `ActiveSubmission::last_resources`: temporary resources used by a queue
98
+ /// submission, to be freed when it completes
99
+ ///
100
+ /// - `LifetimeTracker::free_resources`: resources to be freed in the next
101
+ /// `maintain` call, no longer used anywhere
89
102
#[ derive( Debug ) ]
90
103
pub enum TempResource < A : hal:: Api > {
91
104
Buffer ( A :: Buffer ) ,
@@ -105,6 +118,19 @@ impl<A: hal::Api> EncoderInFlight<A> {
105
118
}
106
119
}
107
120
121
+ /// Writes made directly on the device or queue, not as part of a wgpu command buffer.
122
+ ///
123
+ /// Operations like `buffer_unmap`, `queue_write_buffer`, and
124
+ /// `queue_write_texture` need to copy data to the GPU. This must be
125
+ /// done by encoding and submitting commands at the hal level, but these
126
+ /// operations are not associated with any specific wgpu command buffer.
127
+ ///
128
+ /// Instead, `Device::pending_writes` owns one of these values, which has its
129
+ /// own hal command encoder and resource lists. The commands accumulated here
130
+ /// are automatically submitted to the queue the next time the user submits a
131
+ /// wgpu command buffer, ahead of the user's commands.
132
+ ///
133
+ /// All uses of [`StagingBuffer`]s end up here.
108
134
#[ derive( Debug ) ]
109
135
pub ( crate ) struct PendingWrites < A : hal:: Api > {
110
136
pub command_encoder : A :: CommandEncoder ,
@@ -1082,6 +1108,8 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
1082
1108
Err ( WaitIdleError :: WrongSubmissionIndex ( ..) ) => unreachable ! ( ) ,
1083
1109
} ;
1084
1110
1111
+ // pending_write_resources has been drained, so it's empty, but we
1112
+ // want to retain its heap allocation.
1085
1113
device. pending_writes . temp_resources = pending_write_resources;
1086
1114
device. temp_suspected . clear ( ) ;
1087
1115
device. lock_life ( & mut token) . post_submit ( ) ;
0 commit comments