From fc604a0be3a9ad1bf7f646dd70d4f106c7df2a75 Mon Sep 17 00:00:00 2001 From: Michael Jones Date: Tue, 27 Sep 2022 14:34:37 +0100 Subject: Cycles: Disable binary archives on macOS < 13.0 An bug with binary archives was fixed in macOS 13.0 which stops some spurious kernel recompilations. In older macOS versions, falling back on the system shader cache will prevent recompilations in most instances (this is the same behaviour as in Blender 3.1.x and 3.2.x). Reviewed By: brecht Differential Revision: https://developer.blender.org/D16082 --- intern/cycles/device/metal/kernel.mm | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'intern/cycles/device/metal/kernel.mm') diff --git a/intern/cycles/device/metal/kernel.mm b/intern/cycles/device/metal/kernel.mm index 385cb412b06..172c456f0c0 100644 --- a/intern/cycles/device/metal/kernel.mm +++ b/intern/cycles/device/metal/kernel.mm @@ -308,26 +308,29 @@ MetalKernelPipeline *ShaderCache::get_best_pipeline(DeviceKernel kernel, const M bool MetalKernelPipeline::should_use_binary_archive() const { - if (auto str = getenv("CYCLES_METAL_DISABLE_BINARY_ARCHIVES")) { - if (atoi(str) != 0) { - /* Don't archive if we have opted out by env var. */ - return false; + /* Issues with binary archives in older macOS versions. */ + if (@available(macOS 13.0, *)) { + if (auto str = getenv("CYCLES_METAL_DISABLE_BINARY_ARCHIVES")) { + if (atoi(str) != 0) { + /* Don't archive if we have opted out by env var. */ + return false; + } } - } - if (pso_type == PSO_GENERIC) { - /* Archive the generic kernels. */ - return true; - } + if (pso_type == PSO_GENERIC) { + /* Archive the generic kernels. */ + return true; + } - if (device_kernel >= DEVICE_KERNEL_INTEGRATOR_SHADE_BACKGROUND && - device_kernel <= DEVICE_KERNEL_INTEGRATOR_SHADE_SHADOW) { - /* Archive all shade kernels - they take a long time to compile. */ - return true; - } + if (device_kernel >= DEVICE_KERNEL_INTEGRATOR_SHADE_BACKGROUND && + device_kernel <= DEVICE_KERNEL_INTEGRATOR_SHADE_SHADOW) { + /* Archive all shade kernels - they take a long time to compile. */ + return true; + } - /* The remaining kernels are all fast to compile. They may get cached by the system shader cache, - * but will be quick to regenerate if not. */ + /* The remaining kernels are all fast to compile. They may get cached by the system shader cache, + * but will be quick to regenerate if not. */ + } return false; } -- cgit v1.2.3 From 72a7f107d84293ceeef92e54362127446dddc9df Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 28 Sep 2022 09:41:07 +1000 Subject: Cleanup: format --- intern/cycles/device/metal/kernel.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'intern/cycles/device/metal/kernel.mm') diff --git a/intern/cycles/device/metal/kernel.mm b/intern/cycles/device/metal/kernel.mm index 172c456f0c0..5e0cb6d18f4 100644 --- a/intern/cycles/device/metal/kernel.mm +++ b/intern/cycles/device/metal/kernel.mm @@ -328,8 +328,8 @@ bool MetalKernelPipeline::should_use_binary_archive() const return true; } - /* The remaining kernels are all fast to compile. They may get cached by the system shader cache, - * but will be quick to regenerate if not. */ + /* The remaining kernels are all fast to compile. They may get cached by the system shader + * cache, but will be quick to regenerate if not. */ } return false; } -- cgit v1.2.3