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:
authorPatrick Mours <pmours@nvidia.com>2021-01-05 16:39:29 +0300
committerPatrick Mours <pmours@nvidia.com>2021-01-05 19:59:38 +0300
commit166c0db3f9412925b501b7172875cb8ee2eb6958 (patch)
tree90b87b06a9039d67384888f86708e08bf3e8f9f9 /intern/cycles/render/geometry.cpp
parentda9d471e1d9ac451929340cfe8aa5a8c5b268a75 (diff)
Fix T83915: Subdivision Surface modifier causes visual artifacts in Cycles rendered viewport - CPU and OptiX
Changing the geometry in the current scene caused the primitive offsets for all geometry to change, but the values would not be updated in all bottom-level BVH structures. Rendering artifacts and crashes where the result. This fixes that by ensuring all BVH structures are updated when the primitive offsets change.
Diffstat (limited to 'intern/cycles/render/geometry.cpp')
-rw-r--r--intern/cycles/render/geometry.cpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/intern/cycles/render/geometry.cpp b/intern/cycles/render/geometry.cpp
index 64b98a91853..6fc217f2d76 100644
--- a/intern/cycles/render/geometry.cpp
+++ b/intern/cycles/render/geometry.cpp
@@ -280,6 +280,15 @@ void Geometry::tag_update(Scene *scene, bool rebuild)
scene->object_manager->need_update = true;
}
+void Geometry::tag_bvh_update(bool rebuild)
+{
+ tag_modified();
+
+ if (rebuild) {
+ need_update_rebuild = true;
+ }
+}
+
/* Geometry Manager */
GeometryManager::GeometryManager()
@@ -915,7 +924,7 @@ void GeometryManager::device_update_attributes(Device *device,
scene->object_manager->device_update_mesh_offsets(device, dscene, scene);
}
-void GeometryManager::mesh_calc_offset(Scene *scene)
+void GeometryManager::mesh_calc_offset(Scene *scene, BVHLayout bvh_layout)
{
size_t vert_size = 0;
size_t tri_size = 0;
@@ -930,6 +939,14 @@ void GeometryManager::mesh_calc_offset(Scene *scene)
size_t optix_prim_size = 0;
foreach (Geometry *geom, scene->geometry) {
+ if (geom->optix_prim_offset != optix_prim_size) {
+ /* Need to rebuild BVH in OptiX, since refit only allows modified mesh data there */
+ 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);
+ }
+
if (geom->geometry_type == Geometry::MESH || geom->geometry_type == Geometry::VOLUME) {
Mesh *mesh = static_cast<Mesh *>(geom);
@@ -1526,7 +1543,9 @@ void GeometryManager::device_update(Device *device,
/* Device update. */
device_free(device, dscene);
- mesh_calc_offset(scene);
+ const BVHLayout bvh_layout = BVHParams::best_bvh_layout(scene->params.bvh_layout,
+ device->get_bvh_layout_mask());
+ mesh_calc_offset(scene, bvh_layout);
if (true_displacement_used) {
scoped_callback_timer timer([scene](double time) {
if (scene->update_stats) {
@@ -1553,8 +1572,6 @@ void GeometryManager::device_update(Device *device,
}
/* Update displacement. */
- BVHLayout bvh_layout = BVHParams::best_bvh_layout(scene->params.bvh_layout,
- device->get_bvh_layout_mask());
bool displacement_done = false;
size_t num_bvh = 0;