Change the order to suspect temporary resources earlier

This commit is contained in:
Dzmitry Malyshau 2021-06-18 02:45:53 -04:00
parent 63019893df
commit 80ab18404e
5 changed files with 6 additions and 11 deletions

View File

@ -223,7 +223,6 @@ impl<A: hal::Api> LifetimeTracker<A> {
pub fn track_submission(
&mut self,
index: SubmissionIndex,
new_suspects: &SuspectedResources,
temp_resources: impl Iterator<Item = TempResource<A>>,
encoders: Vec<EncoderInFlight<A>>,
) {
@ -245,7 +244,6 @@ impl<A: hal::Api> LifetimeTracker<A> {
.drain(..)
.map(|stored| stored.value),
);
self.suspected_resources.extend(new_suspects);
self.active.alloc().init(ActiveSubmission {
index,
@ -314,12 +312,15 @@ impl<A: HalApi> LifetimeTracker<A> {
pub(super) fn triage_suspected<G: GlobalIdentityHandlerFactory>(
&mut self,
hub: &Hub<A, G>,
new_suspects: &SuspectedResources,
trackers: &Mutex<TrackerSet>,
#[cfg(feature = "trace")] trace: Option<&Mutex<trace::Trace>>,
token: &mut Token<super::Device<A>>,
) {
profiling::scope!("triage_suspected");
self.suspected_resources.extend(new_suspects);
if !self.suspected_resources.render_bundles.is_empty() {
let (mut guard, _) = hub.render_bundles.write(token);
let mut trackers = trackers.lock();

View File

@ -360,6 +360,7 @@ impl<A: HalApi> Device<A> {
life_tracker.triage_suspected(
hub,
&self.temp_suspected,
&self.trackers,
#[cfg(feature = "trace")]
self.trace.as_ref(),
@ -4159,6 +4160,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let device = device_guard.get(device_id).map_err(|_| InvalidDevice)?;
device.lock_life(&mut token).triage_suspected(
&hub,
&device.temp_suspected,
&device.trackers,
#[cfg(feature = "trace")]
None,

View File

@ -805,7 +805,6 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
}
super::Device::lock_life_internal(&device.life_tracker, &mut token).track_submission(
submit_index,
&device.temp_suspected,
device.pending_writes.temp_resources.drain(..),
active_executions,
);

View File

@ -277,13 +277,6 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let view = &mut view_guard[view_id.value];
let _ = view.life_guard.ref_count.take();
/*
let (view_maybe, _) = hub.texture_views.unregister(view_id.value.0, &mut token);
drop(view_id); // contains the ref count
let view = view_maybe.ok_or(SwapChainError::Invalid)?;
if view.life_guard.ref_count.unwrap().load() != 1 {
return Err(SwapChainError::StillReferenced);
}*/
suf_texture
};

View File

@ -250,7 +250,7 @@ impl<S: ResourceState> ResourceTracker<S> {
Entry::Occupied(e) => {
if e.get().ref_count.load() == 1 {
let res = e.remove();
assert_eq!(res.epoch, epoch);
assert_eq!(res.epoch, epoch, "Epoch mismatch for {:?}", id);
true
} else {
false