diff --git a/src/ShaderCache.cpp b/src/ShaderCache.cpp index 2bbc8e631..997f97316 100644 --- a/src/ShaderCache.cpp +++ b/src/ShaderCache.cpp @@ -1857,6 +1857,12 @@ namespace SIE { Clear(); StopFileWatcher(); + if (!compilationPool.wait_for_tasks_duration(std::chrono::milliseconds(1000))) { + logger::info("Tasks still running despite request to stop; killing thread {}!", GetThreadId(managementThread)); + WaitForSingleObject(managementThread, 1000); + TerminateThread(managementThread, 0); + CloseHandle(managementThread); + } } void ShaderCache::Clear() @@ -2332,7 +2338,8 @@ namespace SIE void ShaderCache::ManageCompilationSet(std::stop_token stoken) { - SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL); + managementThread = GetCurrentThread(); + SetThreadPriority(managementThread, THREAD_PRIORITY_BELOW_NORMAL); while (!stoken.stop_requested()) { const auto& task = compilationSet.WaitTake(stoken); if (!task.has_value()) diff --git a/src/ShaderCache.h b/src/ShaderCache.h index 31f96a720..f715771ce 100644 --- a/src/ShaderCache.h +++ b/src/ShaderCache.h @@ -550,6 +550,7 @@ namespace SIE uint blockedKeyIndex = (uint)-1; // index in shaderMap; negative value indicates disabled std::string blockedKey = ""; std::vector blockedIDs; // more than one descriptor could be blocked based on shader hash + HANDLE managementThread = nullptr; private: ShaderCache();