Page MenuHome

Fix T85440: crash with displacement shaders and updating geometry in viewport
AbandonedPublic

Authored by Brecht Van Lommel (brecht) on Feb 16 2021, 8:52 PM.

Diff Detail

Repository
rB Blender
Branch
displace-offset-rebuild (branched from master)
Build Status
Buildable 12933
Build 12933: arc lint + arc unit

Event Timeline

Brecht Van Lommel (brecht) requested review of this revision.Feb 16 2021, 8:52 PM
Brecht Van Lommel (brecht) created this revision.

This is caused by rB166c0db3f941: Fix T83915: Subdivision Surface modifier causes visual artifacts in Cycles….

What happens is that GeometryManager::device_update detects if geometry has been modified and needs displacement, and then sets true_displacement_used. Afterwards in mesh_calc_offset additional geometry is tagged as modified. This then results in displacement shading being done, without device_update_mesh being called to ensure the proper mesh data is available for it.

For the solution, I don't think we can move mesh_calc_offset earlier since we don't want to re-displace any modified geometry, that will double up displacement. I think we want to mesh_calc_offset to tag the geometry for BVH rebuild, but not make it do any other geometry updates.

Here's the patch I have so far, but I have not tested it well yet, will do that tomorrow. Posting early since we are close to bcon4, so any help with testing or checking the code is welcome.

Based on my understanding of the problem this makes sense and the code looks correct. Have not tested it yet though.

I tested this patch with cases from T85440, T83915, and the behaviors that I observed and talked about in D9555 (deleting an object that is not the last added results in the last one disappearing as well, or crashes, depending on the device) when I first noticed the issue, and everything appears to work properly.

Thanks for the reviews. I noticed a mistake in my code and fix that, and did more extensive testing now and it seems to be fine.