forked from bartvdbraak/blender
Cycles: Solve threading conflict in shader synchronization
Update tag might access links (when checking for attributes) and the links might be in the middle of rebuild in simplification logic.
This commit is contained in:
parent
27d20a04b5
commit
90df1142a3
@ -1158,6 +1158,13 @@ static void add_nodes(Scene *scene,
|
|||||||
|
|
||||||
/* Sync Materials */
|
/* Sync Materials */
|
||||||
|
|
||||||
|
void BlenderSync::sync_materials_simpligy(Shader *shader)
|
||||||
|
{
|
||||||
|
ShaderGraph *graph = shader->graph;
|
||||||
|
graph->simplify(scene);
|
||||||
|
shader->tag_update(scene);
|
||||||
|
}
|
||||||
|
|
||||||
void BlenderSync::sync_materials(bool update_all)
|
void BlenderSync::sync_materials(bool update_all)
|
||||||
{
|
{
|
||||||
shader_map.set_default(scene->default_surface);
|
shader_map.set_default(scene->default_surface);
|
||||||
@ -1203,17 +1210,26 @@ void BlenderSync::sync_materials(bool update_all)
|
|||||||
|
|
||||||
shader->set_graph(graph);
|
shader->set_graph(graph);
|
||||||
|
|
||||||
/* By simplifying the shader graph as soon as possible, some redundant shader nodes
|
/* By simplifying the shader graph as soon as possible, some
|
||||||
* might be removed which prevents loading unneccessary attributes later.
|
* redundant shader nodes might be removed which prevents loading
|
||||||
|
* unnecessary attributes later.
|
||||||
*
|
*
|
||||||
* However, since graph simplification also accounts for e.g. mix weight, this would
|
* However, since graph simplification also accounts for e.g. mix
|
||||||
* cause frequent expensive resyncs in interactive sessions, so for those sessions
|
* weight, this would cause frequent expensive resyncs in interactive
|
||||||
* optimization is only performed right before compiling. */
|
* sessions, so for those sessions optimization is only performed
|
||||||
|
* right before compiling.
|
||||||
|
*/
|
||||||
if(!preview) {
|
if(!preview) {
|
||||||
pool.push(function_bind(&ShaderGraph::simplify, shader->graph, scene));
|
pool.push(function_bind(&BlenderSync::sync_materials_simpligy,
|
||||||
|
this,
|
||||||
|
shader));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* NOTE: Update tagging can access links which are being
|
||||||
|
* optimized out.
|
||||||
|
*/
|
||||||
|
shader->tag_update(scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
shader->tag_update(scene);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,6 +96,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
/* sync */
|
/* sync */
|
||||||
void sync_lamps(bool update_all);
|
void sync_lamps(bool update_all);
|
||||||
|
void sync_materials_simpligy(Shader *shader);
|
||||||
void sync_materials(bool update_all);
|
void sync_materials(bool update_all);
|
||||||
void sync_objects(BL::SpaceView3D& b_v3d, float motion_time = 0.0f);
|
void sync_objects(BL::SpaceView3D& b_v3d, float motion_time = 0.0f);
|
||||||
void sync_motion(BL::RenderSettings& b_render,
|
void sync_motion(BL::RenderSettings& b_render,
|
||||||
|
Loading…
Reference in New Issue
Block a user