Page MenuHome

Geometry Nodes: Add file namespaces.
ClosedPublic

Authored by Jacques Lucke (JacquesLucke) on Nov 23 2021, 12:11 PM.

Details

Summary

This puts the all static functions in geometry node files into a new name space. This allows using unity builds which can improve compile times significantly (P2578).

  • The name space name is derived from the file name. That makes it possible to write some tooling that checks the names later on. The file name extension (cc) is added to the namespace name as well. This also possibly simplifies tooling but also makes it more obvious that this namespace is specific to a file.
  • In the register function of every node, I added a namespace alias namespace file_ns = blender::nodes::node_geo_*_cc;. This avoids some duplication of the file name and may also simplify tooling, because this line is easy to detect. The name file_ns stands for file namespace and also indicates that this namespace corresponds to the current file. In the beginning I used node_ns but file_ns is more generic which may make it more suitable when we want to use unity builds outside of the nodes modules in the future.
  • Some node files contain code that is actually shared between different nodes. For now I left that code in the blender::nodes namespace and moved it to the top of the file (couldn't move it to the bottom in all cases, so I just moved it to the top everywhere). As a separate cleanup step, this shared code should actually be moved to a separate file.

Diff Detail

Repository
rB Blender
Branch
geometry-nodes-file-namespaces (branched from master)
Build Status
Buildable 18895
Build 18895: arc lint + arc unit

Event Timeline

Jacques Lucke (JacquesLucke) requested review of this revision.Nov 23 2021, 12:11 PM
Jacques Lucke (JacquesLucke) created this revision.

This makes sense, and it compiles for me.
I like that you took into account how we can use this for other areas. In general I think we should be moving to smaller files, and this is a great way of removing the compile time cost of that.

I wonder about the best place to put the shared code. Maybe a few smaller files, or in other modules.

This revision is now accepted and ready to land.Nov 23 2021, 1:52 PM

I wonder about the best place to put the shared code. Maybe a few smaller files, or in other modules.

I think for some algorithms we could just put them in separate files in the same folder. There isn't really a rule that says all file names have to start with node_geo_. Some algorithms could go into the new geometry module though maybe.