mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-30 04:38:49 +00:00
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.
This commit is contained in:
parent
d3dd85dbd7
commit
93865b327f
4 changed files with 60 additions and 41 deletions
|
@ -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())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue