Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove_abandoned fix #4781

Merged
merged 3 commits into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions wgpu-core/src/track/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
///
Expand All @@ -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 exiting in metadata.
gents83 marked this conversation as resolved.
Show resolved Hide resolved
///
/// [`Device::trackers`]: crate::device::Device
/// [`self.metadata`]: BufferTracker::metadata
Expand Down Expand Up @@ -339,11 +338,11 @@ impl<A: HalApi> ResourceTracker<BufferId, Buffer<A>> for BufferTracker<A> {
id,
existing_ref_count
);
return false;
}
}
}

false
true
}
}

Expand Down
9 changes: 1 addition & 8 deletions wgpu-core/src/track/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
8 changes: 4 additions & 4 deletions wgpu-core/src/track/stateless.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 exiting in metadata.
///
/// If the ID is higher than the length of internal vectors,
/// false will be returned.
Expand Down Expand Up @@ -113,11 +113,11 @@ impl<A: HalApi, Id: TypedId, T: Resource<Id>> ResourceTracker<Id, T>
id,
existing_ref_count
);
return false;
}
}
}

false
true
}
}

Expand Down
8 changes: 4 additions & 4 deletions wgpu-core/src/track/texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 exiting in metadata.
///
/// If the ID is higher than the length of internal vectors,
/// false will be returned.
Expand Down Expand Up @@ -428,11 +428,11 @@ impl<A: HalApi> ResourceTracker<TextureId, Texture<A>> for TextureTracker<A> {
id,
existing_ref_count
);
return false;
}
}
}

false
true
}
}

Expand Down
Loading