Skip to content

Commit

Permalink
Vulkan: Add the same shutdown logic to stop async shader compiles to …
Browse files Browse the repository at this point in the history
…DeviceLost
  • Loading branch information
hrydgard committed Sep 25, 2023
1 parent 91119c7 commit f2cfbe1
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion GPU/Vulkan/GPU_Vulkan.cpp
Expand Up @@ -182,7 +182,6 @@ GPU_Vulkan::~GPU_Vulkan() {
shaderManager_->ClearShaders();

// other managers are deleted in ~GPUCommonHW.

if (draw_) {
VulkanRenderManager *rm = (VulkanRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
rm->ReleaseCompileQueue();
Expand Down Expand Up @@ -427,13 +426,25 @@ void GPU_Vulkan::DeviceLost() {
while (!IsReady()) {
sleep_ms(10);
}
// draw_ is normally actually still valid here in Vulkan. But we null it out in GPUCommonHW::DeviceLost so we don't try to use it again.
Draw::DrawContext *draw = draw_;
if (draw) {
VulkanRenderManager *rm = (VulkanRenderManager *)draw->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
rm->DrainAndBlockCompileQueue();
}

if (shaderCachePath_.Valid()) {
SaveCache(shaderCachePath_);
}
DestroyDeviceObjects();
pipelineManager_->DeviceLost();

GPUCommonHW::DeviceLost();

if (draw) {
VulkanRenderManager *rm = (VulkanRenderManager *)draw->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
rm->ReleaseCompileQueue();
}
}

void GPU_Vulkan::DeviceRestore(Draw::DrawContext *draw) {
Expand Down

0 comments on commit f2cfbe1

Please sign in to comment.