Skip to content

Commit

Permalink
move trim outside of lock
Browse files Browse the repository at this point in the history
  • Loading branch information
martty committed Jan 16, 2024
1 parent 0c7448d commit ac0a21d
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/DeviceFrameResource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,18 @@ namespace vuk {
}

DeviceFrameResource& DeviceSuperFrameResource::get_next_frame() {
// trim here, outside of lock, to prevent deadlocking, as trim may release memory to the superframe
{
auto& trim_frame = impl->frames[impl->frame_counter % frames_in_flight];
if (direct) {
if (trim_frame.construction_frame % 16 == 0) {
trim_frame.impl->linear_cpu_only.trim();
trim_frame.impl->linear_cpu_gpu.trim();
trim_frame.impl->linear_gpu_cpu.trim();
trim_frame.impl->linear_gpu_only.trim();
}
}
}
std::unique_lock _s(impl->new_frame_mutex);

impl->frame_counter++;
Expand Down Expand Up @@ -866,12 +878,6 @@ namespace vuk {
f.cmdpools_to_free.clear();
f.ds_pools.clear();
if (direct) {
if (frame.construction_frame % 16 == 0) {
f.linear_cpu_only.trim();
f.linear_cpu_gpu.trim();
f.linear_gpu_cpu.trim();
f.linear_gpu_only.trim();
}
f.linear_cpu_only.reset();
f.linear_cpu_gpu.reset();
f.linear_gpu_cpu.reset();
Expand Down

0 comments on commit ac0a21d

Please sign in to comment.