From 32c4f3ce24b69324e040cf2d48bc863c46bfde0e Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Sun, 21 Feb 2016 10:46:47 -0800 Subject: [PATCH] Fixing pool shutdown. --- src/xenia/ui/vulkan/fenced_pools.cc | 1 + src/xenia/ui/vulkan/fenced_pools.h | 30 +++++++++++++++++------------ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/xenia/ui/vulkan/fenced_pools.cc b/src/xenia/ui/vulkan/fenced_pools.cc index 0737b98c4..dc79a9869 100644 --- a/src/xenia/ui/vulkan/fenced_pools.cc +++ b/src/xenia/ui/vulkan/fenced_pools.cc @@ -53,6 +53,7 @@ CommandBufferPool::CommandBufferPool(VkDevice device, } CommandBufferPool::~CommandBufferPool() { + FreeAllEntries(); vkDestroyCommandPool(device_, command_pool_, nullptr); command_pool_ = nullptr; } diff --git a/src/xenia/ui/vulkan/fenced_pools.h b/src/xenia/ui/vulkan/fenced_pools.h index 3bc7e30f6..a50f82d08 100644 --- a/src/xenia/ui/vulkan/fenced_pools.h +++ b/src/xenia/ui/vulkan/fenced_pools.h @@ -33,18 +33,9 @@ class BaseFencedPool { // TODO(benvanik): wait on fence until done. assert_null(pending_batch_list_head_); - // Run down free lists. - while (free_batch_list_head_) { - auto batch = free_batch_list_head_; - free_batch_list_head_ = batch->next; - delete batch; - } - while (free_entry_list_head_) { - auto entry = free_entry_list_head_; - free_entry_list_head_ = entry->next; - static_cast(this)->FreeEntry(entry->handle); - delete entry; - } + // Subclasses must call FreeAllEntries() to properly clean up things. + assert_null(free_batch_list_head_); + assert_null(free_entry_list_head_); } // True if one or more batches are still pending on the GPU. @@ -159,6 +150,21 @@ class BaseFencedPool { free_entry_list_head_ = entry; } + void FreeAllEntries() { + // Run down free lists. + while (free_batch_list_head_) { + auto batch = free_batch_list_head_; + free_batch_list_head_ = batch->next; + delete batch; + } + while (free_entry_list_head_) { + auto entry = free_entry_list_head_; + free_entry_list_head_ = entry->next; + static_cast(this)->FreeEntry(entry->handle); + delete entry; + } + } + VkDevice device_ = nullptr; private: