mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-16 04:09:51 +00:00
Merge pull request #18351 from hrydgard/shutdown-fixes-better
Better fix for shutdown crash
This commit is contained in:
commit
a196c5e7d4
@ -1181,6 +1181,7 @@ uint8_t *ReadLocalFile(const Path &filename, size_t *size) {
|
||||
return nullptr;
|
||||
}
|
||||
fseek(file, 0, SEEK_SET);
|
||||
// NOTE: If you find ~10 memory leaks from here, with very varying sizes, it might be the VFPU LUTs.
|
||||
uint8_t *contents = new uint8_t[f_size + 1];
|
||||
if (fread(contents, 1, f_size, file) != f_size) {
|
||||
delete[] contents;
|
||||
|
@ -85,8 +85,6 @@ void VulkanDescSetPool::Reset() {
|
||||
}
|
||||
|
||||
void VulkanDescSetPool::Destroy() {
|
||||
_assert_msg_(vulkan_ != nullptr, "VulkanDescSetPool::Destroy without VulkanContext");
|
||||
|
||||
if (descPool_ != VK_NULL_HANDLE) {
|
||||
vulkan_->Delete().QueueDeleteDescriptorPool(descPool_);
|
||||
usage_ = 0;
|
||||
@ -94,6 +92,15 @@ void VulkanDescSetPool::Destroy() {
|
||||
sizes_.clear();
|
||||
}
|
||||
|
||||
void VulkanDescSetPool::DestroyImmediately() {
|
||||
if (descPool_ != VK_NULL_HANDLE) {
|
||||
vkDestroyDescriptorPool(vulkan_->GetDevice(), descPool_, nullptr);
|
||||
descPool_ = VK_NULL_HANDLE;
|
||||
usage_ = 0;
|
||||
}
|
||||
sizes_.clear();
|
||||
}
|
||||
|
||||
VkResult VulkanDescSetPool::Recreate(bool grow) {
|
||||
_assert_msg_(vulkan_ != nullptr, "VulkanDescSetPool::Recreate without VulkanContext");
|
||||
|
||||
|
@ -25,7 +25,11 @@ public:
|
||||
// Use only for the current frame.
|
||||
bool Allocate(VkDescriptorSet *descriptorSets, int count, const VkDescriptorSetLayout *layouts);
|
||||
void Reset();
|
||||
|
||||
// This queues up destruction.
|
||||
void Destroy();
|
||||
// This actually destroys immediately.
|
||||
void DestroyImmediately();
|
||||
|
||||
bool IsDestroyed() const {
|
||||
return !descPool_;
|
||||
|
@ -515,20 +515,18 @@ void VulkanRenderManager::CompileThreadFunc() {
|
||||
Task *task = new CreateMultiPipelinesTask(vulkan_, entries);
|
||||
g_threadManager.EnqueueTask(task);
|
||||
}
|
||||
|
||||
|
||||
queueRunner_.NotifyCompileDone();
|
||||
}
|
||||
}
|
||||
|
||||
void VulkanRenderManager::DrainAndBlockCompileQueue() {
|
||||
EndCurRenderStep();
|
||||
std::unique_lock<std::mutex> lock(compileMutex_);
|
||||
compileBlocked_ = true;
|
||||
compileCond_.notify_all();
|
||||
while (!compileQueue_.empty()) {
|
||||
queueRunner_.WaitForCompileNotification();
|
||||
}
|
||||
FlushSync();
|
||||
}
|
||||
|
||||
void VulkanRenderManager::ReleaseCompileQueue() {
|
||||
@ -1662,19 +1660,22 @@ VKRPipelineLayout *VulkanRenderManager::CreatePipelineLayout(BindingType *bindin
|
||||
}
|
||||
|
||||
void VulkanRenderManager::DestroyPipelineLayout(VKRPipelineLayout *layout) {
|
||||
for (int i = 0; i < VulkanContext::MAX_INFLIGHT_FRAMES; i++) {
|
||||
layout->frameData[i].pool.Destroy();
|
||||
}
|
||||
|
||||
vulkan_->Delete().QueueDeletePipelineLayout(layout->pipelineLayout);
|
||||
vulkan_->Delete().QueueDeleteDescriptorSetLayout(layout->descriptorSetLayout);
|
||||
for (auto iter = pipelineLayouts_.begin(); iter != pipelineLayouts_.end(); iter++) {
|
||||
if (*iter == layout) {
|
||||
pipelineLayouts_.erase(iter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
delete layout;
|
||||
vulkan_->Delete().QueueCallback([](VulkanContext *vulkan, void *userdata) {
|
||||
VKRPipelineLayout *layout = (VKRPipelineLayout *)userdata;
|
||||
for (int i = 0; i < VulkanContext::MAX_INFLIGHT_FRAMES; i++) {
|
||||
layout->frameData[i].pool.DestroyImmediately();
|
||||
}
|
||||
vkDestroyPipelineLayout(vulkan->GetDevice(), layout->pipelineLayout, nullptr);
|
||||
vkDestroyDescriptorSetLayout(vulkan->GetDevice(), layout->descriptorSetLayout, nullptr);
|
||||
|
||||
delete layout;
|
||||
}, layout);
|
||||
}
|
||||
|
||||
void VulkanRenderManager::FlushDescriptors(int frame) {
|
||||
@ -1694,7 +1695,6 @@ void VulkanRenderManager::ResetDescriptorLists(int frame) {
|
||||
}
|
||||
|
||||
VKRPipelineLayout::~VKRPipelineLayout() {
|
||||
_assert_(!pipelineLayout && !descriptorSetLayout);
|
||||
_assert_(frameData[0].pool.IsDestroyed());
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user