From b0fcd55aed210cb9aa4a9724123e63a2aa248b16 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 20 Feb 2025 16:32:44 +0100 Subject: [PATCH] Fix: Cycles OSL random texture issue on macOS ARM Shader compilation is multithreaded, this needs to be atomic. Pull Request: https://projects.blender.org/blender/blender/pulls/134854 --- intern/cycles/scene/osl.cpp | 2 +- intern/cycles/scene/osl.h | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/intern/cycles/scene/osl.cpp b/intern/cycles/scene/osl.cpp index 5bc5fe58cba..0364393f7fd 100644 --- a/intern/cycles/scene/osl.cpp +++ b/intern/cycles/scene/osl.cpp @@ -48,7 +48,7 @@ map> OSLShaderManager::ss_shared; int OSLShaderManager::ss_shared_users = 0; thread_mutex OSLShaderManager::ss_shared_mutex; -int OSLCompiler::texture_shared_unique_id = 0; +std::atomic OSLCompiler::texture_shared_unique_id = 0; /* Shader Manager */ diff --git a/intern/cycles/scene/osl.h b/intern/cycles/scene/osl.h index bf6d260f292..ba4e88fbaac 100644 --- a/intern/cycles/scene/osl.h +++ b/intern/cycles/scene/osl.h @@ -4,6 +4,8 @@ #pragma once +#include + #include "util/array.h" #include "util/set.h" #include "util/string.h" @@ -180,7 +182,7 @@ class OSLCompiler { ShaderType current_type; Shader *current_shader; - static int texture_shared_unique_id; + static std::atomic texture_shared_unique_id; }; CCL_NAMESPACE_END