More sanity checks

This commit is contained in:
Henrik Rydgård 2024-01-24 00:50:32 +01:00
parent d260cd0498
commit 0d2e5c32ab
2 changed files with 9 additions and 4 deletions

View file

@ -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());
}
@ -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);
}
@ -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() {

View file

@ -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;