Cycles: Metal cherrypicks from 4.0 into 3.6 #114399

Merged

5 Commits

Author SHA1 Message Date
Michael Jones (Apple) 98928d2dac Cycles: Metal: Fix occasional anim corruption (KernelData MD5 refresh bug)
This fixes an issue where animation frames occasionally get corrupted (e.g. when rendering "Pokedstudio" Blender 2.77 splash screen). This happens when the KernelData is refreshed but the MD5 isn't immediately regenerated which can cause the wrong PSO to be selected.

Pull Request: #114153
2023-11-02 12:52:33 +00:00
Michael Jones (Apple) 25636c815e Cycles: Fix animation hangs/crashes in Metal due to leaking temp objects
This PR adds `@autoreleasepool` blocks around functions that have been observed to create hidden temporary NSObjects, and eventually cause command buffer failures. A couple of allocations needed to be tweaked in order to maintain correct retain/release behaviour. This PR also fixes the command buffer error text to show more useful information.

(clone of https://projects.blender.org/blender/blender/commit/4e3ee4f02)
2023-11-02 12:51:38 +00:00
Michael Jones (Apple) 11857d056e Cycles: Fix #107714: Leak during MetalRT BVH buid
This patch fixes the memory leak described in #107714 by adding an `@autoreleasepool` around Metal BVH builds. Certain NSObjects were being retained indefinitely, specifically ones which had been value-passed via an NSArray into acceleration structure descriptors.

Pull Request: #112820
2023-11-02 12:50:11 +00:00
Michael Jones (Apple) ba037d3cc2 Cycles: Disable NanoVDB if not needed when specialising Metal PSOs
This patch adds a check to see whether we're actually using NanoVDB textures, and if not, removes `#define WITH_NANOVDB` when generating the scene-optimised kernels. This results in marginally faster render times (maybe 2 or 3%) for scenes that do not use NanoVDB. The generic kernels are unaffected, so this will not impact responsiveness on first render.

Pull Request: #112822
2023-11-02 12:49:24 +00:00
Michael Jones (Apple) faedda7a7a Cycles: Make use of maximum concurrent compilations on Metal
This patch queries the MTLDevice `maximumConcurrentCompilationTaskCount` property (macOS >= 13.3) to spawn more compilation threads if available.

Pull Request: #109689
2023-11-02 12:48:29 +00:00