Skip to content

Commit 59e79c0

Browse files
committed
[wgpu-core] Document and improve naming in PendingWrites.
1 parent 60487f5 commit 59e79c0

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

wgpu-core/src/device/queue.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,18 +188,25 @@ impl<A: HalApi> EncoderInFlight<A> {
188188
#[derive(Debug)]
189189
pub(crate) struct PendingWrites<A: HalApi> {
190190
pub command_encoder: A::CommandEncoder,
191-
pub is_active: bool,
191+
192+
/// True if `command_encoder` is in the "recording" state, as
193+
/// described in the docs for the [`wgpu_hal::CommandEncoder`]
194+
/// trait.
195+
pub is_recording: bool,
196+
192197
pub temp_resources: Vec<TempResource<A>>,
193198
pub dst_buffers: FastHashMap<id::BufferId, Arc<Buffer<A>>>,
194199
pub dst_textures: FastHashMap<id::TextureId, Arc<Texture<A>>>,
200+
201+
/// All command buffers allocated from `command_encoder`.
195202
pub executing_command_buffers: Vec<A::CommandBuffer>,
196203
}
197204

198205
impl<A: HalApi> PendingWrites<A> {
199206
pub fn new(command_encoder: A::CommandEncoder) -> Self {
200207
Self {
201208
command_encoder,
202-
is_active: false,
209+
is_recording: false,
203210
temp_resources: Vec::new(),
204211
dst_buffers: FastHashMap::default(),
205212
dst_textures: FastHashMap::default(),
@@ -209,7 +216,7 @@ impl<A: HalApi> PendingWrites<A> {
209216

210217
pub fn dispose(mut self, device: &A::Device) {
211218
unsafe {
212-
if self.is_active {
219+
if self.is_recording {
213220
self.command_encoder.discard_encoding();
214221
}
215222
self.command_encoder
@@ -232,9 +239,9 @@ impl<A: HalApi> PendingWrites<A> {
232239
fn pre_submit(&mut self) -> Result<Option<&A::CommandBuffer>, DeviceError> {
233240
self.dst_buffers.clear();
234241
self.dst_textures.clear();
235-
if self.is_active {
242+
if self.is_recording {
236243
let cmd_buf = unsafe { self.command_encoder.end_encoding()? };
237-
self.is_active = false;
244+
self.is_recording = false;
238245
self.executing_command_buffers.push(cmd_buf);
239246

240247
return Ok(self.executing_command_buffers.last());
@@ -262,23 +269,23 @@ impl<A: HalApi> PendingWrites<A> {
262269
}
263270

264271
pub fn activate(&mut self) -> &mut A::CommandEncoder {
265-
if !self.is_active {
272+
if !self.is_recording {
266273
unsafe {
267274
self.command_encoder
268275
.begin_encoding(Some("(wgpu internal) PendingWrites"))
269276
.unwrap();
270277
}
271-
self.is_active = true;
278+
self.is_recording = true;
272279
}
273280
&mut self.command_encoder
274281
}
275282

276283
pub fn deactivate(&mut self) {
277-
if self.is_active {
284+
if self.is_recording {
278285
unsafe {
279286
self.command_encoder.discard_encoding();
280287
}
281-
self.is_active = false;
288+
self.is_recording = false;
282289
}
283290
}
284291
}

0 commit comments

Comments
 (0)