Skip to content

Commit 1353817

Browse files
authored
Merge pull request #16689 from unknownbrackets/vk-shutdown
Vulkan: Avoid race in compile thread exit
2 parents 40386bc + 6c79d94 commit 1353817

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Common/GPU/Vulkan/VulkanRenderManager.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,11 @@ void VulkanRenderManager::StopThread() {
302302

303303
INFO_LOG(G3D, "Vulkan submission thread joined. Frame=%d", vulkan_->GetCurFrame());
304304

305-
compileCond_.notify_all();
305+
if (compileThread_.joinable()) {
306+
// Lock to avoid race conditions.
307+
std::lock_guard<std::mutex> guard(compileMutex_);
308+
compileCond_.notify_all();
309+
}
306310
compileThread_.join();
307311
INFO_LOG(G3D, "Vulkan compiler thread joined.");
308312

@@ -360,7 +364,7 @@ void VulkanRenderManager::CompileThreadFunc() {
360364
std::vector<CompileQueueEntry> toCompile;
361365
{
362366
std::unique_lock<std::mutex> lock(compileMutex_);
363-
if (compileQueue_.empty()) {
367+
if (compileQueue_.empty() && run_) {
364368
compileCond_.wait(lock);
365369
}
366370
toCompile = std::move(compileQueue_);

0 commit comments

Comments
 (0)