Cycles: Fix race condition in attributes creation during SVM compilation
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 5 Apr 2017 12:57:54 +0000 (14:57 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 5 Apr 2017 12:57:54 +0000 (14:57 +0200)
intern/cycles/render/svm.cpp
intern/cycles/render/svm.h

index 48287d872d4fa94b25a9b8371b71e9ddfbd28993..9cf3f4cb0b2e491735b17fb33ee98857fb3b9611 100644 (file)
@@ -393,11 +393,13 @@ void SVMCompiler::add_node(const float4& f)
 
 uint SVMCompiler::attribute(ustring name)
 {
+       thread_scoped_spin_lock lock(attribute_lock_);
        return shader_manager->get_attribute_id(name);
 }
 
 uint SVMCompiler::attribute(AttributeStandard std)
 {
+       thread_scoped_spin_lock lock(attribute_lock_);
        return shader_manager->get_attribute_id(std);
 }
 
index abbd9e50610419b92d159e96bf11fcb875a976c2..eef344a506e4cc527fdbee7c1a9a49f8c0517acc 100644 (file)
@@ -218,6 +218,8 @@ protected:
        int max_stack_use;
        uint mix_weight_offset;
        bool compile_failed;
+
+       thread_spin_lock attribute_lock_;
 };
 
 CCL_NAMESPACE_END