remove_abandoned fix (#4781)

* remove_abandoned fix

* Updated doc
This commit is contained in:
Mauro Gentile 2023-11-26 15:58:00 +01:00 committed by GitHub
parent 12ee31d6f9
commit 281a7aecd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 21 deletions

View File

@ -293,7 +293,7 @@ pub(crate) struct BufferTracker<A: HalApi> {
}
impl<A: HalApi> ResourceTracker<BufferId, Buffer<A>> for BufferTracker<A> {
/// Removes the buffer `id` from this tracker if it is otherwise unused.
/// Try to remove the buffer `id` from this tracker if it is otherwise unused.
///
/// A buffer is 'otherwise unused' when the only references to it are:
///
@ -308,8 +308,7 @@ impl<A: HalApi> ResourceTracker<BufferId, Buffer<A>> for BufferTracker<A> {
/// `triage_suspected` will remove 3), leaving 1) as the sole
/// remaining reference.
///
/// Return `true` if this tracker contained the buffer `id`. This
/// implies that we removed it.
/// Returns true if the resource was removed or if not existing in metadata.
///
/// [`Device::trackers`]: crate::device::Device
/// [`self.metadata`]: BufferTracker::metadata
@ -339,11 +338,11 @@ impl<A: HalApi> ResourceTracker<BufferId, Buffer<A>> for BufferTracker<A> {
id,
existing_ref_count
);
return false;
}
}
}
false
true
}
}

View File

@ -122,14 +122,7 @@ impl<A: HalApi, I: TypedId, T: Resource<I>> ResourceMetadata<A, I, T> {
/// existing tables. See `tracker_assert_in_bounds`.
#[inline(always)]
pub(super) unsafe fn get_ref_count_unchecked(&self, index: usize) -> usize {
unsafe {
Arc::strong_count(
self.resources
.get_unchecked(index)
.as_ref()
.unwrap_unchecked(),
)
}
unsafe { Arc::strong_count(self.get_resource_unchecked(index)) }
}
/// Returns an iterator over the resources owned by `self`.

View File

@ -78,10 +78,10 @@ pub(crate) struct StatelessTracker<A: HalApi, Id: TypedId, T: Resource<Id>> {
impl<A: HalApi, Id: TypedId, T: Resource<Id>> ResourceTracker<Id, T>
for StatelessTracker<A, Id, T>
{
/// Removes the given resource from the tracker iff we have the last reference to the
/// Try to remove the given resource from the tracker iff we have the last reference to the
/// resource and the epoch matches.
///
/// Returns true if the resource was removed.
/// Returns true if the resource was removed or if not existing in metadata.
///
/// If the ID is higher than the length of internal vectors,
/// false will be returned.
@ -113,11 +113,11 @@ impl<A: HalApi, Id: TypedId, T: Resource<Id>> ResourceTracker<Id, T>
id,
existing_ref_count
);
return false;
}
}
}
false
true
}
}

View File

@ -394,10 +394,10 @@ pub(crate) struct TextureTracker<A: HalApi> {
}
impl<A: HalApi> ResourceTracker<TextureId, Texture<A>> for TextureTracker<A> {
/// Removes the given resource from the tracker iff we have the last reference to the
/// Try to remove the given resource from the tracker iff we have the last reference to the
/// resource and the epoch matches.
///
/// Returns true if the resource was removed.
/// Returns true if the resource was removed or if not existing in metadata.
///
/// If the ID is higher than the length of internal vectors,
/// false will be returned.
@ -428,11 +428,11 @@ impl<A: HalApi> ResourceTracker<TextureId, Texture<A>> for TextureTracker<A> {
id,
existing_ref_count
);
return false;
}
}
}
false
true
}
}