Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Gavrilov <angavrilov@gmail.com>2020-10-31 19:21:07 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2020-11-03 16:35:43 +0300
commit91d320edc3cfb30443af4adbcb09bc3d7a609e1d (patch)
tree5fa112217c986e516ff30e3ba95556bc2b94d7ce /intern/cycles/blender
parent9bc177d8ded4ba498762813a0d5106005fef0e67 (diff)
Cycles: immediately store the used_shader list in Blender interface.
Uniform attributes require immediate access to the shader list in object update code, so setting the field can't be deferred to a background task. This required adding a parameter to the clear method of Geometry. Ref D2057
Diffstat (limited to 'intern/cycles/blender')
-rw-r--r--intern/cycles/blender/blender_curves.cpp10
-rw-r--r--intern/cycles/blender/blender_geometry.cpp9
-rw-r--r--intern/cycles/blender/blender_mesh.cpp8
-rw-r--r--intern/cycles/blender/blender_sync.h12
-rw-r--r--intern/cycles/blender/blender_volume.cpp7
5 files changed, 16 insertions, 30 deletions
diff --git a/intern/cycles/blender/blender_curves.cpp b/intern/cycles/blender/blender_curves.cpp
index 6288c370567..32aa25354c4 100644
--- a/intern/cycles/blender/blender_curves.cpp
+++ b/intern/cycles/blender/blender_curves.cpp
@@ -352,7 +352,7 @@ static void ExportCurveSegments(Scene *scene, Hair *hair, ParticleCurveData *CDa
/* check allocation */
if ((hair->curve_keys.size() != num_keys) || (hair->num_curves() != num_curves)) {
VLOG(1) << "Allocation failed, clearing data";
- hair->clear();
+ hair->clear(true);
}
}
@@ -817,10 +817,7 @@ void BlenderSync::sync_hair(Hair *hair, BL::Object &b_ob, bool motion, int motio
}
#endif
-void BlenderSync::sync_hair(BL::Depsgraph b_depsgraph,
- BL::Object b_ob,
- Hair *hair,
- const vector<Shader *> &used_shaders)
+void BlenderSync::sync_hair(BL::Depsgraph b_depsgraph, BL::Object b_ob, Hair *hair)
{
/* Compares curve_keys rather than strands in order to handle quick hair
* adjustments in dynamic BVH - other methods could probably do this better. */
@@ -829,8 +826,7 @@ void BlenderSync::sync_hair(BL::Depsgraph b_depsgraph,
oldcurve_keys.steal_data(hair->curve_keys);
oldcurve_radius.steal_data(hair->curve_radius);
- hair->clear();
- hair->used_shaders = used_shaders;
+ hair->clear(true);
if (view_layer.use_hair) {
if (b_ob.type() == BL::Object::type_HAIR) {
diff --git a/intern/cycles/blender/blender_geometry.cpp b/intern/cycles/blender/blender_geometry.cpp
index c7637fe8608..c9ac9d1068d 100644
--- a/intern/cycles/blender/blender_geometry.cpp
+++ b/intern/cycles/blender/blender_geometry.cpp
@@ -138,6 +138,9 @@ Geometry *BlenderSync::sync_geometry(BL::Depsgraph &b_depsgraph,
geom->name = ustring(b_ob_data.name().c_str());
+ /* Store the shaders immediately for the object attribute code. */
+ geom->used_shaders = used_shaders;
+
auto sync_func = [=]() mutable {
if (progress.get_cancel())
return;
@@ -146,15 +149,15 @@ Geometry *BlenderSync::sync_geometry(BL::Depsgraph &b_depsgraph,
if (geom_type == Geometry::HAIR) {
Hair *hair = static_cast<Hair *>(geom);
- sync_hair(b_depsgraph, b_ob, hair, used_shaders);
+ sync_hair(b_depsgraph, b_ob, hair);
}
else if (geom_type == Geometry::VOLUME) {
Volume *volume = static_cast<Volume *>(geom);
- sync_volume(b_ob, volume, used_shaders);
+ sync_volume(b_ob, volume);
}
else {
Mesh *mesh = static_cast<Mesh *>(geom);
- sync_mesh(b_depsgraph, b_ob, mesh, used_shaders);
+ sync_mesh(b_depsgraph, b_ob, mesh);
}
};
diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp
index e40e1f5f001..1438bfad2b9 100644
--- a/intern/cycles/blender/blender_mesh.cpp
+++ b/intern/cycles/blender/blender_mesh.cpp
@@ -1023,10 +1023,7 @@ static void sync_mesh_fluid_motion(BL::Object &b_ob, Scene *scene, Mesh *mesh)
}
}
-void BlenderSync::sync_mesh(BL::Depsgraph b_depsgraph,
- BL::Object b_ob,
- Mesh *mesh,
- const vector<Shader *> &used_shaders)
+void BlenderSync::sync_mesh(BL::Depsgraph b_depsgraph, BL::Object b_ob, Mesh *mesh)
{
array<int> oldtriangles;
array<Mesh::SubdFace> oldsubd_faces;
@@ -1035,8 +1032,7 @@ void BlenderSync::sync_mesh(BL::Depsgraph b_depsgraph,
oldsubd_faces.steal_data(mesh->subd_faces);
oldsubd_face_corners.steal_data(mesh->subd_face_corners);
- mesh->clear();
- mesh->used_shaders = used_shaders;
+ mesh->clear(true);
mesh->subdivision_type = Mesh::SUBDIVISION_NONE;
diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h
index a17db128957..360468da0ef 100644
--- a/intern/cycles/blender/blender_sync.h
+++ b/intern/cycles/blender/blender_sync.h
@@ -150,20 +150,14 @@ class BlenderSync {
TaskPool *geom_task_pool);
/* Volume */
- void sync_volume(BL::Object &b_ob, Volume *volume, const vector<Shader *> &used_shaders);
+ void sync_volume(BL::Object &b_ob, Volume *volume);
/* Mesh */
- void sync_mesh(BL::Depsgraph b_depsgraph,
- BL::Object b_ob,
- Mesh *mesh,
- const vector<Shader *> &used_shaders);
+ void sync_mesh(BL::Depsgraph b_depsgraph, BL::Object b_ob, Mesh *mesh);
void sync_mesh_motion(BL::Depsgraph b_depsgraph, BL::Object b_ob, Mesh *mesh, int motion_step);
/* Hair */
- void sync_hair(BL::Depsgraph b_depsgraph,
- BL::Object b_ob,
- Hair *hair,
- const vector<Shader *> &used_shaders);
+ void sync_hair(BL::Depsgraph b_depsgraph, BL::Object b_ob, Hair *hair);
void sync_hair_motion(BL::Depsgraph b_depsgraph, BL::Object b_ob, Hair *hair, int motion_step);
void sync_hair(Hair *hair, BL::Object &b_ob, bool motion, int motion_step = 0);
void sync_particle_hair(
diff --git a/intern/cycles/blender/blender_volume.cpp b/intern/cycles/blender/blender_volume.cpp
index e039d8a4895..7ecfd3583d6 100644
--- a/intern/cycles/blender/blender_volume.cpp
+++ b/intern/cycles/blender/blender_volume.cpp
@@ -320,14 +320,11 @@ static vector<int> get_voxel_image_slots(Mesh *mesh)
return slots;
}
-void BlenderSync::sync_volume(BL::Object &b_ob,
- Volume *volume,
- const vector<Shader *> &used_shaders)
+void BlenderSync::sync_volume(BL::Object &b_ob, Volume *volume)
{
vector<int> old_voxel_slots = get_voxel_image_slots(volume);
- volume->clear();
- volume->used_shaders = used_shaders;
+ volume->clear(true);
if (view_layer.use_volumes) {
if (b_ob.type() == BL::Object::type_VOLUME) {