Fix #109583: Avoid non-threadsafe writing to custom normals data #110478

Merged
Hans Goudey merged 7 commits from HooglyBoogly/blender:fix-no-custom-normals-write into main 2023-07-26 17:04:19 +02:00
Member

Currently, while calculating face corner normals, Blender retrieves
custom normal data with write access. When the the custom normals in a
single smooth corner fan don't match, they are reset to the average
value.

This behavior is very old, but it comes from when Blender didn't have a
strong idea of const correctness. Indeed, modifying custom normal data
while calculating normals isn't threadsafe, which is important because
normals are calculated for viewport drawing, for example. And in the
future, properly caching face corner normals (see #93551) will require
the ability to calculate normals on a properly const mesh.

The fix is to still use the average of custom normals in a fan, but
not write that back to the custom data array. In my testing the results
are the same. Setting custom normals still fills the same value for all
corners in a fan.

Currently, while calculating face corner normals, Blender retrieves custom normal data with write access. When the the custom normals in a single smooth corner fan don't match, they are reset to the average value. This behavior is very old, but it comes from when Blender didn't have a strong idea of const correctness. Indeed, modifying custom normal data while calculating normals isn't threadsafe, which is important because normals are calculated for viewport drawing, for example. And in the future, properly caching face corner normals (see #93551) will require the ability to calculate normals on a properly const mesh. The fix is to still use the average of custom normals in a fan, but not write that back to the custom data array. In my testing the results are the same. Setting custom normals still fills the same value for all corners in a fan.
Hans Goudey added 1 commit 2023-07-25 22:06:24 +02:00
Hans Goudey changed title from Fix: Avoid non-threadsafe writing to custom normals data to Fix #109583: Avoid non-threadsafe writing to custom normals data 2023-07-25 22:12:48 +02:00
Hans Goudey added 3 commits 2023-07-26 06:15:32 +02:00
Author
Member

@blender-bot build

@blender-bot build
Hans Goudey added 1 commit 2023-07-26 14:24:04 +02:00
Jacques Lucke approved these changes 2023-07-26 15:47:14 +02:00
@ -948,9 +948,6 @@ static void split_loop_nor_fan_do(LoopSplitTaskDataCommon *common_data,
/* We validate clnors data on the fly - cheapest way to do! */
Member

Probably need to update the comment.

Probably need to update the comment.
HooglyBoogly marked this conversation as resolved
Hans Goudey added 2 commits 2023-07-26 17:03:20 +02:00
Hans Goudey merged commit 580833165c into main 2023-07-26 17:04:19 +02:00
Hans Goudey deleted branch fix-no-custom-normals-write 2023-07-26 17:04:23 +02:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
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
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
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
EEVEE & Viewport
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
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
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#110478
No description provided.