Skip to content

Commit

Permalink
fixup! [hal] Document Api::Fence, its users, and its Vulkan impl.
Browse files Browse the repository at this point in the history
Rename `wgpu_hal::vulkan::Fence::check_active` argument to
`last_completed`, and explain better its rationale.
  • Loading branch information
jimblandy committed Apr 27, 2024
1 parent 5ba9f01 commit 79925d1
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions wgpu-hal/src/vulkan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -611,24 +611,25 @@ pub enum Fence {
impl Fence {
/// Return the highest [`FenceValue`] among the signalled fences in `active`.
///
/// As an optimization, assume that the returned value should be at least
/// `max_value`, and don't bother checking fences whose values are less than
/// that.
/// As an optimization, assume that we already know that the fence has
/// reached `last_completed`, and don't bother checking fences whose values
/// are less than that: those fences remain in the `active` array only
/// because we haven't called `maintain` yet to clean them up.
///
/// [`FenceValue`]: crate::FenceValue
fn check_active(
device: &ash::Device,
mut max_value: crate::FenceValue,
mut last_completed: crate::FenceValue,
active: &[(crate::FenceValue, vk::Fence)],
) -> Result<crate::FenceValue, crate::DeviceError> {
for &(value, raw) in active.iter() {
unsafe {
if value > max_value && device.get_fence_status(raw)? {
max_value = value;
if value > last_completed && device.get_fence_status(raw)? {
last_completed = value;
}
}
}
Ok(max_value)
Ok(last_completed)
}

/// Return the highest signalled [`FenceValue`] for `self`.
Expand Down

0 comments on commit 79925d1

Please sign in to comment.