Fix #105455: GPU subdivision with textures corrupts display after undo #105844

Merged
Brecht Van Lommel merged 1 commits from fix-undo-orco-subdiv into blender-v3.5-release 2023-03-16 23:19:05 +01:00

This is an issue revealed by the recent optimization in 4d3bfb3f41 to have
CPU and GPU subdivision topology both cached.

BKE_subsurf_modifier_subdiv_descriptor_ensure is what (re)creates the
topology refiner when needed. Invalidating the topology refiner on changes
must be done before it, otherwise we end up with an incomplete Subdiv that
either does not draw or draw incorrectly.

This is an issue revealed by the recent optimization in 4d3bfb3f41 to have CPU and GPU subdivision topology both cached. BKE_subsurf_modifier_subdiv_descriptor_ensure is what (re)creates the topology refiner when needed. Invalidating the topology refiner on changes must be done before it, otherwise we end up with an incomplete Subdiv that either does not draw or draw incorrectly.
Brecht Van Lommel requested review from Kévin Dietrich 2023-03-16 20:59:47 +01:00
Brecht Van Lommel requested review from Alexander Gavrilov 2023-03-16 20:59:47 +01:00
Brecht Van Lommel changed title from Fix #105455: GPU subdivision with textures corrupt display after undo to Fix #105455: GPU subdivision with textures corrupts display after undo 2023-03-16 21:05:07 +01:00
Kévin Dietrich requested changes 2023-03-16 22:32:01 +01:00
Kévin Dietrich left a comment
Member

This causes a crash in one of my test file as draw_subdiv_invalidate_evaluator_for_orco is not checking the validity of the Subdiv pointer.

diff --git a/source/blender/draw/intern/draw_cache_impl_subdivision.cc b/source/blender/draw/intern/draw_cache_impl_subdivision.cc
index 2f0dd84af8c..eb8c2c5e6b4 100644
--- a/source/blender/draw/intern/draw_cache_impl_subdivision.cc
+++ b/source/blender/draw/intern/draw_cache_impl_subdivision.cc
@@ -838,6 +838,10 @@ static DRWSubdivCache *mesh_batch_cache_ensure_subdiv_cache(MeshBatchCache *mbc)
 
 static void draw_subdiv_invalidate_evaluator_for_orco(Subdiv *subdiv, Mesh *mesh)
 {
+  if (!subdiv) {
+    return;
+  }
+
   const bool has_orco = CustomData_has_layer(&mesh->vdata, CD_ORCO);
   if (has_orco && subdiv->evaluator && !subdiv->evaluator->hasVertexData(subdiv->evaluator)) {
     /* If we suddenly have/need original coordinates, recreate the evaluator if the extra
This causes a crash in one of my test file as draw_subdiv_invalidate_evaluator_for_orco is not checking the validity of the Subdiv pointer. ``` diff --git a/source/blender/draw/intern/draw_cache_impl_subdivision.cc b/source/blender/draw/intern/draw_cache_impl_subdivision.cc index 2f0dd84af8c..eb8c2c5e6b4 100644 --- a/source/blender/draw/intern/draw_cache_impl_subdivision.cc +++ b/source/blender/draw/intern/draw_cache_impl_subdivision.cc @@ -838,6 +838,10 @@ static DRWSubdivCache *mesh_batch_cache_ensure_subdiv_cache(MeshBatchCache *mbc) static void draw_subdiv_invalidate_evaluator_for_orco(Subdiv *subdiv, Mesh *mesh) { + if (!subdiv) { + return; + } + const bool has_orco = CustomData_has_layer(&mesh->vdata, CD_ORCO); if (has_orco && subdiv->evaluator && !subdiv->evaluator->hasVertexData(subdiv->evaluator)) { /* If we suddenly have/need original coordinates, recreate the evaluator if the extra ```
Author
Owner

Thanks!

I had actually fixed that in brecht/blender@3a5c44e057 but for some reason the PR did not update.

Thanks! I had actually fixed that in brecht/blender@3a5c44e05760756d32f33d7346b8ba0d197e3789 but for some reason the PR did not update.
Brecht Van Lommel force-pushed fix-undo-orco-subdiv from e2bfeedb70 to ebf8153911 2023-03-16 22:46:16 +01:00 Compare
Brecht Van Lommel force-pushed fix-undo-orco-subdiv from ebf8153911 to aa83501d80 2023-03-16 22:50:16 +01:00 Compare
Author
Owner

Ok, code should be updated now with a similar null check.

Ok, code should be updated now with a similar null check.
Kévin Dietrich approved these changes 2023-03-16 22:59:37 +01:00
Brecht Van Lommel merged commit 20a8bc1204 into blender-v3.5-release 2023-03-16 23:19:05 +01:00
Brecht Van Lommel deleted branch fix-undo-orco-subdiv 2023-03-16 23:19:07 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#105844
No description provided.