mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-11-22 17:19:18 +01:00
Vulkan: Properly shut down compilation threads
This commit is contained in:
parent
bffeb818d1
commit
e7fa8ec0c6
@ -139,7 +139,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
~_ShaderVkThreadPool()
|
void StopThreads()
|
||||||
{
|
{
|
||||||
m_shutdownThread.store(true);
|
m_shutdownThread.store(true);
|
||||||
for (uint32 i = 0; i < s_threads.size(); ++i)
|
for (uint32 i = 0; i < s_threads.size(); ++i)
|
||||||
@ -149,6 +149,11 @@ public:
|
|||||||
s_threads.clear();
|
s_threads.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~_ShaderVkThreadPool()
|
||||||
|
{
|
||||||
|
StopThreads();
|
||||||
|
}
|
||||||
|
|
||||||
void CompilerThreadFunc()
|
void CompilerThreadFunc()
|
||||||
{
|
{
|
||||||
while (!m_shutdownThread.load(std::memory_order::relaxed))
|
while (!m_shutdownThread.load(std::memory_order::relaxed))
|
||||||
@ -176,6 +181,8 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool HasThreadsRunning() const { return !m_shutdownThread; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::vector<std::thread> s_threads;
|
std::vector<std::thread> s_threads;
|
||||||
|
|
||||||
@ -195,8 +202,8 @@ RendererShaderVk::RendererShaderVk(ShaderType type, uint64 baseHash, uint64 auxH
|
|||||||
m_compilationState.setValue(COMPILATION_STATE::QUEUED);
|
m_compilationState.setValue(COMPILATION_STATE::QUEUED);
|
||||||
ShaderVkThreadPool.s_compilationQueue.push_back(this);
|
ShaderVkThreadPool.s_compilationQueue.push_back(this);
|
||||||
ShaderVkThreadPool.s_compilationQueueCount.increment();
|
ShaderVkThreadPool.s_compilationQueueCount.increment();
|
||||||
ShaderVkThreadPool.StartThreads();
|
|
||||||
ShaderVkThreadPool.s_compilationQueueMutex.unlock();
|
ShaderVkThreadPool.s_compilationQueueMutex.unlock();
|
||||||
|
cemu_assert_debug(ShaderVkThreadPool.HasThreadsRunning()); // make sure .StartThreads() was called
|
||||||
}
|
}
|
||||||
|
|
||||||
RendererShaderVk::~RendererShaderVk()
|
RendererShaderVk::~RendererShaderVk()
|
||||||
@ -204,6 +211,16 @@ RendererShaderVk::~RendererShaderVk()
|
|||||||
VulkanRenderer::GetInstance()->destroyShader(this);
|
VulkanRenderer::GetInstance()->destroyShader(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RendererShaderVk::Init()
|
||||||
|
{
|
||||||
|
ShaderVkThreadPool.StartThreads();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RendererShaderVk::Shutdown()
|
||||||
|
{
|
||||||
|
ShaderVkThreadPool.StopThreads();
|
||||||
|
}
|
||||||
|
|
||||||
sint32 RendererShaderVk::GetUniformLocation(const char* name)
|
sint32 RendererShaderVk::GetUniformLocation(const char* name)
|
||||||
{
|
{
|
||||||
cemu_assert_suspicious();
|
cemu_assert_suspicious();
|
||||||
|
@ -28,6 +28,9 @@ public:
|
|||||||
RendererShaderVk(ShaderType type, uint64 baseHash, uint64 auxHash, bool isGameShader, bool isGfxPackShader, const std::string& glslCode);
|
RendererShaderVk(ShaderType type, uint64 baseHash, uint64 auxHash, bool isGameShader, bool isGfxPackShader, const std::string& glslCode);
|
||||||
virtual ~RendererShaderVk();
|
virtual ~RendererShaderVk();
|
||||||
|
|
||||||
|
static void Init();
|
||||||
|
static void Shutdown();
|
||||||
|
|
||||||
sint32 GetUniformLocation(const char* name) override;
|
sint32 GetUniformLocation(const char* name) override;
|
||||||
void SetUniform1iv(sint32 location, void* data, sint32 count) override;
|
void SetUniform1iv(sint32 location, void* data, sint32 count) override;
|
||||||
void SetUniform2fv(sint32 location, void* data, sint32 count) override;
|
void SetUniform2fv(sint32 location, void* data, sint32 count) override;
|
||||||
|
@ -591,6 +591,9 @@ VulkanRenderer::VulkanRenderer()
|
|||||||
{
|
{
|
||||||
//cemuLog_log(LogType::Force, "Disable surface copies via buffer (Requires 2GB. Has only {}MB available)", availableSurfaceCopyBufferMem / 1024ull / 1024ull);
|
//cemuLog_log(LogType::Force, "Disable surface copies via buffer (Requires 2GB. Has only {}MB available)", availableSurfaceCopyBufferMem / 1024ull / 1024ull);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start compilation threads
|
||||||
|
RendererShaderVk::Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
VulkanRenderer::~VulkanRenderer()
|
VulkanRenderer::~VulkanRenderer()
|
||||||
@ -598,6 +601,8 @@ VulkanRenderer::~VulkanRenderer()
|
|||||||
SubmitCommandBuffer();
|
SubmitCommandBuffer();
|
||||||
WaitDeviceIdle();
|
WaitDeviceIdle();
|
||||||
WaitCommandBufferFinished(GetCurrentCommandBufferId());
|
WaitCommandBufferFinished(GetCurrentCommandBufferId());
|
||||||
|
// shut down compilation threads
|
||||||
|
RendererShaderVk::Shutdown();
|
||||||
// shut down pipeline save thread
|
// shut down pipeline save thread
|
||||||
m_destructionRequested = true;
|
m_destructionRequested = true;
|
||||||
m_pipeline_cache_semaphore.notify();
|
m_pipeline_cache_semaphore.notify();
|
||||||
|
Loading…
Reference in New Issue
Block a user