diff options
| author | Stenzek <stenzek@gmail.com> | 2018-03-16 22:48:56 +1000 |
|---|---|---|
| committer | Stenzek <stenzek@gmail.com> | 2018-03-17 01:53:11 +1000 |
| commit | 93865b327f97399d7b166cbce739685749de083a (patch) | |
| tree | 6a90df46f4fd6575f94a3d5b9a879e6fbb5a6510 /Source/Core/VideoCommon/AsyncShaderCompiler.cpp | |
| parent | d3dd85dbd75cb95e42a89990557fb5f78b2fb6c6 (diff) | |
ShaderCache: Implement compile priority
Currently, when immediately compile shaders is not enabled, the
ubershaders will be placed before any specialized shaders in the compile
queue in hybrid ubershaders mode. This means that Dolphin could
potentially use the ubershaders for a longer time than it would have if
we blocked startup until all shaders were compiled, leading to a drop in
performance.
Diffstat (limited to 'Source/Core/VideoCommon/AsyncShaderCompiler.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/AsyncShaderCompiler.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Source/Core/VideoCommon/AsyncShaderCompiler.cpp b/Source/Core/VideoCommon/AsyncShaderCompiler.cpp index 2f14c1621b..8ac3c26fc9 100644 --- a/Source/Core/VideoCommon/AsyncShaderCompiler.cpp +++ b/Source/Core/VideoCommon/AsyncShaderCompiler.cpp @@ -20,7 +20,7 @@ AsyncShaderCompiler::~AsyncShaderCompiler() _assert_(!HasWorkerThreads()); } -void AsyncShaderCompiler::QueueWorkItem(WorkItemPtr item) +void AsyncShaderCompiler::QueueWorkItem(WorkItemPtr item, u32 priority) { // If no worker threads are available, compile synchronously. if (!HasWorkerThreads()) @@ -31,7 +31,7 @@ void AsyncShaderCompiler::QueueWorkItem(WorkItemPtr item) else { std::lock_guard<std::mutex> guard(m_pending_work_lock); - m_pending_work.push_back(std::move(item)); + m_pending_work.emplace(priority, std::move(item)); m_worker_thread_wake.notify_one(); } } @@ -219,8 +219,9 @@ void AsyncShaderCompiler::WorkerThreadRun() while (!m_pending_work.empty() && !m_exit_flag.IsSet()) { m_busy_workers++; - WorkItemPtr item(std::move(m_pending_work.front())); - m_pending_work.pop_front(); + auto iter = m_pending_work.begin(); + WorkItemPtr item(std::move(iter->second)); + m_pending_work.erase(iter); pending_lock.unlock(); if (item->Compile()) |
