From becc2fa9cbd51ebac8a667bbff55d31fdb9223d5 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 30 May 2025 17:31:47 +0200 Subject: [PATCH] Fix: Metal parallel shader compilation does not respect -t option This command line option to control the number of threads was already taken into account for OpenGL and Vulkan. --- source/blender/gpu/metal/mtl_backend.mm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/blender/gpu/metal/mtl_backend.mm b/source/blender/gpu/metal/mtl_backend.mm index fd732b1a3f9..b62888db742 100644 --- a/source/blender/gpu/metal/mtl_backend.mm +++ b/source/blender/gpu/metal/mtl_backend.mm @@ -8,6 +8,8 @@ #include +#include "BLI_threads.h" + #include "BKE_global.hh" #include "gpu_backend.hh" @@ -523,8 +525,10 @@ void MTLBackend::capabilities_init(MTLContext *ctx) GCaps.geometry_shader_support = false; - /* Compile shaders on performance cores but leave one free so UI is still responsive */ - GCaps.max_parallel_compilations = MTLBackend::capabilities.num_performance_cores - 1; + /* Compile shaders on performance cores but leave one free so UI is still responsive. + * Also respect command line option to reduce number of threads. */ + GCaps.max_parallel_compilations = std::min(BLI_system_thread_count(), + MTLBackend::capabilities.num_performance_cores - 1); /* Maximum buffer bindings: 31. Consider required slot for uniforms/UBOs/Vertex attributes. * Can use argument buffers if a higher limit is required. */