diff options
| author | ameerj <aj662@drexel.edu> | 2020-08-05 12:53:26 -0400 |
|---|---|---|
| committer | ameerj <aj662@drexel.edu> | 2020-08-16 12:02:22 -0400 |
| commit | b467d4dbd058e46eecbcf577013e539bf73feca2 (patch) | |
| tree | b843deb06496541b1e611832ddf54c4492f0849c /src/video_core/shader/async_shaders.cpp | |
| parent | 3fa34fa7bf141ddaea6ce1d37be2df9718d15574 (diff) | |
move thread 1/4 count computation into allocate workers method
Diffstat (limited to 'src/video_core/shader/async_shaders.cpp')
| -rw-r--r-- | src/video_core/shader/async_shaders.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/video_core/shader/async_shaders.cpp b/src/video_core/shader/async_shaders.cpp index ea813d506a..6a1b8999c9 100644 --- a/src/video_core/shader/async_shaders.cpp +++ b/src/video_core/shader/async_shaders.cpp @@ -19,9 +19,18 @@ AsyncShaders::~AsyncShaders() { KillWorkers(); } -void AsyncShaders::AllocateWorkers(std::size_t num_workers) { +void AsyncShaders::AllocateWorkers() { + // Max worker threads we should allow + constexpr u32 MAX_THREADS = 4; + // Deduce how many threads we can use + const u32 threads_used = std::thread::hardware_concurrency() / 4; + // Always allow at least 1 thread regardless of our settings + const auto max_worker_count = std::max(1U, threads_used); + // Don't use more than MAX_THREADS + const auto num_workers = std::min(max_worker_count, MAX_THREADS); + // If we're already have workers queued or don't want to queue workers, ignore - if (num_workers == worker_threads.size() || num_workers == 0) { + if (num_workers == worker_threads.size()) { return; } |
