Skip to content

Commit 4f77012

Browse files
committedApr 24, 2024·
cleanup weak ref to bind groups
1 parent fe2a633 commit 4f77012

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
 

‎wgpu-core/src/device/life.rs

+10
Original file line numberDiff line numberDiff line change
@@ -545,13 +545,17 @@ impl<A: HalApi> LifetimeTracker<A> {
545545
&mut trackers.bind_groups,
546546
|maps| &mut maps.bind_groups,
547547
);
548+
let mut used_buffers = vec![];
549+
let mut used_textures = vec![];
548550
removed_resource.drain(..).for_each(|bind_group| {
549551
for v in bind_group.used.buffers.drain_resources() {
552+
used_buffers.push(v.clone());
550553
self.suspected_resources
551554
.buffers
552555
.insert(v.as_info().tracker_index(), v);
553556
}
554557
for v in bind_group.used.textures.drain_resources() {
558+
used_textures.push(v.clone());
555559
self.suspected_resources
556560
.textures
557561
.insert(v.as_info().tracker_index(), v);
@@ -572,6 +576,12 @@ impl<A: HalApi> LifetimeTracker<A> {
572576
bind_group.layout.clone(),
573577
);
574578
});
579+
for b in used_buffers {
580+
b.bind_groups.lock().retain(|weak| weak.strong_count() > 0);
581+
}
582+
for t in used_textures {
583+
t.bind_groups.lock().retain(|weak| weak.strong_count() > 0);
584+
}
575585
self
576586
}
577587

0 commit comments

Comments
 (0)