VideoCommon: add method to async shader compiler to clear pending/completed work (used on shutdown), this will in turn clear up any resources that the worker items may have held onto
This commit is contained in:
@@ -68,6 +68,19 @@ bool AsyncShaderCompiler::HasCompletedWork()
|
|||||||
return !m_completed_work.empty();
|
return !m_completed_work.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AsyncShaderCompiler::ClearAllWork()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> guard(m_pending_work_lock);
|
||||||
|
m_pending_work.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> guard(m_completed_work_lock);
|
||||||
|
m_completed_work.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool AsyncShaderCompiler::WaitUntilCompletion(
|
bool AsyncShaderCompiler::WaitUntilCompletion(
|
||||||
const std::function<void(size_t, size_t)>& progress_callback)
|
const std::function<void(size_t, size_t)>& progress_callback)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -49,6 +49,9 @@ public:
|
|||||||
bool HasPendingWork();
|
bool HasPendingWork();
|
||||||
bool HasCompletedWork();
|
bool HasCompletedWork();
|
||||||
|
|
||||||
|
// Clears both pending and completed work
|
||||||
|
void ClearAllWork();
|
||||||
|
|
||||||
// Calls progress_callback periodically, with completed_items, and total_items.
|
// Calls progress_callback periodically, with completed_items, and total_items.
|
||||||
// Returns false if interrupted.
|
// Returns false if interrupted.
|
||||||
bool WaitUntilCompletion(const std::function<void(size_t, size_t)>& progress_callback);
|
bool WaitUntilCompletion(const std::function<void(size_t, size_t)>& progress_callback);
|
||||||
|
|||||||
@@ -24,10 +24,16 @@ CustomShaderCache::CustomShaderCache()
|
|||||||
CustomShaderCache::~CustomShaderCache()
|
CustomShaderCache::~CustomShaderCache()
|
||||||
{
|
{
|
||||||
if (m_async_shader_compiler)
|
if (m_async_shader_compiler)
|
||||||
|
{
|
||||||
m_async_shader_compiler->StopWorkerThreads();
|
m_async_shader_compiler->StopWorkerThreads();
|
||||||
|
m_async_shader_compiler->ClearAllWork();
|
||||||
|
}
|
||||||
|
|
||||||
if (m_async_uber_shader_compiler)
|
if (m_async_uber_shader_compiler)
|
||||||
|
{
|
||||||
m_async_uber_shader_compiler->StopWorkerThreads();
|
m_async_uber_shader_compiler->StopWorkerThreads();
|
||||||
|
m_async_uber_shader_compiler->ClearAllWork();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomShaderCache::RetrieveAsyncShaders()
|
void CustomShaderCache::RetrieveAsyncShaders()
|
||||||
|
|||||||
@@ -109,7 +109,10 @@ void ShaderCache::Shutdown()
|
|||||||
// This may leave shaders uncommitted to the cache, but it's better than blocking shutdown
|
// This may leave shaders uncommitted to the cache, but it's better than blocking shutdown
|
||||||
// until everything has finished compiling.
|
// until everything has finished compiling.
|
||||||
if (m_async_shader_compiler)
|
if (m_async_shader_compiler)
|
||||||
|
{
|
||||||
m_async_shader_compiler->StopWorkerThreads();
|
m_async_shader_compiler->StopWorkerThreads();
|
||||||
|
m_async_shader_compiler->ClearAllWork();
|
||||||
|
}
|
||||||
|
|
||||||
ClosePipelineUIDCache();
|
ClosePipelineUIDCache();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user