mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-12-05 04:03:49 +01:00
Fix a really bad race condition during game shutdown.
This commit is contained in:
1 parent
b8353c6273
commit
3783afd855
4 files changed
+26
-1
No files matched your search
@@ -199,6 +199,14 @@ VKRGraphicsPipeline::~VKRGraphicsPipeline() {
|
||||
desc->Release();
|
||||
}
|
||||
|
||||
void VKRGraphicsPipeline::BlockUntilCompiled() {
|
||||
for (size_t i = 0; i < (size_t)RenderPassType::TYPE_COUNT; i++) {
|
||||
if (pipeline[i]) {
|
||||
pipeline[i]->BlockUntilReady();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VKRGraphicsPipeline::QueueForDeletion(VulkanContext *vulkan) {
|
||||
// Can't destroy variants here, the pipeline still lives for a while.
|
||||
vulkan->Delete().QueueCallback([](VulkanContext *vulkan, void *p) {
|
||||
|
||||
@@ -131,6 +131,10 @@ struct VKRGraphicsPipeline {
|
||||
// This deletes the whole VKRGraphicsPipeline, you must remove your last pointer to it when doing this.
|
||||
void QueueForDeletion(VulkanContext *vulkan);
|
||||
|
||||
// This blocks until any background compiles are finished.
|
||||
// Used during game shutdown before we clear out shaders that these compiles depend on.
|
||||
void BlockUntilCompiled();
|
||||
|
||||
u32 GetVariantsBitmask() const;
|
||||
|
||||
void LogCreationFailure() const;
|
||||
|
||||
@@ -186,12 +186,16 @@ GPU_Vulkan::~GPU_Vulkan() {
|
||||
}
|
||||
|
||||
SaveCache(shaderCachePath_);
|
||||
|
||||
// Super important to delete pipeline manager FIRST, before clearing shaders, so we wait for all pending pipelines to finish compiling.
|
||||
delete pipelineManager_;
|
||||
pipelineManager_ = nullptr;
|
||||
|
||||
// Note: We save the cache in DeviceLost
|
||||
DestroyDeviceObjects();
|
||||
drawEngine_.DeviceLost();
|
||||
shaderManager_->ClearShaders();
|
||||
|
||||
delete pipelineManager_;
|
||||
// other managers are deleted in ~GPUCommonHW.
|
||||
|
||||
if (draw_) {
|
||||
|
||||
@@ -29,6 +29,15 @@ PipelineManagerVulkan::PipelineManagerVulkan(VulkanContext *vulkan) : pipelines_
|
||||
}
|
||||
|
||||
PipelineManagerVulkan::~PipelineManagerVulkan() {
|
||||
// Block on all pipelines to make sure any background compiles are done.
|
||||
// This is very important to do before we start trying to tear down the shaders - otherwise, we might
|
||||
// be deleting shaders before queued pipeline creations that use them are performed.
|
||||
pipelines_.Iterate([&](const VulkanPipelineKey &key, VulkanPipeline *value) {
|
||||
if (value->pipeline) {
|
||||
value->pipeline->BlockUntilCompiled();
|
||||
}
|
||||
});
|
||||
|
||||
Clear();
|
||||
if (pipelineCache_ != VK_NULL_HANDLE)
|
||||
vulkan_->Delete().QueueDeletePipelineCache(pipelineCache_);
|
||||
|
||||
Reference in new issue
Block a user