fix(agc): release pooled buffers and image mirrors before the device

This commit is contained in:
Mehran
2026-10-06 11:47:31 +03:00
parent e76c70f682
commit 498b53bbf5
3 changed files with 17 additions and 0 deletions
@@ -510,8 +510,11 @@ struct VulkanDevice::State {
}
// Every ShaderResources (kept by the recorder or the resource cache) is gone now, so the
// sets and samplers they borrowed can go.
copiedWriters->clear();
resourceCache.Clear();
Graphics::ClearCachedTextures(device);
Graphics::ClearImageMirrors(device);
patternBuffers.clear();
descriptorCache.reset();
emptyBuffer.reset();
samplerCache.reset();
@@ -148,6 +148,7 @@ struct MirrorStats {
std::uint64_t heapRefills = 0;
};
MirrorStats MirrorCounters();
void ClearImageMirrors(VkDevice device);
struct AddressCopy {
std::uint64_t begin;
@@ -1002,6 +1002,19 @@ MirrorStats MirrorCounters() {
return stats;
}
void ClearImageMirrors(VkDevice device) {
auto& state = Mirrors();
std::map<std::uint64_t, std::shared_ptr<ImageMirror>> entries;
{
std::lock_guard lock(state.mutex);
if (state.device != device) return;
entries.swap(state.entries);
state.failed.clear();
state.heapBytes = 0;
state.device = VK_NULL_HANDLE;
}
}
ImportProbe ProbeImportWriteProtection(const Context& context) {
ImportProbe probe;
#ifdef _WIN32