Cycles: Guard global write access in SVM compilation code

This commit is contained in:
Sergey Sharybin 2017-04-05 14:21:49 +02:00
parent e4c5441286
commit 424901ad7b

@ -67,6 +67,7 @@ void SVMShaderManager::device_update_shader(Scene *scene,
<< "Shader name: " << shader->name << "\n" << "Shader name: " << shader->name << "\n"
<< summary.full_report(); << summary.full_report();
nodes_lock_.lock();
if(shader->use_mis && shader->has_surface_emission) { if(shader->use_mis && shader->has_surface_emission) {
scene->light_manager->need_update = true; scene->light_manager->need_update = true;
} }
@ -74,7 +75,6 @@ void SVMShaderManager::device_update_shader(Scene *scene,
/* The copy needs to be done inside the lock, if another thread resizes the array /* The copy needs to be done inside the lock, if another thread resizes the array
* while memcpy is running, it'll be copying into possibly invalid/freed ram. * while memcpy is running, it'll be copying into possibly invalid/freed ram.
*/ */
nodes_lock_.lock();
size_t global_nodes_size = global_svm_nodes->size(); size_t global_nodes_size = global_svm_nodes->size();
global_svm_nodes->resize(global_nodes_size + svm_nodes.size()); global_svm_nodes->resize(global_nodes_size + svm_nodes.size());