Clamp branching factor - #611
Conversation
Clamp BVHBuilderMorton settings to MAX_BRANCHING_FACTOR when an oversized maxBranchingFactor is provided via RTCBuildArguments.\n\nAdd an integration test that exercises rtcBuildBVH with RTC_BUILD_QUALITY_LOW and maxBranchingFactor=64 to verify the Morton build path returns a valid root. Co-authored-by: Copilot <[email protected]>
johguenther
left a comment
There was a problem hiding this comment.
LGTM, just some questions/comments
- the regression test does nowhere check whether
childrenare <=8 (MAX_BRANCHING_FACTOR), so basically without the fix, the builder would crash (stack overflow)? But what ifmaxBranchingFactoris set to 9 without the fix / clamp, it may not crash (just slightly above the limit), just be corrupt? - needs un-draft and should be squashed
johguenther
left a comment
There was a problem hiding this comment.
actually, embree_regression_morton_builder_clamp already crashes (without modifications)
There was a problem hiding this comment.
- test passes, good
- when I remove the fix (clamp branching in builder), the test segfaults (expected, but a fail would be better)
- when I now reduce test requested branching to 6 via
runCase(6), the test still segfaults, bad (segfault is inembree/kernels/common/alloc.h:517allslotMutex[]arenullptr, called bymorton_builder_clamp_regression.cpp:createLeaf()->rtcThreadLocalAlloc())
I'd recommend to replace the asserts by std::throw and remove all other code which allocates or writes to memory. This way the regression test does not depend on asserts being compiled and the thrown exception (in case of a regression) is handled by the test framework (then failing properly instead of crashing -- at least not crashing in the test, but maybe in the builder).
the new file morton_builder_clamp_regression.cpp still needs clang-formated
|
The internal builders should fail when invalid config is passed, as this is really an error when we want to use wide BVHs. This which is also how this is handled in some other builders. The BVH builder API could clamp max width to 8, which is supported by all builders. kernels/builders/bvh_builder_msmblur.h already fails (ok) |
Limiting the branching factor of the standalone BVH builder.