summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrChat <arkolbed@gmail.com>2017-09-07 14:22:04 -0500
committerDrChat <arkolbed@gmail.com>2017-09-07 14:22:04 -0500
commitf9d08888c7ef34c243e492447843c6d138793cc5 (patch)
tree647d64b20319a85cca376ffb23e7d729ee5c04bb
parent1358b94f4da3eb0a90240526197ba2ffa2abe347 (diff)
Vulkan: ClearCache for texture cache, properly free all textures and allocator on exit.
-rw-r--r--src/xenia/gpu/vulkan/texture_cache.cc24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/xenia/gpu/vulkan/texture_cache.cc b/src/xenia/gpu/vulkan/texture_cache.cc
index 57b32c965..f8d380f49 100644
--- a/src/xenia/gpu/vulkan/texture_cache.cc
+++ b/src/xenia/gpu/vulkan/texture_cache.cc
@@ -207,12 +207,11 @@ TextureCache::~TextureCache() {
device_->ReleaseQueue(device_queue_);
}
- for (auto it = samplers_.begin(); it != samplers_.end(); ++it) {
- vkDestroySampler(*device_, it->second->sampler, nullptr);
- delete it->second;
- }
- samplers_.clear();
+ // Free all textures allocated.
+ ClearCache();
+ Scavenge();
+ vmaDestroyAllocator(mem_allocator_);
vkDestroyDescriptorSetLayout(*device_, texture_descriptor_set_layout_,
nullptr);
}
@@ -1453,7 +1452,20 @@ void TextureCache::RemoveInvalidatedTextures() {
}
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() {