Skip to content

Commit

Permalink
More sanity checks
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Jan 23, 2024
1 parent d260cd0 commit 0d2e5c3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions Common/GPU/Vulkan/VulkanRenderManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,11 @@ void VulkanRenderManager::DestroyBackbuffers() {
VulkanRenderManager::~VulkanRenderManager() {
INFO_LOG(G3D, "VulkanRenderManager destructor");

{
std::unique_lock<std::mutex> lock(compileMutex_);
_assert_(compileQueue_.empty());
}

if (useRenderThread_) {
_dbg_assert_(!renderThread_.joinable());
}
Expand All @@ -439,9 +444,6 @@ void VulkanRenderManager::CompileThreadFunc() {
std::vector<CompileQueueEntry> toCompile;
{
std::unique_lock<std::mutex> lock(compileMutex_);
// TODO: Should this be while?
// It may be beneficial also to unlock and wait a little bit to see if we get some more shaders
// so we can do a better job of thread-sorting them.
if (compileQueue_.empty() && runCompileThread_) {
compileCond_.wait(lock);
}
Expand Down Expand Up @@ -496,6 +498,9 @@ void VulkanRenderManager::CompileThreadFunc() {
// Hold off just a bit before we check again, to allow bunches of pipelines to collect.
sleep_ms(1);
}

std::unique_lock<std::mutex> lock(compileMutex_);
_assert_(compileQueue_.empty());
}

void VulkanRenderManager::RenderThreadFunc() {
Expand Down
2 changes: 1 addition & 1 deletion GPU/Vulkan/GPU_Vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ 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.
// StopThreads should have ensured that no pipelines are queued to compile at this point. So we can tear it down.
delete pipelineManager_;
pipelineManager_ = nullptr;

Expand Down

0 comments on commit 0d2e5c3

Please sign in to comment.