vk: Fix invalidated surface_cache resource deletion bug
Some checks failed
Generate Translation Template / Generate Translation Template (push) Has been cancelled
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (/rpcs3/.ci/build-linux-aarch64.sh, gcc, rpcs3/rpcs3-ci-jammy-aarch64:1.6, ubuntu-24.04-arm) (push) Has been cancelled
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (/rpcs3/.ci/build-linux.sh, gcc, rpcs3/rpcs3-ci-jammy:1.6, ubuntu-24.04) (push) Has been cancelled
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (a1d35836e8d45bfc6f63c26f0a3e5d46ef622fe1, rpcs3/rpcs3-binaries-linux-arm64, /rpcs3/.ci/build-linux-aarch64.sh, clang, rpcs3/rpcs3-ci-jammy-aarch64:1.6, ubuntu-24.04-arm) (push) Has been cancelled
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (d812f1254a1157c80fd402f94446310560f54e5f, rpcs3/rpcs3-binaries-linux, /rpcs3/.ci/build-linux.sh, clang, rpcs3/rpcs3-ci-jammy:1.6, ubuntu-24.04) (push) Has been cancelled
Build RPCS3 / RPCS3 Mac ${{ matrix.name }} (51ae32f468089a8169aaf1567de355ff4a3e0842, rpcs3/rpcs3-binaries-mac, arch -X86_64 .ci/build-mac.sh, Intel) (push) Has been cancelled
Build RPCS3 / RPCS3 Mac ${{ matrix.name }} (8e21bdbc40711a3fccd18fbf17b742348b0f4281, rpcs3/rpcs3-binaries-mac-arm64, .ci/build-mac-arm64.sh, Apple Silicon) (push) Has been cancelled
Build RPCS3 / RPCS3 Windows (push) Has been cancelled
Build RPCS3 / RPCS3 Windows Clang (win64, clang, clang64) (push) Has been cancelled
Build RPCS3 / RPCS3 FreeBSD (push) Has been cancelled

This commit is contained in:
kd-11 2025-09-13 19:16:37 +03:00 committed by kd-11
parent 1a7d702e4e
commit 335ed8d91b

View file

@ -183,7 +183,7 @@ namespace vk
});
const u64 last_finished_frame = vk::get_last_completed_frame_id();
invalidated_resources.remove_if([&](std::unique_ptr<vk::render_target>& rtt)
for (auto& rtt : invalidated_resources)
{
ensure(rtt->frame_tag != 0);
@ -191,13 +191,13 @@ namespace vk
{
// Actively in use, likely for a reading pass.
// Call handle_memory_pressure before calling this method.
return false;
continue;
}
if (rtt->frame_tag >= last_finished_frame)
{
// RTT itself still in use by the frame.
return false;
continue;
}
if (!rtt->old_contents.empty())
@ -212,21 +212,34 @@ namespace vk
vk::get_resource_manager()->dispose(rtt->resolve_surface);
}
int threshold = 8;
switch (memory_pressure)
{
case rsx::problem_severity::low:
return (rtt->unused_check_count() >= 2);
threshold = 2;
break;
case rsx::problem_severity::moderate:
return (rtt->unused_check_count() >= 1);
threshold = 1;
break;
case rsx::problem_severity::severe:
case rsx::problem_severity::fatal:
// We're almost dead anyway. Remove forcefully.
vk::get_resource_manager()->dispose(rtt);
return true;
threshold = -1;
break;
default:
fmt::throw_exception("Unreachable");
}
});
if (threshold < 0 || (rtt->unused_check_count() >= threshold))
{
vk::get_resource_manager()->dispose(rtt);
ensure(!rtt);
}
}
invalidated_resources.remove_if(
[](auto& rtt) { return !rtt; }
);
}
bool surface_cache::is_overallocated()