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

Fix incorrect memory usage stats for destroyed on-creation-mapped buffers #1963

Merged
merged 1 commit into from
Apr 25, 2023
Merged
Changes from all 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
13 changes: 9 additions & 4 deletions crates/re_renderer/src/wgpu_resources/dynamic_resource_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@ where
self.current_frame_index = frame_index;
let state = self.state.get_mut();

let update_stats = |creation_desc: &Desc| {
self.total_resource_size_in_bytes.fetch_sub(
creation_desc.resource_size_in_bytes(),
std::sync::atomic::Ordering::Relaxed,
);
};

// Throw out any resources that we haven't reclaimed last frame.
for (desc, resources) in state.last_frame_deallocated.drain() {
re_log::trace!(
Expand All @@ -160,11 +167,8 @@ where
debug_assert!(false, "a resource was marked as destroyed last frame that we no longer kept track of");
continue;
};
update_stats(&desc);
on_destroy_resource(&removed_resource);
self.total_resource_size_in_bytes.fetch_sub(
desc.resource_size_in_bytes(),
std::sync::atomic::Ordering::Relaxed,
);
}
}

Expand All @@ -184,6 +188,7 @@ where
.push(resource.handle);
true
} else {
update_stats(&resource.creation_desc);
on_destroy_resource(&resource.inner);
false
}
Expand Down