Cycles: Fix race condition in shader attribute for real now
authorSergey Sharybin <sergey.vfx@gmail.com>
Mon, 10 Apr 2017 14:53:01 +0000 (16:53 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 10 Apr 2017 14:53:01 +0000 (16:53 +0200)
Ended up moving lock in the more centralized space since multiple shaders
can access this map.

intern/cycles/render/shader.cpp
intern/cycles/render/shader.h
intern/cycles/render/svm.cpp
intern/cycles/render/svm.h

index 12d3c6cf83299777134dbdd4a090f907b2a2de07..23eee1916bd95951acec7d9581d0edfcd8fdf6dd 100644 (file)
@@ -332,6 +332,8 @@ ShaderManager *ShaderManager::create(Scene *scene, int shadingsystem)
 
 uint ShaderManager::get_attribute_id(ustring name)
 {
+       thread_scoped_spin_lock lock(attribute_lock_);
+
        /* get a unique id for each name, for SVM attribute lookup */
        AttributeIDMap::iterator it = unique_attribute_id.find(name);
 
index 87fef19c59216aee7e1ee68fabd1a02b53a95c1f..a8018231f1a3bb2dc37e08bdd48cbd8b0ae3d34c 100644 (file)
@@ -202,6 +202,8 @@ protected:
 
        void get_requested_graph_features(ShaderGraph *graph,
                                          DeviceRequestedFeatures *requested_features);
+
+       thread_spin_lock attribute_lock_;
 };
 
 CCL_NAMESPACE_END
index 9cf3f4cb0b2e491735b17fb33ee98857fb3b9611..48287d872d4fa94b25a9b8371b71e9ddfbd28993 100644 (file)
@@ -393,13 +393,11 @@ 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 eef344a506e4cc527fdbee7c1a9a49f8c0517acc..abbd9e50610419b92d159e96bf11fcb875a976c2 100644 (file)
@@ -218,8 +218,6 @@ protected:
        int max_stack_use;
        uint mix_weight_offset;
        bool compile_failed;
-
-       thread_spin_lock attribute_lock_;
 };
 
 CCL_NAMESPACE_END