Subdiv: Remove topology refiner C-API wrapper #120825

Open
Hans Goudey wants to merge 5 commits from HooglyBoogly/blender:cleanup-opensubdiv-more into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Member

Remove the indirection previously used for the topology refiner
to separate C and C++ code. Instead retrieve the base level in
calling code and call opensubdiv API functions directly. This
avoids copying arrays of mesh indices and should reduce
function call overhead since index retrieval can now be inlined.
It also lets us remove a lot of boilerplate shim code.

The downside is increased need for WITH_OPENSUBDIV defines
in various parts of blenkernel, but I think that is required to avoid
the previous indirection and have the kernel deal with OpenSubdiv
more directly.

Remove the indirection previously used for the topology refiner to separate C and C++ code. Instead retrieve the base level in calling code and call opensubdiv API functions directly. This avoids copying arrays of mesh indices and should reduce function call overhead since index retrieval can now be inlined. It also lets us remove a lot of boilerplate shim code. The downside is increased need for WITH_OPENSUBDIV defines in various parts of blenkernel, but I think that is required to avoid the previous indirection and have the kernel deal with OpenSubdiv more directly.
Hans Goudey added 5 commits 2024-04-19 14:16:27 +02:00
412a7f14a4 Subdiv: Use nested namespaces and static for opensubdiv module
Declaring the `blender::opensubdiv` namespace on one line is just shorter.
`static` is preferred over anonymous namespaces since it's locally visible.
74002c245c Subdiv: Move most blenkernel subdiv code to C++ namespace
Move most code to `blender::bke::subdiv`. That helps organization
and makes using C++ in subdiv code easier, which will be useful for
removing the unnecessary opensubdiv C-API wrapper.
c8618b92f3 Cleanup: Remove redundant part of SubdivForeachTaskContext name
The "subdiv" part is implied by the namespace.
04e260de01 Subdiv: Make OpenSubdiv_TopologyRefiner into a C++ class
Replace the C-class pattern function pointers with actual class methods.
Other than the obvious benefit of not requiring the "this" pointer to be
explicitly passed into every function call, this will make it much simpler
to remove the entire C-API class and replace it with its "impl" next.

For that next step we need to expose code to the implementation
of the topology refiner, so instead of defining stubs locally in the
opensubdiv intern class, we spread some WITH_OPENSUBDIV checks
in the blenkernel. As far as I know this is the only way to remove the
intermediate C-API and call opensubdiv functions directly from there.
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
419a1ce2ad
Subdiv: Remove topology refiner C-API wrapper
Remove the indirection previously used for the topology refiner
to separate C and C++ code. Instead retrieve the base level in
calling code and call opensubdiv API functions directly. This
avoids copying arrays of mesh indices and should reduce
function call overhead since index retrieval is now inlined.
It also lets us remove a lot of boilerplate shim code.

Similar to the previous commit, the downside is increased need
for WITH_OPENSUBDIV defines in various parts of blenkernel,
but I think that is required to avoid the previous indirection.
Hans Goudey force-pushed cleanup-opensubdiv-more from 419a1ce2ad to 5bab5a9d5d 2024-04-19 14:22:30 +02:00 Compare
Author
Member

@blender-bot build

@blender-bot build
Hans Goudey force-pushed cleanup-opensubdiv-more from 5bab5a9d5d to 19f750f0ee 2024-04-19 15:10:07 +02:00 Compare
Hans Goudey changed title from Subdiv: Cleanups and reduce topology refiner indirection to Subdiv: Reduce topology refiner indirection 2024-04-19 15:22:46 +02:00
Hans Goudey changed title from Subdiv: Reduce topology refiner indirection to Subdiv: Remove topology refiner C-API wrapper 2024-04-19 15:33:26 +02:00
Hans Goudey added 2 commits 2024-04-22 02:26:33 +02:00
Hans Goudey requested review from Sergey Sharybin 2024-04-22 02:26:52 +02:00
Hans Goudey added 1 commit 2024-04-26 17:12:36 +02:00
Hans Goudey added 1 commit 2024-04-30 17:00:31 +02:00
Merge conflict checking is in progress. Try again in few moments.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u cleanup-opensubdiv-more:HooglyBoogly-cleanup-opensubdiv-more
git checkout HooglyBoogly-cleanup-opensubdiv-more
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
1 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#120825
No description provided.