Merge remote-tracking branch 'origin/master' into blender2.8
authorDalai Felinto <dfelinto@gmail.com>
Fri, 6 Oct 2017 16:09:24 +0000 (13:09 -0300)
committerDalai Felinto <dfelinto@gmail.com>
Fri, 6 Oct 2017 16:09:24 +0000 (13:09 -0300)
intern/cycles/render/shader.cpp
intern/cycles/render/shader.h

index 86378dfb4952eccf6e96966e4738860e4b0d0644..864875361c0522b74683a95f3a98f68d98c8f600 100644 (file)
@@ -33,7 +33,9 @@
 
 CCL_NAMESPACE_BEGIN
 
+thread_mutex ShaderManager::lookup_table_mutex;
 vector<float> ShaderManager::beckmann_table;
+bool ShaderManager::beckmann_table_ready = false;
 
 /* Beckmann sampling precomputed table, see bsdf_microfacet.h */
 
@@ -482,10 +484,11 @@ void ShaderManager::device_update_common(Device *device,
 
        /* beckmann lookup table */
        if(beckmann_table_offset == TABLE_OFFSET_INVALID) {
-               if(beckmann_table.size() == 0) {
+               if(!beckmann_table_ready) {
                        thread_scoped_lock lock(lookup_table_mutex);
-                       if(beckmann_table.size() == 0) {
+                       if(!beckmann_table_ready) {
                                beckmann_table_build(beckmann_table);
+                               beckmann_table_ready = true;
                        }
                }
                beckmann_table_offset = scene->lookup_tables->add_table(dscene, beckmann_table);
index 79a67d6756ac45ccffca2b5db855731b8100fd4d..3fdcd3c0c5be356d7f4065b1901b93999e1e2aea 100644 (file)
@@ -200,8 +200,9 @@ protected:
        typedef unordered_map<ustring, uint, ustringHash> AttributeIDMap;
        AttributeIDMap unique_attribute_id;
 
-       thread_mutex lookup_table_mutex;
+       static thread_mutex lookup_table_mutex;
        static vector<float> beckmann_table;
+       static bool beckmann_table_ready;
 
        size_t beckmann_table_offset;