From 898187cfab5993924b53119a1d6fee28790e7258 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 8 Mar 2024 16:41:27 +0100 Subject: [PATCH 1/5] 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 --- intern/cycles/device/metal/device_impl.mm | 16 ++++++++++------ intern/cycles/kernel/geom/triangle.h | 2 ++ intern/cycles/kernel/types.h | 3 +++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/intern/cycles/device/metal/device_impl.mm b/intern/cycles/device/metal/device_impl.mm index b7fd6658f64..319a348db7f 100644 --- a/intern/cycles/device/metal/device_impl.mm +++ b/intern/cycles/device/metal/device_impl.mm @@ -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. */ diff --git a/intern/cycles/kernel/geom/triangle.h b/intern/cycles/kernel/geom/triangle.h index d633364f925..d2c1172c963 100644 --- a/intern/cycles/kernel/geom/triangle.h +++ b/intern/cycles/kernel/geom/triangle.h @@ -10,6 +10,8 @@ #pragma once +#include "util/color.h" + CCL_NAMESPACE_BEGIN /* Normal on triangle. */ diff --git a/intern/cycles/kernel/types.h b/intern/cycles/kernel/types.h index b50a0c192a1..0c1b67b9b34 100644 --- a/intern/cycles/kernel/types.h +++ b/intern/cycles/kernel/types.h @@ -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. */ From 940fed49e0fe9210dcba9a0a690773cc6e23b8fc Mon Sep 17 00:00:00 2001 From: Ray Molenkamp Date: Fri, 8 Mar 2024 09:14:05 -0700 Subject: [PATCH 2/5] Windows_Libs: OSL 1.13.7, OIDN 2.2.1 --- lib/windows_x64 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/windows_x64 b/lib/windows_x64 index 71e6832c48d..eed1bd0a11b 160000 --- a/lib/windows_x64 +++ b/lib/windows_x64 @@ -1 +1 @@ -Subproject commit 71e6832c48d25b4929bcdfc1637ababab843e551 +Subproject commit eed1bd0a11b434182b3ba7c9f3ecaf752f4e3736 From 850b89ba511f12b066e10b446e868721035c25ce Mon Sep 17 00:00:00 2001 From: Ray Molenkamp Date: Fri, 8 Mar 2024 10:01:44 -0700 Subject: [PATCH 3/5] deps_builder: fix URI for the blender mirror of the source packages This was still using the SVN repository, which isn't used any more since the migration to git lfs. --- build_files/build_environment/cmake/download.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build_files/build_environment/cmake/download.cmake b/build_files/build_environment/cmake/download.cmake index 0b59bee3aef..f566fa520c7 100644 --- a/build_files/build_environment/cmake/download.cmake +++ b/build_files/build_environment/cmake/download.cmake @@ -12,9 +12,9 @@ function(download_source dep) if(PACKAGE_USE_UPSTREAM_SOURCES) set(TARGET_URI ${${dep}_URI}) elseif(BLENDER_VERSION) - set(TARGET_URI https://svn.blender.org/svnroot/bf-blender/tags/blender-${BLENDER_VERSION}-release/lib/packages/${TARGET_FILE}) + set(TARGET_URI https://projects.blender.org/blender/lib-source/media/branch/blender-v${BLENDER_VERSION}-release/${TARGET_FILE}) else() - set(TARGET_URI https://svn.blender.org/svnroot/bf-blender/trunk/lib/packages/${TARGET_FILE}) + set(TARGET_URI https://projects.blender.org/blender/lib-source/media/branch/main/${TARGET_FILE}) endif() # Validate all required variables are set and give an explicit error message # rather than CMake erroring out later on with a more ambigious error. From 1cca96067781f569c6bced0c4f363d71781df092 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Fri, 8 Mar 2024 18:33:35 +0100 Subject: [PATCH 4/5] Fix #103985: crash when using viewer node on curves with gpu subdivisions The `cache.curves_cache.proc_attributes_buf[i]` is independent of the subdivision level. Therefore it's not freed when the subdivision level changes currently. However, the check assumed that when no attribute was changed, the final subdivided buffer is non-zero, which is not true when the subdivision level changed. Now directly check whether the attribute is cached already. Pull Request: https://projects.blender.org/blender/blender/pulls/119216 --- source/blender/draw/intern/draw_cache_impl_curves.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/draw/intern/draw_cache_impl_curves.cc b/source/blender/draw/intern/draw_cache_impl_curves.cc index b05fec5d413..a6c8deb1024 100644 --- a/source/blender/draw/intern/draw_cache_impl_curves.cc +++ b/source/blender/draw/intern/draw_cache_impl_curves.cc @@ -565,7 +565,7 @@ static bool curves_ensure_attributes(const Curves &curves, for (const int i : IndexRange(final_cache.attr_used.num_requests)) { const DRW_AttributeRequest &request = final_cache.attr_used.requests[i]; - if (cache.curves_cache.proc_attributes_buf[i] != nullptr) { + if (cache.curves_cache.final[subdiv].attributes_buf[i] != nullptr) { continue; } From c4bf2d43e7a628bf598dd2a27ce412b118a224f9 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Fri, 8 Mar 2024 16:09:05 -0500 Subject: [PATCH 5/5] Fix #116395: Auto smooth versioning modifier added unnecessarily As mentioned in new code comments, the auto smooth behavior in 4.0 was to skip sharp angle tagging when the evaluated mesh had custom normals. There was already a check for custom normals on the original mesh (we can't access the evaluated mesh from versioning code). But that didn't handle cases where custom normals were created by modifiers (the normal edit and weighted normal modifiers). Now skip adding the new modifier when those modifiers come last in the stack. Alternatively we could check if they existed in the stack at all, but that seems a bit more risky. --- source/blender/blenkernel/intern/mesh_legacy_convert.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source/blender/blenkernel/intern/mesh_legacy_convert.cc b/source/blender/blenkernel/intern/mesh_legacy_convert.cc index 89d13d608f2..6836e234fe0 100644 --- a/source/blender/blenkernel/intern/mesh_legacy_convert.cc +++ b/source/blender/blenkernel/intern/mesh_legacy_convert.cc @@ -2250,8 +2250,17 @@ void BKE_main_mesh_legacy_convert_auto_smooth(Main &bmain) continue; } if (CustomData_has_layer(&mesh->corner_data, CD_CUSTOMLOOPNORMAL)) { + /* Auto-smooth disabled sharp edge tagging when the evaluated mesh had custom normals. + * When the original mesh has custom normals, that's a good sign the evaluated mesh will + * have custom normals as well. */ continue; } + if (ModifierData *last_md = static_cast(object->modifiers.last)) { + if (ELEM(last_md->type, eModifierType_WeightedNormal, eModifierType_NormalEdit)) { + /* These modifiers always generate custom normals which disabled sharp edge tagging. */ + continue; + } + } if (!auto_smooth_node_tree) { auto_smooth_node_tree = add_auto_smooth_node_tree(bmain); BKE_ntree_update_main_tree(&bmain, auto_smooth_node_tree, nullptr);