Skip to content

Commit 7e83137

Browse files
Apply suggestions from code review
Co-authored-by: Andy Leiserson <aleiserson@mozilla.com>
1 parent b4696d2 commit 7e83137

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

wgpu-core/src/device/queue.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ impl WebGpuError for QueueSubmitError {
601601
/// - [`Queue::submit`] just submits user-constructed [`CommandBuffer`]s.
602602
///
603603
/// - [`Queue::prepare_surface_texture_for_present`] examines the surface
604-
/// texture being presented, and submit deferred initialization commands and
604+
/// texture being presented, and submits deferred initialization commands and
605605
/// barriers to get it ready.
606606
///
607607
/// - [`Queue::flush_writes_for_buffer`] and [`Queue::flush_pending_writes`]
@@ -637,7 +637,7 @@ pub(crate) struct PendingSubmission<'a> {
637637

638638
/// Surface textures referenced by command buffers in this submission.
639639
///
640-
/// These need to be passed to the [`wgpu_hal::Queue::submit`], which
640+
/// These need to be passed to [`wgpu_hal::Queue::submit`], which
641641
/// requires that the list contains no duplicates, so we store them in a
642642
/// `HashMap` keyed by `SurfaceTexture` address.
643643
surface_textures: FastHashMap<*const Texture, Arc<Texture>>,

wgpu-core/src/device/resource.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -669,9 +669,11 @@ impl Device {
669669
/// Note that a `false` result here does *not* guarantee that no further activity will
670670
/// occur on the `Device`. A [`Device`] can be marked invalid at any time, even while
671671
/// locks are held, meaning that operations begun before the `Device` was marked
672-
/// invalid will still generally run to completion. This is simply a consequence of
673-
/// making [`Device::valid`] an `AtomicBool`, rather than an ordinary `bool` field
674-
/// protected by the same locks that all other operations acquire.
672+
/// invalid will still generally run to completion. This is a consequence of
673+
/// making [`Device::valid`] an `AtomicBool`. It could be avoided by making
674+
/// [`Device::valid`] an ordinary `bool` field protected by the same locks that
675+
/// all other operations acquire, but we use an `AtomicBool` because there
676+
/// are many device validity checks and we want those to be cheap.
675677
pub fn is_valid(&self) -> bool {
676678
self.valid.load(Ordering::Acquire)
677679
}
@@ -916,7 +918,7 @@ impl Device {
916918
// However, checking device validity for this purpose is tricky. A device can be
917919
// marked invalid at any time, regardless of what locks are held. This means that,
918920
// even though queue submission does check device validity at the start (in
919-
// `Queue::allocate_submission`), the submission will proceed even if the the
921+
// `Queue::allocate_submission`), the submission will proceed even if the
920922
// device gets marked invalid after that check. Thus, other threads can observe
921923
// the queue becoming non-empty even after they have observed the device to be
922924
// invalid.

0 commit comments

Comments
 (0)