mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-25 16:24:24 +00:00
Skip mismatched epochs in the remove_abandoned check
This commit is contained in:
parent
180e3e3576
commit
089294fc51
@ -22,17 +22,17 @@ use std::mem;
|
||||
/// A struct that keeps lists of resources that are no longer needed by the user.
|
||||
#[derive(Debug, Default)]
|
||||
pub(super) struct SuspectedResources {
|
||||
pub(crate) buffers: Vec<id::Valid<id::BufferId>>,
|
||||
pub(crate) textures: Vec<id::Valid<id::TextureId>>,
|
||||
pub(crate) texture_views: Vec<id::Valid<id::TextureViewId>>,
|
||||
pub(crate) samplers: Vec<id::Valid<id::SamplerId>>,
|
||||
pub(crate) bind_groups: Vec<id::Valid<id::BindGroupId>>,
|
||||
pub(crate) compute_pipelines: Vec<id::Valid<id::ComputePipelineId>>,
|
||||
pub(crate) render_pipelines: Vec<id::Valid<id::RenderPipelineId>>,
|
||||
pub(crate) bind_group_layouts: Vec<id::Valid<id::BindGroupLayoutId>>,
|
||||
pub(crate) pipeline_layouts: Vec<Stored<id::PipelineLayoutId>>,
|
||||
pub(crate) render_bundles: Vec<id::Valid<id::RenderBundleId>>,
|
||||
pub(crate) query_sets: Vec<id::Valid<id::QuerySetId>>,
|
||||
pub(super) buffers: Vec<id::Valid<id::BufferId>>,
|
||||
pub(super) textures: Vec<id::Valid<id::TextureId>>,
|
||||
pub(super) texture_views: Vec<id::Valid<id::TextureViewId>>,
|
||||
pub(super) samplers: Vec<id::Valid<id::SamplerId>>,
|
||||
pub(super) bind_groups: Vec<id::Valid<id::BindGroupId>>,
|
||||
pub(super) compute_pipelines: Vec<id::Valid<id::ComputePipelineId>>,
|
||||
pub(super) render_pipelines: Vec<id::Valid<id::RenderPipelineId>>,
|
||||
pub(super) bind_group_layouts: Vec<id::Valid<id::BindGroupLayoutId>>,
|
||||
pub(super) pipeline_layouts: Vec<Stored<id::PipelineLayoutId>>,
|
||||
pub(super) render_bundles: Vec<id::Valid<id::RenderBundleId>>,
|
||||
pub(super) query_sets: Vec<id::Valid<id::QuerySetId>>,
|
||||
}
|
||||
|
||||
impl SuspectedResources {
|
||||
|
@ -235,10 +235,17 @@ impl<S: ResourceState> ResourceTracker<S> {
|
||||
let (index, epoch, backend) = id.0.unzip();
|
||||
debug_assert_eq!(backend, self.backend);
|
||||
match self.map.entry(index) {
|
||||
// This code explicitly ignores requests for IDs that are no longer valid,
|
||||
// i.e. corresponding to removed entries, or entries that got re-filled
|
||||
// with new elements (having different epochs).
|
||||
// This is needed because of the asynchronous nature of the device internals.
|
||||
// As such, by the time a resource is added to the suspected list, it may
|
||||
// already be fully removed from all the trackers (and be a stale ID).
|
||||
// see https://github.com/gfx-rs/wgpu/issues/1996
|
||||
Entry::Occupied(e) => {
|
||||
if e.get().ref_count.load() == 1 {
|
||||
let res = e.remove();
|
||||
assert_eq!(res.epoch, epoch, "Epoch mismatch for {:?}", id);
|
||||
// see https://github.com/gfx-rs/wgpu/issues/1996
|
||||
if e.get().epoch == epoch && e.get().ref_count.load() == 1 {
|
||||
e.remove();
|
||||
true
|
||||
} else {
|
||||
false
|
||||
|
Loading…
Reference in New Issue
Block a user