From 9058fa026e1244c58c16c15fb1f9cb8f3cb6f22a Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 17 Aug 2026 12:33:52 +0200 Subject: [PATCH 1/2] Pass bounds-callback specific payload to the callback 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. --- include/embree4/rtcore_geometry.h | 1 + include/embree4/rtcore_geometry.isph | 1 + kernels/common/accelset.cpp | 2 +- kernels/common/accelset.h | 3 +++ kernels/common/scene_user_geometry.cpp | 1 + 5 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/embree4/rtcore_geometry.h b/include/embree4/rtcore_geometry.h index aa75708508..a30ec9a364 100644 --- a/include/embree4/rtcore_geometry.h +++ b/include/embree4/rtcore_geometry.h @@ -73,6 +73,7 @@ enum RTCCurveFlags struct RTCBoundsFunctionArguments { void* geometryUserPtr; + void* boundsUserPtr; unsigned int primID; unsigned int timeStep; struct RTCBounds* bounds_o; diff --git a/include/embree4/rtcore_geometry.isph b/include/embree4/rtcore_geometry.isph index 7f9b8e2064..716a421972 100644 --- a/include/embree4/rtcore_geometry.isph +++ b/include/embree4/rtcore_geometry.isph @@ -72,6 +72,7 @@ enum RTCCurveFlags struct RTCBoundsFunctionArguments { void* uniform geometryUserPtr; + void* uniform boundsUserPtr; uniform unsigned int primID; uniform unsigned int timeStep; uniform RTCBounds* uniform bounds_o; diff --git a/kernels/common/accelset.cpp b/kernels/common/accelset.cpp index 8c18f31776..51bee106da 100644 --- a/kernels/common/accelset.cpp +++ b/kernels/common/accelset.cpp @@ -7,7 +7,7 @@ namespace embree { AccelSet::AccelSet (Device* device, Geometry::GType gtype, size_t numItems, size_t numTimeSteps) - : Geometry(device,gtype,(unsigned int)numItems,(unsigned int)numTimeSteps), boundsFunc(nullptr) {} + : Geometry(device,gtype,(unsigned int)numItems,(unsigned int)numTimeSteps), boundsFunc(nullptr), boundsUserPtr(nullptr) {} AccelSet::IntersectorN::IntersectorN (ErrorFunc error) : intersect((IntersectFuncN)error), occluded((OccludedFuncN)error), name(nullptr) {} diff --git a/kernels/common/accelset.h b/kernels/common/accelset.h index f78830e397..524cd5ab86 100644 --- a/kernels/common/accelset.h +++ b/kernels/common/accelset.h @@ -77,6 +77,7 @@ namespace embree assert(i < size()); RTCBoundsFunctionArguments args; args.geometryUserPtr = userPtr; + args.boundsUserPtr = boundsUserPtr; args.primID = (unsigned int)i; args.timeStep = (unsigned int)itime; args.bounds_o = (RTCBounds*)&box; @@ -91,6 +92,7 @@ namespace embree assert(i < size()); RTCBoundsFunctionArguments args; args.geometryUserPtr = userPtr; + args.boundsUserPtr = boundsUserPtr; args.primID = (unsigned int)i; args.timeStep = (unsigned int)(itime+0); args.bounds_o = (RTCBounds*)&box[0]; @@ -335,6 +337,7 @@ namespace embree public: RTCBoundsFunction boundsFunc; + void* boundsUserPtr; IntersectorN intersectorN; }; diff --git a/kernels/common/scene_user_geometry.cpp b/kernels/common/scene_user_geometry.cpp index 4bd07d39b2..520d33f8c5 100644 --- a/kernels/common/scene_user_geometry.cpp +++ b/kernels/common/scene_user_geometry.cpp @@ -25,6 +25,7 @@ namespace embree void UserGeometry::setBoundsFunction (RTCBoundsFunction bounds, void* userPtr) { this->boundsFunc = bounds; + this->boundsUserPtr = userPtr; } void UserGeometry::setIntersectFunctionN (RTCIntersectFunctionN intersect) { From 6085eedbec6c369441e2d0a68553baeadc3c1c70 Mon Sep 17 00:00:00 2001 From: "Werner, Stefan" Date: Mon, 17 Aug 2026 13:23:00 +0200 Subject: [PATCH 2/2] Update RTCBoundsFunctionArguments struct with boundsUserPtr field - 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 --- CHANGELOG.md | 1 + README.md | 6 ++++-- doc/src/api/rtcSetGeometryBoundsFunction.md | 6 ++++-- include/embree4/rtcore_geometry.h | 2 +- include/embree4/rtcore_geometry.isph | 2 +- man/man3/rtcSetGeometryBoundsFunction.3embree4 | 6 ++++-- 6 files changed, 15 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b82e05cc23..fa1402ec3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ Version History - Updated TinyEXR dependency to fix resource leaks. - Reduced memory copies and improved move semantics usage. - Bumped CMake minimum required version to 3.10. +- Updated `RTCBoundsFunctionArguments` struct to include `boundsUserPtr` field for consistency across all APIs and documentation. ### Embree 4.4.0 diff --git a/README.md b/README.md index a6f2c6667c..1c596bdf98 100644 --- a/README.md +++ b/README.md @@ -5812,6 +5812,7 @@ On failure an error code is set that can be queried using unsigned int primID; unsigned int timeStep; struct RTCBounds* bounds_o; + void* boundsUserPtr; }; typedef void (*RTCBoundsFunction)( @@ -5846,8 +5847,9 @@ pointer to a structure of type `RTCBoundsFunctionArguments` which contains various arguments, such as: the user data of the geometry (`geometryUserPtr` member), the ID of the primitive to calculate the bounds for (`primID` member), the time step at which to calculate the -bounds (`timeStep` member), and a memory location to write the -calculated bound to (`bounds_o` member). +bounds (`timeStep` member), a memory location to write the +calculated bound to (`bounds_o` member), and the custom pointer data +provided to `rtcSetGeometryBoundsFunction` (`boundsUserPtr` member). In a typical usage scenario one would store a pointer to the internal representation of the user geometry object using diff --git a/doc/src/api/rtcSetGeometryBoundsFunction.md b/doc/src/api/rtcSetGeometryBoundsFunction.md index 47e3d35850..abc0b71c70 100644 --- a/doc/src/api/rtcSetGeometryBoundsFunction.md +++ b/doc/src/api/rtcSetGeometryBoundsFunction.md @@ -15,6 +15,7 @@ unsigned int primID; unsigned int timeStep; struct RTCBounds* bounds_o; + void* boundsUserPtr; }; typedef void (*RTCBoundsFunction)( @@ -49,8 +50,9 @@ pointer to a structure of type `RTCBoundsFunctionArguments` which contains various arguments, such as: the user data of the geometry (`geometryUserPtr` member), the ID of the primitive to calculate the bounds for (`primID` member), the time step at which to calculate the -bounds (`timeStep` member), and a memory location to write the -calculated bound to (`bounds_o` member). +bounds (`timeStep` member), a memory location to write the +calculated bound to (`bounds_o` member), and the custom pointer data +provided to `rtcSetGeometryBoundsFunction` (`boundsUserPtr` member). In a typical usage scenario one would store a pointer to the internal representation of the user geometry object using diff --git a/include/embree4/rtcore_geometry.h b/include/embree4/rtcore_geometry.h index a30ec9a364..433dfe2d83 100644 --- a/include/embree4/rtcore_geometry.h +++ b/include/embree4/rtcore_geometry.h @@ -73,10 +73,10 @@ enum RTCCurveFlags struct RTCBoundsFunctionArguments { void* geometryUserPtr; - void* boundsUserPtr; unsigned int primID; unsigned int timeStep; struct RTCBounds* bounds_o; + void* boundsUserPtr; }; /* Bounding callback function */ diff --git a/include/embree4/rtcore_geometry.isph b/include/embree4/rtcore_geometry.isph index 716a421972..d4d8c59823 100644 --- a/include/embree4/rtcore_geometry.isph +++ b/include/embree4/rtcore_geometry.isph @@ -72,10 +72,10 @@ enum RTCCurveFlags struct RTCBoundsFunctionArguments { void* uniform geometryUserPtr; - void* uniform boundsUserPtr; uniform unsigned int primID; uniform unsigned int timeStep; uniform RTCBounds* uniform bounds_o; + void* uniform boundsUserPtr; }; /* Bounding callback function */ diff --git a/man/man3/rtcSetGeometryBoundsFunction.3embree4 b/man/man3/rtcSetGeometryBoundsFunction.3embree4 index 840c554273..b08f6bdc06 100644 --- a/man/man3/rtcSetGeometryBoundsFunction.3embree4 +++ b/man/man3/rtcSetGeometryBoundsFunction.3embree4 @@ -18,6 +18,7 @@ struct RTCBoundsFunctionArguments unsigned int primID; unsigned int timeStep; struct RTCBounds* bounds_o; + void* boundsUserPtr; }; typedef void (*RTCBoundsFunction)( @@ -53,8 +54,9 @@ invoked with a pointer to a structure of type such as: the user data of the geometry (\f[CR]geometryUserPtr\f[R] member), the ID of the primitive to calculate the bounds for (\f[CR]primID\f[R] member), the time step at which to calculate the -bounds (\f[CR]timeStep\f[R] member), and a memory location to write the -calculated bound to (\f[CR]bounds_o\f[R] member). +bounds (\f[CR]timeStep\f[R] member), a memory location to write the +calculated bound to (\f[CR]bounds_o\f[R] member), and the custom pointer +data provided to \f[CR]rtcSetGeometryBoundsFunction\f[R] (\f[CR]boundsUserPtr\f[R] member). .PP In a typical usage scenario one would store a pointer to the internal representation of the user geometry object using