From 95fa9cbbd89ce10378ba71bb8ecb1b347fa48003 Mon Sep 17 00:00:00 2001 From: Dario Date: Sun, 5 May 2024 12:49:03 -0300 Subject: [PATCH] Add idle thread priority option, use it in shader compilation threads. --- src/common/rt64_thread.cpp | 2 ++ src/common/rt64_thread.h | 1 + src/render/rt64_raster_shader_cache.cpp | 4 ++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/common/rt64_thread.cpp b/src/common/rt64_thread.cpp index d483d37..3af7910 100644 --- a/src/common/rt64_thread.cpp +++ b/src/common/rt64_thread.cpp @@ -18,6 +18,8 @@ namespace RT64 { # if defined(_WIN32) static int toWindowsPriority(Thread::Priority priority) { switch (priority) { + case Thread::Priority::Idle: + return THREAD_PRIORITY_IDLE; case Thread::Priority::Lowest: return THREAD_PRIORITY_LOWEST; case Thread::Priority::Low: diff --git a/src/common/rt64_thread.h b/src/common/rt64_thread.h index 1285cae..e7d8c5f 100644 --- a/src/common/rt64_thread.h +++ b/src/common/rt64_thread.h @@ -10,6 +10,7 @@ namespace RT64 { struct Thread { enum class Priority { + Idle, Lowest, Low, Normal, diff --git a/src/render/rt64_raster_shader_cache.cpp b/src/render/rt64_raster_shader_cache.cpp index 23e00d1..ce13aa2 100644 --- a/src/render/rt64_raster_shader_cache.cpp +++ b/src/render/rt64_raster_shader_cache.cpp @@ -141,8 +141,8 @@ namespace RT64 { void RasterShaderCache::CompilationThread::loop() { Thread::setCurrentThreadName("RT64 Shader"); - // The shader compilation thread should have the lowest priority by default as the application can use the ubershader in the meantime. - Thread::setCurrentThreadPriority(Thread::Priority::Lowest); + // The shader compilation thread should have idle priority by default as the application can use the ubershader in the meantime. + Thread::setCurrentThreadPriority(Thread::Priority::Idle); threadRunning = true;