Cleanup: Reduce unnecessary mesh position copying #111313

Merged
Jesse Yurkovich merged 4 commits from deadpin/blender:cleanup-meshcopy into main 2023-08-22 03:52:00 +02:00

Continuation of #103789 to remove/reduce the copying of mesh position
data.


Notes:
DerivedMesh.cc Still requires a copy, but the work is done directly to the custom data layer, eliminating one memcpy at the end (1 copy instead of 2)
MOD_uvproject.cc Instead of iterating over the verts 3 times (during the vert copy, the world-space conversion, and the uv-project), only 2 iterations are done now (world-space conversion and the uv-project)

scenario old new
UVProject onto a 31658 vert Suzanne (10 times) Timer 'MOD_uvproject': (Average: 0.5 ms, Min: 0.2 ms, Last: 0.2 ms) Timer 'MOD_uvproject': (Average: 0.2 ms, Min: 0.2 ms, Last: 0.2 ms)
A 16641 vert plane with a Cloth modifier (20 frames) Timer 'add_orco_mesh': (Average: 41252 ns, Min: 1100 ns, Last: 0.2 ms) Timer 'add_orco_mesh': (Average: 37633 ns, Min: 1200 ns, Last: 0.3 ms)
Applying Simple Deform Twist to a 24578 vert object (10 times) Timer 'create_applied_mesh_for_modifier': (Average: 1.0 ms, Min: 0.8 ms, Last: 0.8 ms) Timer 'create_applied_mesh_for_modifier': (Average: 0.7 ms, Min: 0.3 ms, Last: 0.3 ms)
Continuation of #103789 to remove/reduce the copying of mesh position data. ---- Notes: `DerivedMesh.cc` Still requires a copy, but the work is done directly to the custom data layer, eliminating one `memcpy` at the end (1 copy instead of 2) `MOD_uvproject.cc` Instead of iterating over the verts 3 times (during the vert copy, the world-space conversion, and the uv-project), only 2 iterations are done now (world-space conversion and the uv-project) | scenario | old | new | | -- | -- | -- | | UVProject onto a 31658 vert Suzanne (10 times) | Timer 'MOD_uvproject': (Average: 0.5 ms, Min: 0.2 ms, Last: 0.2 ms) | Timer 'MOD_uvproject': (Average: 0.2 ms, Min: 0.2 ms, Last: 0.2 ms) | | A 16641 vert plane with a Cloth modifier (20 frames) | Timer 'add_orco_mesh': (Average: 41252 ns, Min: 1100 ns, Last: 0.2 ms) | Timer 'add_orco_mesh': (Average: 37633 ns, Min: 1200 ns, Last: 0.3 ms) | | Applying Simple Deform Twist to a 24578 vert object (10 times) | Timer 'create_applied_mesh_for_modifier': (Average: 1.0 ms, Min: 0.8 ms, Last: 0.8 ms) | Timer 'create_applied_mesh_for_modifier': (Average: 0.7 ms, Min: 0.3 ms, Last: 0.3 ms) |
Jesse Yurkovich added 2 commits 2023-08-20 07:04:57 +02:00
Iliya Katushenock requested review from Hans Goudey 2023-08-20 14:55:11 +02:00
Member

@blender-bot build

@blender-bot build
Hans Goudey approved these changes 2023-08-20 16:16:22 +02:00
Hans Goudey left a comment
Member

Thanks! Just two comments inline, but I don't think they require another review.

Thanks! Just two comments inline, but I don't think they require another review.
@ -100,3 +100,2 @@
using namespace blender;
float(*coords)[3], (*co)[3];
int i, verts_num;
Member

Whitespace after the "using namespace" lines usually isn't necessary IMO

Whitespace after the "using namespace" lines usually isn't necessary IMO
deadpin marked this conversation as resolved
Author
Member

I only see 1 comment? Just checking as I want to make sure I get all your feedback :)

I only see 1 comment? Just checking as I want to make sure I get all your feedback :)
Hans Goudey reviewed 2023-08-21 20:19:28 +02:00
Hans Goudey left a comment
Member

Oop, not sure what happened there, thanks for following up!

Oop, not sure what happened there, thanks for following up!
@ -408,2 +408,3 @@
const int totvert = mesh->totvert;
totvert = mesh->totvert;
auto make_layer_orco = [mesh, layer]() -> MutableSpan<float3> {
Member

Looks like this might make more sense as a separate function called something like "orco_coord_layer_ensure", just to make the use of data clearer and make this easier to read.

Looks like this might make more sense as a separate function called something like "orco_coord_layer_ensure", just to make the use of data clearer and make this easier to read.
deadpin marked this conversation as resolved
Jesse Yurkovich added 2 commits 2023-08-21 22:07:23 +02:00
Author
Member

@blender-bot build

@blender-bot build
Jesse Yurkovich merged commit f30ac938de into main 2023-08-22 03:52:00 +02:00
Jesse Yurkovich deleted branch cleanup-meshcopy 2023-08-22 03:52:02 +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#111313
No description provided.