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
This commit is contained in:
parent
9bc177d8de
commit
91d320edc3
Notes:
blender-bot
2023-04-19 22:54:54 +02:00
Referenced by issue #82521, Bump OpenImageIO minimum version 1.8 > 2.2.1 for install_deps.sh
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -81,9 +81,11 @@ Geometry::~Geometry()
|
|||
delete bvh;
|
||||
}
|
||||
|
||||
void Geometry::clear()
|
||||
void Geometry::clear(bool preserve_shaders)
|
||||
{
|
||||
used_shaders.clear();
|
||||
if (!preserve_shaders)
|
||||
used_shaders.clear();
|
||||
|
||||
transform_applied = false;
|
||||
transform_negative_scaled = false;
|
||||
transform_normal = transform_identity();
|
||||
|
|
|
@ -99,7 +99,7 @@ class Geometry : public Node {
|
|||
virtual ~Geometry();
|
||||
|
||||
/* Geometry */
|
||||
virtual void clear();
|
||||
virtual void clear(bool preserve_shaders = false);
|
||||
virtual void compute_bounds() = 0;
|
||||
virtual void apply_transform(const Transform &tfm, const bool apply_to_motion) = 0;
|
||||
|
||||
|
|
|
@ -321,9 +321,9 @@ void Hair::reserve_curves(int numcurves, int numkeys)
|
|||
attributes.resize(true);
|
||||
}
|
||||
|
||||
void Hair::clear()
|
||||
void Hair::clear(bool preserve_shaders)
|
||||
{
|
||||
Geometry::clear();
|
||||
Geometry::clear(preserve_shaders);
|
||||
|
||||
curve_keys.clear();
|
||||
curve_radius.clear();
|
||||
|
|
|
@ -103,7 +103,7 @@ class Hair : public Geometry {
|
|||
~Hair();
|
||||
|
||||
/* Geometry */
|
||||
void clear() override;
|
||||
void clear(bool preserve_shaders = false) override;
|
||||
|
||||
void resize_curves(int numcurves, int numkeys);
|
||||
void reserve_curves(int numcurves, int numkeys);
|
||||
|
|
|
@ -213,9 +213,9 @@ void Mesh::reserve_subd_faces(int numfaces, int num_ngons_, int numcorners)
|
|||
subd_attributes.resize(true);
|
||||
}
|
||||
|
||||
void Mesh::clear(bool preserve_voxel_data)
|
||||
void Mesh::clear(bool preserve_shaders, bool preserve_voxel_data)
|
||||
{
|
||||
Geometry::clear();
|
||||
Geometry::clear(preserve_shaders);
|
||||
|
||||
/* clear all verts and triangles */
|
||||
verts.clear();
|
||||
|
@ -243,9 +243,9 @@ void Mesh::clear(bool preserve_voxel_data)
|
|||
patch_table = NULL;
|
||||
}
|
||||
|
||||
void Mesh::clear()
|
||||
void Mesh::clear(bool preserve_shaders)
|
||||
{
|
||||
clear(false);
|
||||
clear(preserve_shaders, false);
|
||||
}
|
||||
|
||||
void Mesh::add_vertex(float3 P)
|
||||
|
|
|
@ -174,8 +174,7 @@ class Mesh : public Geometry {
|
|||
void reserve_mesh(int numverts, int numfaces);
|
||||
void resize_subd_faces(int numfaces, int num_ngons, int numcorners);
|
||||
void reserve_subd_faces(int numfaces, int num_ngons, int numcorners);
|
||||
void clear(bool preserve_voxel_data);
|
||||
void clear() override;
|
||||
void clear(bool preserve_shaders = false) override;
|
||||
void add_vertex(float3 P);
|
||||
void add_vertex_slow(float3 P);
|
||||
void add_triangle(int v0, int v1, int v2, int shader, bool smooth);
|
||||
|
@ -202,6 +201,9 @@ class Mesh : public Geometry {
|
|||
void pack_patches(uint *patch_data, uint vert_offset, uint face_offset, uint corner_offset);
|
||||
|
||||
void tessellate(DiagSplit *split);
|
||||
|
||||
protected:
|
||||
void clear(bool preserve_shaders, bool preserve_voxel_data);
|
||||
};
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
|
|
@ -56,9 +56,9 @@ Volume::Volume() : Mesh(node_type, Geometry::VOLUME)
|
|||
object_space = false;
|
||||
}
|
||||
|
||||
void Volume::clear()
|
||||
void Volume::clear(bool preserve_shaders)
|
||||
{
|
||||
Mesh::clear(true);
|
||||
Mesh::clear(preserve_shaders, true);
|
||||
}
|
||||
|
||||
struct QuadData {
|
||||
|
|
|
@ -32,7 +32,7 @@ class Volume : public Mesh {
|
|||
float step_size;
|
||||
bool object_space;
|
||||
|
||||
virtual void clear() override;
|
||||
virtual void clear(bool preserve_shaders = false) override;
|
||||
};
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
|
Loading…
Reference in New Issue