mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-07-04 23:31:19 +01:00
async_shaders: Increase Async worker thread count for 8+ thread cpus
Adds 1 async worker thread for every 2 available threads above 8
This commit is contained in:
parent
2dbb144fc6
commit
3620206136
1 changed files with 9 additions and 8 deletions
|
@ -20,14 +20,15 @@ AsyncShaders::~AsyncShaders() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsyncShaders::AllocateWorkers() {
|
void AsyncShaders::AllocateWorkers() {
|
||||||
// Max worker threads we should allow
|
// Use at least one thread
|
||||||
constexpr u32 MAX_THREADS = 4;
|
u32 num_workers = 1;
|
||||||
// Deduce how many threads we can use
|
|
||||||
const u32 threads_used = std::thread::hardware_concurrency() / 4;
|
// Deduce how many more threads we can use
|
||||||
// Always allow at least 1 thread regardless of our settings
|
const u32 thread_count = std::thread::hardware_concurrency();
|
||||||
const auto max_worker_count = std::max(1U, threads_used);
|
if (thread_count >= 8) {
|
||||||
// Don't use more than MAX_THREADS
|
// Increase async workers by 1 for every 2 threads >= 8
|
||||||
const auto num_workers = std::min(max_worker_count, MAX_THREADS);
|
num_workers += 1 + (thread_count - 8) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
// If we already have workers queued, ignore
|
// If we already have workers queued, ignore
|
||||||
if (num_workers == worker_threads.size()) {
|
if (num_workers == worker_threads.size()) {
|
||||||
|
|
Loading…
Reference in a new issue