diff options
author | Michael Jones <michael_p_jones@apple.com> | 2022-10-12 19:06:06 +0300 |
---|---|---|
committer | Michael Jones <michael_p_jones@apple.com> | 2022-10-12 19:06:50 +0300 |
commit | ba67a383fa3931b95bebd9ce92c9fc71928fb409 (patch) | |
tree | eeadd7d8a622dcd80f70ef64d8a28cb96e421436 /intern/cycles | |
parent | d586f8962de4037a3aceb3da9aa13a02862d0d3c (diff) |
Cycles: Enable MNEE on Metal (macOS >= 13)
This patch enables MNEE on macOS >= 13. There was an inefficiency in the calculation of spill requirements, fixed as of macOS 13. This patch also adds a temporary inlining workaround for a Metal compiler bug which causes `mnee_compute_constraint_derivatives` to behave incorrectly.
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D16235
Diffstat (limited to 'intern/cycles')
-rw-r--r-- | intern/cycles/device/metal/device_impl.mm | 4 | ||||
-rw-r--r-- | intern/cycles/kernel/integrator/mnee.h | 10 | ||||
-rw-r--r-- | intern/cycles/kernel/types.h | 6 |
3 files changed, 16 insertions, 4 deletions
diff --git a/intern/cycles/device/metal/device_impl.mm b/intern/cycles/device/metal/device_impl.mm index d1250b83d22..6a16d4bb3b4 100644 --- a/intern/cycles/device/metal/device_impl.mm +++ b/intern/cycles/device/metal/device_impl.mm @@ -254,6 +254,10 @@ void MetalDevice::make_source(MetalPipelineType pso_type, const uint kernel_feat break; } + NSProcessInfo *processInfo = [NSProcessInfo processInfo]; + NSOperatingSystemVersion macos_ver = [processInfo operatingSystemVersion]; + global_defines += "#define __KERNEL_METAL_MACOS__ " + to_string(macos_ver.majorVersion) + "\n"; + string &source = this->source[pso_type]; source = "\n#include \"kernel/device/metal/kernel.metal\"\n"; source = path_source_replace_includes(source, path_get("source")); diff --git a/intern/cycles/kernel/integrator/mnee.h b/intern/cycles/kernel/integrator/mnee.h index 038f0379bbc..23885306885 100644 --- a/intern/cycles/kernel/integrator/mnee.h +++ b/intern/cycles/kernel/integrator/mnee.h @@ -279,7 +279,15 @@ ccl_device_forceinline void mnee_setup_manifold_vertex(KernelGlobals kg, } /* Compute constraint derivatives. */ -ccl_device_forceinline bool mnee_compute_constraint_derivatives( + +# if defined(__KERNEL_METAL__) +/* Temporary workaround for front-end compilation bug (incorrect MNEE rendering when this is + * inlined). */ +__attribute__((noinline)) +# else +ccl_device_forceinline +# endif +bool mnee_compute_constraint_derivatives( int vertex_count, ccl_private ManifoldVertex *vertices, ccl_private const float3 &surface_sample_pos, diff --git a/intern/cycles/kernel/types.h b/intern/cycles/kernel/types.h index 1469d915d15..8f7cfd19169 100644 --- a/intern/cycles/kernel/types.h +++ b/intern/cycles/kernel/types.h @@ -85,9 +85,9 @@ CCL_NAMESPACE_BEGIN # define __VOLUME_RECORD_ALL__ #endif /* !__KERNEL_GPU__ */ -/* MNEE currently causes "Compute function exceeds available temporary registers" - * on Metal, disabled for now. */ -#ifndef __KERNEL_METAL__ +/* MNEE caused "Compute function exceeds available temporary registers" in macOS < 13 due to a bug + * in spill buffer allocation sizing. */ +#if !defined(__KERNEL_METAL__) || (__KERNEL_METAL_MACOS__ >= 13) # define __MNEE__ #endif |