Skip to content

Clamp branching factor#611

Draft
stefanatwork wants to merge 2 commits into
masterfrom
sw/clamp_branching_factor
Draft

Clamp branching factor#611
stefanatwork wants to merge 2 commits into
masterfrom
sw/clamp_branching_factor

Conversation

@stefanatwork

Copy link
Copy Markdown
Collaborator

Limiting the branching factor of the standalone BVH builder.

stefanatwork and others added 2 commits July 6, 2026 16:16
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 <223556219+Copilot@users.noreply.github.com>
@stefanatwork stefanatwork added this to the 4.4.2 milestone Jul 9, 2026
@stefanatwork stefanatwork self-assigned this Jul 9, 2026
@stefanatwork stefanatwork marked this pull request as draft July 9, 2026 11:11

@johguenther johguenther left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just some questions/comments

  • the regression test does nowhere check whether children are <=8 (MAX_BRANCHING_FACTOR), so basically without the fix, the builder would crash (stack overflow)? But what if maxBranchingFactor is 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

Comment thread tests/CMakeLists.txt
ENDFOREACH()
ENDFOREACH()

ADD_SUBDIRECTORY(regression)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong indentation

@johguenther johguenther left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, embree_regression_morton_builder_clamp already crashes (without modifications)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs clang-format

{
if (branchingFactor > MAX_BRANCHING_FACTOR)
branchingFactor = MAX_BRANCHING_FACTOR;
minLeafSize = min(minLeafSize,maxLeafSize);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is actually bad: parameters shadow members, better rename all parameters (e.g., append _

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants