forked from bartvdbraak/blender
Fix T85440: crash with displacement shaders and updating geometry in viewport
When primitive offsets change we need to rebuild or refit BVHs, however this was also tagging other data as modified too late in the geometry update process. Now ensure only the BVHs are updated. Ref D10441
This commit is contained in:
parent
6ce06957c9
commit
2217719feb
@ -61,6 +61,7 @@ Geometry::Geometry(const NodeType *node_type, const Type type)
|
||||
: Node(node_type), geometry_type(type), attributes(this, ATTR_PRIM_GEOMETRY)
|
||||
{
|
||||
need_update_rebuild = false;
|
||||
need_update_bvh_for_offset = false;
|
||||
|
||||
transform_applied = false;
|
||||
transform_negative_scaled = false;
|
||||
@ -242,6 +243,7 @@ void Geometry::compute_bvh(
|
||||
|
||||
clear_modified();
|
||||
need_update_rebuild = false;
|
||||
need_update_bvh_for_offset = false;
|
||||
}
|
||||
|
||||
bool Geometry::has_motion_blur() const
|
||||
@ -944,7 +946,8 @@ void GeometryManager::mesh_calc_offset(Scene *scene, BVHLayout bvh_layout)
|
||||
const bool has_optix_bvh = bvh_layout == BVH_LAYOUT_OPTIX ||
|
||||
bvh_layout == BVH_LAYOUT_MULTI_OPTIX ||
|
||||
bvh_layout == BVH_LAYOUT_MULTI_OPTIX_EMBREE;
|
||||
geom->tag_bvh_update(has_optix_bvh);
|
||||
geom->need_update_rebuild |= has_optix_bvh;
|
||||
geom->need_update_bvh_for_offset = true;
|
||||
}
|
||||
|
||||
if (geom->geometry_type == Geometry::MESH || geom->geometry_type == Geometry::VOLUME) {
|
||||
@ -1590,7 +1593,9 @@ void GeometryManager::device_update(Device *device,
|
||||
displacement_done = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (geom->is_modified() || geom->need_update_bvh_for_offset) {
|
||||
if (geom->need_build_bvh(bvh_layout)) {
|
||||
num_bvh++;
|
||||
}
|
||||
@ -1632,7 +1637,7 @@ void GeometryManager::device_update(Device *device,
|
||||
|
||||
size_t i = 0;
|
||||
foreach (Geometry *geom, scene->geometry) {
|
||||
if (geom->is_modified()) {
|
||||
if (geom->is_modified() || geom->need_update_bvh_for_offset) {
|
||||
pool.push(function_bind(
|
||||
&Geometry::compute_bvh, geom, device, dscene, &scene->params, &progress, i, num_bvh));
|
||||
if (geom->need_build_bvh(bvh_layout)) {
|
||||
|
@ -90,6 +90,7 @@ class Geometry : public Node {
|
||||
|
||||
/* Update Flags */
|
||||
bool need_update_rebuild;
|
||||
bool need_update_bvh_for_offset;
|
||||
|
||||
/* Index into scene->geometry (only valid during update) */
|
||||
size_t index;
|
||||
|
Loading…
Reference in New Issue
Block a user