Hydra: Parallelize and simplify submesh export #113412

Merged
Hans Goudey merged 14 commits from HooglyBoogly/blender:cleanup-hydra-submesh-index-mask into main 2023-11-21 23:41:03 +01:00
Member
  • Only calculate normals on the necessary domain
  • Functions for exporting generic data
  • Parallelize export of multiple submeshes
  • Parallelize export within a single submesh
  • Resize vectors to correct size to avoid reallocation
  • Simplify hot loops to improve performance
  • Optimize single material case to avoid index remapping

write_submeshes timing information (average of many runs)

Test Before After
6 million vert mesh 791.99 ms 130.75 ms
1.5 million vert 100 materials crash 48.27 ms
Mr. Elephant 778.95 ms 277.06 ms
- Only calculate normals on the necessary domain - Functions for exporting generic data - Parallelize export of multiple submeshes - Parallelize export within a single submesh - Resize vectors to correct size to avoid reallocation - Simplify hot loops to improve performance - Optimize single material case to avoid index remapping `write_submeshes` timing information (average of many runs) | Test | Before | After | | ------------------------------ | --------- | --------- | | 6 million vert mesh | 791.99 ms | 130.75 ms | | 1.5 million vert 100 materials | crash | 48.27 ms | | Mr. Elephant | 778.95 ms | 277.06 ms |
Hans Goudey added 1 commit 2023-10-08 14:45:22 +02:00
Hans Goudey changed title from WIP: Hydra: Parallelize and submesh export to WIP: Hydra: Parallelize and simplify submesh export 2023-10-08 14:45:34 +02:00
Hans Goudey added 2 commits 2023-11-13 12:05:30 +01:00
Hans Goudey added 2 commits 2023-11-14 12:18:54 +01:00
Hans Goudey changed title from WIP: Hydra: Parallelize and simplify submesh export to Hydra: Parallelize and simplify submesh export 2023-11-14 12:20:51 +01:00
Hans Goudey added the
Module
Pipeline, Assets & IO
Interest
Render & Cycles
Interest
USD
labels 2023-11-14 12:21:09 +01:00
Hans Goudey requested review from Brecht Van Lommel 2023-11-14 12:21:36 +01:00
Author
Member

@blender-bot build

@blender-bot build
Author
Member

I'm not sure if there are automated tests for the Hydra rendering. This seems to work locally though, and we'll see what the buildbots say.

I'm not sure if there are automated tests for the Hydra rendering. This seems to work locally though, and we'll see what the buildbots say.
Brecht Van Lommel requested review from Bogdan Nagirniak 2023-11-14 17:54:24 +01:00
Brecht Van Lommel requested review from Georgiy Markelov 2023-11-14 17:54:24 +01:00
Brecht Van Lommel requested review from Vasyl Pidhirskyi 2023-11-14 17:54:24 +01:00
Bogdan Nagirniak requested changes 2023-11-16 18:44:35 +01:00
Bogdan Nagirniak left a comment
Contributor

Tested this PR with some scenes, including https://download.blender.org/demo/eevee/mr_elephant/mr_elephant.blend and checked export time. This PR increases export time in average about 10-20%.
But also found following issue in console:

Warning (secondary thread): in _PopulateVertexPrimvars at line 1434 of C:\db\build\S\VS1564R\build\usd\src\external_usd\pxr\imaging\hdSt\mesh.cpp -- Invalid Hydra prim '/scene/O_000002208CF99D08/SM_0000': Vertex primvar points has 61 elements, while its topology references only upto element index 0.

which means something wrong with one of submesh (it relates to object OBBezierCurve.006 in mr_elephant.blend scene).

Also make format is required.

Tested this PR with some scenes, including https://download.blender.org/demo/eevee/mr_elephant/mr_elephant.blend and checked export time. This PR increases export time in average about 10-20%. But also found following issue in console: ``` Warning (secondary thread): in _PopulateVertexPrimvars at line 1434 of C:\db\build\S\VS1564R\build\usd\src\external_usd\pxr\imaging\hdSt\mesh.cpp -- Invalid Hydra prim '/scene/O_000002208CF99D08/SM_0000': Vertex primvar points has 61 elements, while its topology references only upto element index 0. ``` which means something wrong with one of submesh (it relates to object `OBBezierCurve.006` in `mr_elephant.blend` scene). Also `make format` is required.
Hans Goudey added 9 commits 2023-11-19 16:30:48 +01:00
Author
Member

Thanks for the review. I fixed the warning you mentioned. It shouldn't have caused an actual problem, there were just extra loose vertices being uploaded. But it's nice to fix as well.

As for performance, in my testing this is a fair amount better, especially for a large mesh with only a single material. I added some timing information to the PR description. I made a couple optimizations to the new code as well, that may have helped. Anyway, it's curious that we're getting such different results. I'm happy to do more testing if there's another scene with regressed export time.

Thanks for the review. I fixed the warning you mentioned. It shouldn't have caused an actual problem, there were just extra loose vertices being uploaded. But it's nice to fix as well. As for performance, in my testing this is a fair amount better, especially for a large mesh with only a single material. I added some timing information to the PR description. I made a couple optimizations to the new code as well, that may have helped. Anyway, it's curious that we're getting such different results. I'm happy to do more testing if there's another scene with regressed export time.
Hans Goudey requested review from Bogdan Nagirniak 2023-11-19 16:40:05 +01:00
Bogdan Nagirniak approved these changes 2023-11-20 13:29:36 +01:00
Bogdan Nagirniak left a comment
Contributor

Tested - works good, no more mentioned warning in console.

Also, I tested performance before and after those changes and have following results:

Test Before After Improvement
6M vert 32M faces mesh 2.3 sec 1.95 sec 16%
Mr. Elephant 1.0 sec 0.65 sec 35%
Tested - works good, no more mentioned warning in console. Also, I tested performance before and after those changes and have following results: | Test | Before | After | Improvement | | -------- | -------- | -------- | -------- | | 6M vert 32M faces mesh | 2.3 sec | 1.95 sec | 16% | | Mr. Elephant | 1.0 sec | 0.65 sec | 35% |
Author
Member

Thanks!

In case anyone else here wants to review, I'll wait a couple days before landing this.

Thanks! In case anyone else here wants to review, I'll wait a couple days before landing this.
Vasyl Pidhirskyi approved these changes 2023-11-21 08:26:23 +01:00
Brecht Van Lommel approved these changes 2023-11-21 20:02:21 +01:00
Hans Goudey merged commit 75f24a5f14 into main 2023-11-21 23:41:03 +01:00
Hans Goudey deleted branch cleanup-hydra-submesh-index-mask 2023-11-21 23:41:05 +01:00
Sign in to join this conversation.
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
4 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#113412
No description provided.