Vulkan: ClearCache for texture cache, properly free all textures and allocator on exit.
This commit is contained in:
parent
1358b94f4d
commit
f9d08888c7
|
@ -207,12 +207,11 @@ TextureCache::~TextureCache() {
|
||||||
device_->ReleaseQueue(device_queue_);
|
device_->ReleaseQueue(device_queue_);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto it = samplers_.begin(); it != samplers_.end(); ++it) {
|
// Free all textures allocated.
|
||||||
vkDestroySampler(*device_, it->second->sampler, nullptr);
|
ClearCache();
|
||||||
delete it->second;
|
Scavenge();
|
||||||
}
|
|
||||||
samplers_.clear();
|
|
||||||
|
|
||||||
|
vmaDestroyAllocator(mem_allocator_);
|
||||||
vkDestroyDescriptorSetLayout(*device_, texture_descriptor_set_layout_,
|
vkDestroyDescriptorSetLayout(*device_, texture_descriptor_set_layout_,
|
||||||
nullptr);
|
nullptr);
|
||||||
}
|
}
|
||||||
|
@ -1453,7 +1452,20 @@ void TextureCache::RemoveInvalidatedTextures() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureCache::ClearCache() {
|
void TextureCache::ClearCache() {
|
||||||
// TODO(DrChat): Nuke everything.
|
RemoveInvalidatedTextures();
|
||||||
|
for (auto it = textures_.begin(); it != textures_.end(); ++it) {
|
||||||
|
while (!FreeTexture(it->second)) {
|
||||||
|
// Texture still in use. Busy loop.
|
||||||
|
xe::threading::MaybeYield();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
textures_.clear();
|
||||||
|
|
||||||
|
for (auto it = samplers_.begin(); it != samplers_.end(); ++it) {
|
||||||
|
vkDestroySampler(*device_, it->second->sampler, nullptr);
|
||||||
|
delete it->second;
|
||||||
|
}
|
||||||
|
samplers_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureCache::Scavenge() {
|
void TextureCache::Scavenge() {
|
||||||
|
|
Loading…
Reference in New Issue