Commit: 6a8ce5ec1c550cbcaf2fbb8e05c0743b1bda40d2 Author: Patrick Mours Date: Thu Nov 10 19:27:07 2022 +0100 Branches: master https://developer.blender.org/rB6a8ce5ec1c550cbcaf2fbb8e05c0743b1bda40d2
Fix abort when rendering with OSL and OptiX in Cycles LLVM could kill the process during OSL PTX code generation, due to generated symbols contained invalid characters in their name. Those names are generated by Cycles and were not properly filtered: - If the locale was set to something other than the minimal locale (when Blender was built with WITH_INTERNATIONAL), pointers may be printed with grouping characters, like commas or dots, added to them. - Material names from Blender may contain the full range of UTF8 characters. This fixes those cases by forcing the locale used in the symbol name generation to the minimal locale and using the material name hash instead of the actual material name string. =================================================================== M intern/cycles/scene/osl.cpp =================================================================== diff --git a/intern/cycles/scene/osl.cpp b/intern/cycles/scene/osl.cpp index 3ea406b6935..4dc5fb4edf7 100644 --- a/intern/cycles/scene/osl.cpp +++ b/intern/cycles/scene/osl.cpp @@ -641,6 +641,8 @@ string OSLCompiler::id(ShaderNode *node) { /* assign layer unique name based on pointer address + bump mode */ stringstream stream; + stream.imbue(std::locale("C")); /* Ensure that no grouping characters (e.g. commas with en_US + locale) are added to the pointer string */ stream << "node_" << node->type->name << "_" << node; return stream.str(); @@ -1132,12 +1134,12 @@ OSL::ShaderGroupRef OSLCompiler::compile_type(Shader *shader, ShaderGraph *graph { current_type = type; - string name = shader->name.string(); - /* Replace invalid characters. */ - for (size_t i; (i = name.find_first_of(" .,:;+-*/#")) != string::npos;) - name.replace(i, 1, "_"); + /* Use name hash to identify shader group to avoid issues with non-alphanumeric characters */ + stringstream name; + name.imbue(std::locale("C")); + name << "shader_" << shader->name.hash(); - OSL::ShaderGroupRef group = ss->ShaderGroupBegin(name); + OSL::ShaderGroupRef group = ss->ShaderGroupBegin(name.str()); ShaderNode *output = graph->output(); ShaderNodeSet dependencies; _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs