Fixing pool shutdown.

This commit is contained in:
Ben Vanik 2016-02-21 10:46:47 -08:00
parent b3faba50a3
commit 32c4f3ce24
2 changed files with 19 additions and 12 deletions

View File

@ -53,6 +53,7 @@ CommandBufferPool::CommandBufferPool(VkDevice device,
}
CommandBufferPool::~CommandBufferPool() {
FreeAllEntries();
vkDestroyCommandPool(device_, command_pool_, nullptr);
command_pool_ = nullptr;
}

View File

@ -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<T*>(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<T*>(this)->FreeEntry(entry->handle);
delete entry;
}
}
VkDevice device_ = nullptr;
private: