Fix #139670: Cycles crash with persistent data and light geometry

After refactor in e813e46327. Don't try to rebuild BVH for light geometry
which does not need one.
This commit is contained in:
Brecht Van Lommel
2025-06-02 13:46:21 +02:00
parent 50b554e1aa
commit bc543ec531
2 changed files with 21 additions and 15 deletions

View File

@@ -955,22 +955,27 @@ void GeometryManager::device_update(Device *device,
size_t i = 0;
size_t num_bvh = 0;
for (Geometry *geom : scene->geometry) {
if (geom->is_modified() || geom->need_update_bvh_for_offset) {
need_update_scene_bvh = true;
if (geom->is_light()) {
continue;
}
if (!(geom->is_modified() || geom->need_update_bvh_for_offset)) {
continue;
}
if (geom->need_build_bvh(bvh_layout)) {
i++;
num_bvh++;
}
need_update_scene_bvh = true;
if (use_multithreaded_build) {
pool.push([geom, device, dscene, scene, &progress, i, &num_bvh] {
geom->compute_bvh(device, dscene, &scene->params, &progress, i, num_bvh);
});
}
else {
if (geom->need_build_bvh(bvh_layout)) {
i++;
num_bvh++;
}
if (use_multithreaded_build) {
pool.push([geom, device, dscene, scene, &progress, i, &num_bvh] {
geom->compute_bvh(device, dscene, &scene->params, &progress, i, num_bvh);
}
});
}
else {
geom->compute_bvh(device, dscene, &scene->params, &progress, i, num_bvh);
}
}

View File

@@ -4,6 +4,7 @@
#include "bvh/bvh.h"
#include "bvh/bvh2.h"
#include "bvh/params.h"
#include "device/device.h"
@@ -60,7 +61,7 @@ void Geometry::compute_bvh(Device *device,
vector<Object *> objects;
objects.push_back(&object);
if (bvh && !need_update_rebuild) {
if (bvh && !need_update_rebuild && params->bvh_type == BVH_TYPE_DYNAMIC) {
progress->set_status(msg, "Refitting BVH");
bvh->replace_geometry(geometry, objects);
@@ -114,7 +115,7 @@ void GeometryManager::device_update_bvh(Device *device,
VLOG_INFO << "Using " << bvh_layout_name(bparams.bvh_layout) << " layout.";
const bool can_refit = scene->bvh != nullptr &&
const bool can_refit = scene->bvh != nullptr && scene->params.bvh_type == BVH_TYPE_DYNAMIC &&
(bparams.bvh_layout == BVHLayout::BVH_LAYOUT_OPTIX ||
bparams.bvh_layout == BVHLayout::BVH_LAYOUT_METAL);