Page MenuHome

Crash When Adding Material To a plane with Addabtive SubD Enabled [Cycles]
Closed, ResolvedPublicBUG

Description

System Information
Operating system: Windows-10-10.0.19041-SP0 64 Bits
Graphics card: GeForce RTX 2060 SUPER/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 457.30

Blender Version
Broken: version: Bisect points to rB88bb29dea668: Fix T82617: artifacts in Cycles viewport when changing subdivision attributes

Short description of error
Crash When Adding 4K Material With a Displacement node to a plane with an Adaptive Subdivisions Enabled in Subdivisions Modifier, and trying to rotate the plane, once rotated it crashes.

Exact steps for others to reproduce the error

  1. Enable Cycles Render
  2. Enable Experimental
  3. Choose GPU Compute and enable Adaptive Sampling
  4. Open Setting and Choose Cuda [Check both GPU + CPU]
  5. Create a Plane
  6. Add a Subdivions Modifier to the plane
  7. Choose Simple and check adaptive Subdivion and dicing scale =1
  8. Add a 4K Material with a Displacement node ( Displacement node is the cause of the crash)
  9. Go to Rendered View
  10. Try to move or rotate the plane

11.Crash

[Based on the default startup or an attached .blend file (as simple as possible)]

Event Timeline

Kévin Dietrich (kevindietrich) changed the task status from Needs Triage to Confirmed.Nov 19 2020, 9:30 PM

This is only an issue in master, and is caused by the socket API refactor.

I don't understand the terminology, How can I solve it then? Thank you

It works perfectly in 2.90.1 the stable one, just sayin :)

This was a comment meant for other developers or bug triagers, to let them know that I found the issue and I am working on fixing it, also to let them know that it is not going to affect the upcoming release. There is nothing you can do to solve it on your side.

ah ok thank you, just my first time reporting something :D

Philipp Oeser (lichtwerk) changed the subtype of this task from "Report" to "Bug".Nov 20 2020, 9:31 AM

@Brecht Van Lommel (brecht) this crash is caused by the API refactor, because Mesh data is not cleared anymore during synchronization we are using a wrong value to compute the attribute size when adding updisplaced attributes. Basically Mesh.num_subd_verts is the value from the previous update which causes an underflow when subtracting it from the computed size (verts.size() + num_ngons() - num_subd_verts()). At this point num_subd_verts should be 0.

I already had a similar issue when working on the patch, so we changed the behaviour to reset num_subd_verts in Mesh::tesselate instead, but it wasn't enough apparently.

To fix this I have two options:

  • add a Mesh::clear_non_sockets, where we just clear anything that is not a socket
  • or, use ATTR_PRIM_GEOMETRY in Mesh::add_undisplaced so we do not subtract the stale num_subd_verts value when computing the attribute size, as in this patch:
diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp
index 11c8e240afd..cd75eef8eea 100644
--- a/intern/cycles/render/mesh.cpp
+++ b/intern/cycles/render/mesh.cpp
@@ -662,7 +662,7 @@ void Mesh::add_undisplaced()
   float3 *data = attr->data_float3();
 
   /* copy verts */
-  size_t size = attr->buffer_size(this, attrs.prim);
+  size_t size = attr->buffer_size(this, ATTR_PRIM_GEOMETRY);
 
   /* Center points for ngons aren't stored in Mesh::verts but are included in size since they will
    * be calculated later, we subtract them from size here so we don't have an overflow while

The first one is bit more robust, but the second one is also reasonable as at this point the vertices are still the original ones so there is no need to subtract the subdivision vertices count.

What do you think? I kinda want to do both actually.

Doing both seems reasonable.