Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Mours <pmours@nvidia.com>2022-11-10 21:27:07 +0300
committerPatrick Mours <pmours@nvidia.com>2022-11-10 21:31:59 +0300
commit6a8ce5ec1c550cbcaf2fbb8e05c0743b1bda40d2 (patch)
treea1ec81823c3cd2600658874f8708d9244b56d5db
parent2688d7200aa3766a60456f097c3e939ec80ebba8 (diff)
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.
-rw-r--r--intern/cycles/scene/osl.cpp12
1 files changed, 7 insertions, 5 deletions
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;