GPU/Vulkan: Fix race/crash when changing settings live

This commit is contained in:
Connor McLaughlin 2020-06-21 01:33:00 +10:00
parent f54876deb0
commit 97ef905f10

View file

@ -82,6 +82,7 @@ bool GPU_HW_Vulkan::Initialize(HostDisplay* host_display, System* system, DMA* d
return false; return false;
} }
UpdateDepthBufferFromMaskBit();
RestoreGraphicsAPIState(); RestoreGraphicsAPIState();
return true; return true;
} }
@ -90,9 +91,7 @@ void GPU_HW_Vulkan::Reset()
{ {
GPU_HW::Reset(); GPU_HW::Reset();
if (InRenderPass()) EndRenderPass();
EndRenderPass();
ClearFramebuffer(); ClearFramebuffer();
} }
@ -100,8 +99,7 @@ void GPU_HW_Vulkan::ResetGraphicsAPIState()
{ {
GPU_HW::ResetGraphicsAPIState(); GPU_HW::ResetGraphicsAPIState();
if (InRenderPass()) EndRenderPass();
EndRenderPass();
// vram texture is probably going to be displayed now // vram texture is probably going to be displayed now
if (!IsDisplayDisabled()) if (!IsDisplayDisabled())
@ -134,8 +132,9 @@ void GPU_HW_Vulkan::UpdateSettings()
CreateFramebuffer(); CreateFramebuffer();
DestroyPipelines(); DestroyPipelines();
CompilePipelines(); CompilePipelines();
RestoreGraphicsAPIState(); UpdateDepthBufferFromMaskBit();
UpdateDisplay(); UpdateDisplay();
RestoreGraphicsAPIState();
} }
void GPU_HW_Vulkan::MapBatchVertexPointer(u32 required_vertices) void GPU_HW_Vulkan::MapBatchVertexPointer(u32 required_vertices)
@ -449,14 +448,11 @@ bool GPU_HW_Vulkan::CreateFramebuffer()
m_vram_texture.TransitionToLayout(cmdbuf, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); m_vram_texture.TransitionToLayout(cmdbuf, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
UpdateDepthBufferFromMaskBit();
// Can't immediately destroy because we're blitting in the current command buffer. // Can't immediately destroy because we're blitting in the current command buffer.
old_vram_texture.Destroy(true); old_vram_texture.Destroy(true);
} }
SetFullVRAMDirtyRectangle(); SetFullVRAMDirtyRectangle();
RestoreGraphicsAPIState();
return true; return true;
} }