Fix #118466: Cycles renders black on Metal + AMD

Global built-ins appear to not work on AMD cards.

Also add a tweak to avoid a performance regression, similar
to what was done before. Disable adaptive subdivision kernel
code if not used.

Pull Request: https://projects.blender.org/blender/blender/pulls/119175
This commit is contained in:
Brecht Van Lommel 2024-03-08 16:41:27 +01:00 committed by Brecht Van Lommel
parent 2191cbf7f5
commit 898187cfab
3 changed files with 15 additions and 6 deletions

@ -340,11 +340,6 @@ string MetalDevice::preprocess_source(MetalPipelineType pso_type,
}
}
if (@available(macos 14.0, *)) {
/* Use Program Scope Global Built-ins, when available. */
global_defines += "#define __METAL_GLOBAL_BUILTINS__\n";
}
# ifdef WITH_CYCLES_DEBUG
global_defines += "#define __KERNEL_DEBUG__\n";
# endif
@ -359,13 +354,22 @@ string MetalDevice::preprocess_source(MetalPipelineType pso_type,
global_defines += "#define __KERNEL_METAL_AMD__\n";
/* The increased amount of BSDF code leads to a big performance regression
* on AMD. There is currently no workaround to fix this general. Instead
* disable Principled Hair. */
* disable Principled Hair and patch evaluation. */
if (kernel_features & KERNEL_FEATURE_NODE_PRINCIPLED_HAIR) {
global_defines += "#define WITH_PRINCIPLED_HAIR\n";
}
if (kernel_features & KERNEL_FEATURE_PATCH_EVALUATION) {
global_defines += "#define WITH_PATCH_EVAL\n";
}
break;
case METAL_GPU_APPLE:
global_defines += "#define __KERNEL_METAL_APPLE__\n";
if (@available(macos 14.0, *)) {
/* Use Program Scope Global Built-ins, when available. */
global_defines += "#define __METAL_GLOBAL_BUILTINS__\n";
}
# ifdef WITH_NANOVDB
/* Compiling in NanoVDB results in a marginal drop in render performance,
* so disable it for specialized PSOs when no textures are using it. */

@ -10,6 +10,8 @@
#pragma once
#include "util/color.h"
CCL_NAMESPACE_BEGIN
/* Normal on triangle. */

@ -116,6 +116,9 @@ CCL_NAMESPACE_BEGIN
# ifndef WITH_PRINCIPLED_HAIR
# undef __PRINCIPLED_HAIR__
# endif
# ifndef WITH_PATCH_EVAL
# undef __PATCH_EVAL__
# endif
#endif
/* Scene-based selective features compilation. */