Skip to content

Pass bounds-callback specific payload to the callback - #618

Open
sergeyvfx wants to merge 2 commits into
RenderKit:masterfrom
sergeyvfx:bounds_user_ptr
Open

Pass bounds-callback specific payload to the callback#618
sergeyvfx wants to merge 2 commits into
RenderKit:masterfrom
sergeyvfx:bounds_user_ptr

Conversation

@sergeyvfx

Copy link
Copy Markdown

Prior to this change the rtcSetGeometryBoundsFunction() accepted an user payload (userPtr argument) which was not passed to the callback since the UserGeometry::setBoundsFunction() simply ignored the argument.

This change makes it so the bounds callback function has an access to this payload via RTCBoundsFunctionArguments::boundsUserPtr.

The change allows to use geometry-specific payload (geometryUserPtr) for efficient intersection and filtering, while being able to access data needed for the purpose of bounding box calculation.

Prior to this change the rtcSetGeometryBoundsFunction() accepted an
user payload (userPtr argument) which was not passed to the callback
since the UserGeometry::setBoundsFunction() simply ignored the argument.

This change makes it so the bounds callback function has an access to
this payload via RTCBoundsFunctionArguments::boundsUserPtr.

The change allows to use geometry-specific payload (geometryUserPtr)
for efficient intersection and filtering, while being able to access
data needed for the purpose of bounding box calculation.
@sergeyvfx

Copy link
Copy Markdown
Author

Developed on macOS, tested via integrating the patched version into Blender (also on macOS). Not sure what is the easiest way to run the full embree test suit, and also how to test oneAPI.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes the user-geometry bounds callback payload plumbing so the userPtr passed to rtcSetGeometryBoundsFunction() becomes accessible inside the bounds callback via RTCBoundsFunctionArguments::boundsUserPtr, while keeping geometryUserPtr available for geometry-wide data.

Changes:

  • Store the bounds-callback userPtr in UserGeometry/AccelSet and forward it when invoking the bounds callback.
  • Extend RTCBoundsFunctionArguments (C and ISPC headers) with a new boundsUserPtr field.
  • Initialize the new boundsUserPtr member in AccelSet’s constructor.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
kernels/common/scene_user_geometry.cpp Persist the bounds-callback payload when setting the bounds function.
kernels/common/accelset.h Pass the new payload through RTCBoundsFunctionArguments and add storage in AccelSet.
kernels/common/accelset.cpp Initialize boundsUserPtr to nullptr in AccelSet constructor.
include/embree4/rtcore_geometry.isph Add boundsUserPtr to the public ISPC bounds callback args struct.
include/embree4/rtcore_geometry.h Add boundsUserPtr to the public C bounds callback args struct.
Suppressed comments (2)

include/embree4/rtcore_geometry.h:80

  • RTCBoundsFunctionArguments is part of the public callback ABI; inserting boundsUserPtr between geometryUserPtr and primID shifts the offsets of primID, timeStep, and bounds_o. Applications compiled against older headers will interpret these fields incorrectly at runtime when used with the updated library. To preserve binary compatibility, append the new member at the end of the struct (or introduce a versioned args struct/size field) and update all corresponding call sites + ISPC header accordingly.
struct RTCBoundsFunctionArguments
{
  void* geometryUserPtr;
  void* boundsUserPtr;
  unsigned int primID;
  unsigned int timeStep;
  struct RTCBounds* bounds_o;
};

include/embree4/rtcore_geometry.isph:79

  • The ISPC RTCBoundsFunctionArguments layout must match the C API layout and should remain ABI-stable across releases. Inserting boundsUserPtr before primID changes field offsets for any existing ISPC user code compiled against older headers. Consider appending the new field at the end (and mirroring that order in the C header + all internal call sites).
struct RTCBoundsFunctionArguments
{
  void* uniform geometryUserPtr;
  void* uniform boundsUserPtr;
  uniform unsigned int primID;
  uniform unsigned int timeStep;
  uniform RTCBounds* uniform bounds_o;
};

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

- Add boundsUserPtr field to RTCBoundsFunctionArguments struct across all headers (C and ISPC)
- Update documentation to reflect the new field and its purpose
- Update CHANGELOG with release notes for version 4.5
@stefanatwork
stefanatwork self-requested a review August 17, 2026 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants