Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions include/embree4/rtcore_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ RTC_API_CPP sycl::event rtcCommitBufferWithQueue(RTCBuffer buffer, sycl::queue q

#endif

/* Returns if the buffer is a shared buffer. */
RTC_API bool rtcIsBufferShared(RTCBuffer buffer);

/* Returns the size of the buffer in bytes. */
RTC_API size_t rtcGetBufferSize(RTCBuffer buffer);

/* Returns a pointer to the buffer data. */
RTC_API void* rtcGetBufferData(RTCBuffer buffer);

Expand Down
12 changes: 12 additions & 0 deletions include/embree4/rtcore_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,22 @@ typedef void (*RTCErrorFunction)(void* userPtr, enum RTCError code, const char*
/* Sets the error callback function. */
RTC_API void rtcSetDeviceErrorFunction(RTCDevice device, RTCErrorFunction error, void* userPtr);

/* Gets the error callback function pointer. */
RTC_API RTCErrorFunction rtcGetDeviceErrorFunction(RTCDevice device);

/* Gets the error callback function user pointer. */
RTC_API void* rtcGetDeviceErrorFunctionUserPtr(RTCDevice device);

/* Memory monitor callback function */
typedef bool (*RTCMemoryMonitorFunction)(void* ptr, ssize_t bytes, bool post);

/* Sets the memory monitor callback function. */
RTC_API void rtcSetDeviceMemoryMonitorFunction(RTCDevice device, RTCMemoryMonitorFunction memoryMonitor, void* userPtr);

/* Gets the memory monitor callback function pointer. */
RTC_API RTCMemoryMonitorFunction rtcGetDeviceMemoryMonitorFunction(RTCDevice device);

/* Gets the memory monitor callback function user pointer. */
RTC_API void* rtcGetDeviceMemoryMonitorFunctionUserPtr(RTCDevice device);

RTC_NAMESPACE_END
20 changes: 20 additions & 0 deletions include/embree4/rtcore_scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ RTC_API void rtcAttachGeometryByID(RTCScene scene, RTCGeometry geometry, unsigne
/* Detaches the geometry from the scene. */
RTC_API void rtcDetachGeometry(RTCScene scene, unsigned int geomID);

/* Gets the number of geometry IDs attached to the scene. To get the array of valid IDs allocate an array of the correct size and pass it as geomIDs. */
RTC_API size_t rtcGetNumAttachedGeometryIDs(RTCScene scene);
RTC_API void rtcGetAttachedGeometryIDs(RTCScene scene, size_t* numGeomIDs, unsigned int* geomIDs RTC_DEFAULT_VALUE(nullptr));

/* Gets the number of geometries attached to the scene. To get the array of valid geometries allocate an array of the correct size and pass it as geometries. */
RTC_API size_t rtcGetNumAttachedGeometries(RTCScene scene);
RTC_API void rtcGetAttachedGeometries(RTCScene scene, size_t* numGeoms, RTCGeometry* geometries RTC_DEFAULT_VALUE(nullptr));

/* Gets a geometry handle from the scene. This function is not thread safe and should get used during rendering. */
RTC_API RTCGeometry rtcGetGeometry(RTCScene scene, unsigned int geomID);

Expand All @@ -120,16 +128,28 @@ RTC_API void rtcCommitScene(RTCScene scene);
/* Commits the scene from multiple threads. */
RTC_API void rtcJoinCommitScene(RTCScene scene);

/* Returns if the scene has been modified since it was last committed. */
RTC_API bool rtcIsSceneModified(RTCScene scene);


/* Progress monitor callback function */
typedef bool (*RTCProgressMonitorFunction)(void* ptr, double n);

/* Sets the progress monitor callback function of the scene. */
RTC_API void rtcSetSceneProgressMonitorFunction(RTCScene scene, RTCProgressMonitorFunction progress, void* ptr);

/* Gets the progress monitor callback function of the scene. */
RTC_API RTCProgressMonitorFunction rtcGetSceneProgressMonitorFunction(RTCScene scene);

/* Gets the progress monitor callback function user pointer of the scene. */
RTC_API void* rtcGetSceneProgressMonitorFunctionUserPtr(RTCScene scene);

/* Sets the build quality of the scene. */
RTC_API void rtcSetSceneBuildQuality(RTCScene scene, enum RTCBuildQuality quality);

/* Gets the build quality of the scene. */
RTC_API enum RTCBuildQuality rtcGetSceneBuildQuality(RTCScene scene);

/* Sets the scene flags. */
RTC_API void rtcSetSceneFlags(RTCScene scene, enum RTCSceneFlags flags);

Expand Down
15 changes: 15 additions & 0 deletions kernels/common/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ namespace embree
return numBytes;
}

/*! returns if the buffer is shared */
__forceinline bool isShared() const {
return shared;
}

/*! returns true of the buffer is not empty */
__forceinline operator bool() const {
return ptr;
Expand Down Expand Up @@ -349,6 +354,16 @@ namespace embree
volatile int MAYBE_UNUSED w = *((int*)getPtr(size()-1)+3); // FIXME: is failing hard avoidable?
}

/*! returns the buffer object */
__forceinline Ref<Buffer> getBuffer() {
return buffer;
}

/*! returns the offset of the view from the base pointer */
__forceinline size_t getOffset() const {
return ptr_ofs - buffer->getPtr();
}

public:
char* ptr_ofs; //!< base pointer plus offset
char* dptr_ofs; //!< base pointer plus offset in device memory
Expand Down
204 changes: 199 additions & 5 deletions kernels/common/rtcore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,28 @@ RTC_NAMESPACE_BEGIN;
RTC_CATCH_END(device);
}

RTC_API RTCErrorFunction rtcGetDeviceErrorFunction(RTCDevice hdevice)
{
Device* device = (Device*) hdevice;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcGetDeviceErrorFunction);
RTC_VERIFY_HANDLE(hdevice);
return device->getErrorFunction();
RTC_CATCH_END(device);
return nullptr;
}

RTC_API void* rtcGetDeviceErrorFunctionUserPtr(RTCDevice hdevice)
{
Device* device = (Device*) hdevice;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcGetDeviceErrorFunctionUserPtr);
RTC_VERIFY_HANDLE(hdevice);
return device->getErrorFunctionUserPtr();
RTC_CATCH_END(device);
return nullptr;
}

RTC_API void rtcSetDeviceMemoryMonitorFunction(RTCDevice hdevice, RTCMemoryMonitorFunction memoryMonitor, void* userPtr)
{
Device* device = (Device*) hdevice;
Expand All @@ -190,6 +212,28 @@ RTC_NAMESPACE_BEGIN;
RTC_CATCH_END(device);
}

RTC_API RTCMemoryMonitorFunction rtcGetDeviceMemoryMonitorFunction(RTCDevice hdevice)
{
Device* device = (Device*) hdevice;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcGetDeviceMemoryMonitorFunction);
RTC_VERIFY_HANDLE(hdevice);
return device->getMemoryMonitorFunction();
RTC_CATCH_END(device);
return nullptr;
}

RTC_API void* rtcGetDeviceMemoryMonitorFunctionUserPtr(RTCDevice hdevice)
{
Device* device = (Device*) hdevice;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcGetDeviceMemoryMonitorFunctionUserPtr);
RTC_VERIFY_HANDLE(hdevice);
return device->getMemoryMonitorFunctionUserPtr();
RTC_CATCH_END(device);
return nullptr;
}

RTC_API RTCBuffer rtcNewBuffer(RTCDevice hdevice, size_t byteSize)
{
RTC_CATCH_BEGIN;
Expand Down Expand Up @@ -245,6 +289,28 @@ RTC_NAMESPACE_BEGIN;
return nullptr;
}

RTC_API bool rtcIsBufferShared(RTCBuffer hbuffer)
{
Buffer* buffer = (Buffer*)hbuffer;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcIsBufferShared);
RTC_VERIFY_HANDLE(hbuffer);
return buffer->isShared();
RTC_CATCH_END2(buffer);
return false;
}

RTC_API size_t rtcGetBufferSize(RTCBuffer hbuffer)
{
Buffer* buffer = (Buffer*)hbuffer;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcGetBufferSize);
RTC_VERIFY_HANDLE(hbuffer);
return buffer->bytes();
RTC_CATCH_END2(buffer);
return 0;
}

RTC_API void* rtcGetBufferData(RTCBuffer hbuffer)
{
Buffer* buffer = (Buffer*)hbuffer;
Expand Down Expand Up @@ -285,7 +351,7 @@ RTC_NAMESPACE_BEGIN;
RTC_CATCH_END2(buffer);
}

RTC_API RTCScene rtcNewScene (RTCDevice hdevice)
RTC_API RTCScene rtcNewScene (RTCDevice hdevice)
{
RTC_CATCH_BEGIN;
RTC_TRACE(rtcNewScene);
Expand Down Expand Up @@ -321,7 +387,7 @@ RTC_NAMESPACE_BEGIN;
return (RTCTraversable)nullptr;
}

RTC_API void rtcSetSceneProgressMonitorFunction(RTCScene hscene, RTCProgressMonitorFunction progress, void* ptr)
RTC_API void rtcSetSceneProgressMonitorFunction(RTCScene hscene, RTCProgressMonitorFunction progress, void* ptr)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
Expand All @@ -332,6 +398,32 @@ RTC_NAMESPACE_BEGIN;
RTC_CATCH_END2(scene);
}

RTC_API RTCProgressMonitorFunction rtcGetSceneProgressMonitorFunction(RTCScene hscene)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcGetSceneProgressMonitorFunction);
RTC_VERIFY_HANDLE(hscene);
RTC_ENTER_DEVICE(hscene);
Lock<MutexSys> lock(g_mutex);
return scene->getProgressMonitorFunction();
RTC_CATCH_END2(scene);
return nullptr;
}

RTC_API void* rtcGetSceneProgressMonitorFunctionUserPtr(RTCScene hscene)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcGetSceneProgressMonitorFunctionUserPtr);
RTC_VERIFY_HANDLE(hscene);
RTC_ENTER_DEVICE(hscene);
Lock<MutexSys> lock(g_mutex);
return scene->getProgressMonitorFunctionUserPtr();
RTC_CATCH_END2(scene);
return nullptr;
}

RTC_API void rtcSetSceneBuildQuality (RTCScene hscene, RTCBuildQuality quality)
{
Scene* scene = (Scene*) hscene;
Expand All @@ -346,6 +438,18 @@ RTC_NAMESPACE_BEGIN;
RTC_CATCH_END2(scene);
}

RTC_API RTCBuildQuality rtcGetSceneBuildQuality (RTCScene hscene)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcGetSceneBuildQuality);
RTC_VERIFY_HANDLE(hscene);
RTC_ENTER_DEVICE(hscene);
return scene->getBuildQuality();
RTC_CATCH_END2(scene);
return RTC_BUILD_QUALITY_MEDIUM;
}

RTC_API void rtcSetSceneFlags (RTCScene hscene, RTCSceneFlags flags)
{
Scene* scene = (Scene*) hscene;
Expand Down Expand Up @@ -375,7 +479,7 @@ RTC_NAMESPACE_BEGIN;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcCommitScene);
RTC_VERIFY_HANDLE(hscene);

scene->commit(false);

#if defined(EMBREE_SYCL_SUPPORT)
Expand All @@ -391,11 +495,23 @@ RTC_NAMESPACE_BEGIN;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcJoinCommitScene);
RTC_VERIFY_HANDLE(hscene);

scene->commit(true);
RTC_CATCH_END2(scene);
}

RTC_API bool rtcIsSceneModified(RTCScene hscene)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcIsSceneModified);
RTC_VERIFY_HANDLE(hscene);
RTC_ENTER_DEVICE(hscene);
return scene->isModified();
RTC_CATCH_END2(scene);
return false;
}

RTC_API void rtcGetSceneBounds(RTCScene hscene, RTCBounds* bounds_o)
{
Scene* scene = (Scene*) hscene;
Expand Down Expand Up @@ -1362,7 +1478,7 @@ RTC_NAMESPACE_BEGIN;
rtcForwardOccluded16Ex(valid, args, (RTCScene)htraversable, iray, instID, instPrimID);
}

RTC_API void rtcRetainScene (RTCScene hscene)
RTC_API void rtcRetainScene (RTCScene hscene)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
Expand Down Expand Up @@ -2295,6 +2411,84 @@ RTC_API void rtcSetGeometryTransform(RTCGeometry hgeometry, unsigned int timeSte
RTC_CATCH_END2(geometry);
}

RTC_API size_t rtcGetNumAttachedGeometryIDs (RTCScene hscene)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcGetNumAttachedGeometryIDs);
RTC_VERIFY_HANDLE(hscene);
RTC_ENTER_DEVICE(hscene);
unsigned int numGeomIDs = scene->size();
for (unsigned int i = 0; i < scene->size(); ++i) {
Geometry* ptr = scene->get(i);
if (!ptr) {
numGeomIDs -= 1;
}
}
return numGeomIDs;
RTC_CATCH_END2(scene);
return 0;
}

RTC_API void rtcGetAttachedGeometryIDs (RTCScene hscene, size_t* numGeomIDs, unsigned int* geomIDs)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcGetAttachedGeometryIDs);
RTC_VERIFY_HANDLE(hscene);
RTC_VERIFY_HANDLE(numGeomIDs);
RTC_ENTER_DEVICE(hscene);
*numGeomIDs = scene->size();
for (unsigned int i = 0; i < scene->size(); ++i) {
Geometry* ptr = scene->get(i);
if (!ptr) {
*numGeomIDs -= 1;
} else if (geomIDs) {
*geomIDs++ = i;
}
}
RTC_CATCH_END2(scene);
}

RTC_API size_t rtcGetNumAttachedGeometries (RTCScene hscene)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcGetNumAttachedGeometryIDs);
RTC_VERIFY_HANDLE(hscene);
RTC_ENTER_DEVICE(hscene);
unsigned int numGeomIDs = scene->size();
for (unsigned int i = 0; i < scene->size(); ++i) {
Geometry* ptr = scene->get(i);
if (!ptr) {
numGeomIDs -= 1;
}
}
return numGeomIDs;
RTC_CATCH_END2(scene);
return 0;
}

RTC_API void rtcGetAttachedGeometries (RTCScene hscene, size_t* numGeoms, RTCGeometry* geometries)
{
Scene* scene = (Scene*) hscene;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcGetAttachedGeometries);
RTC_VERIFY_HANDLE(hscene);
RTC_VERIFY_HANDLE(numGeoms);
RTC_ENTER_DEVICE(hscene);
*numGeoms = scene->size();
for (unsigned int i = 0; i < scene->size(); ++i) {
Geometry* ptr = scene->get(i);
if (!ptr) {
*numGeoms -= 1;
} else if (geometries) {
*geometries++ = (RTCGeometry) ptr;
}
}
RTC_CATCH_END2(scene);
}

RTC_API RTCGeometry rtcGetGeometry (RTCScene hscene, unsigned int geomID)
{
Scene* scene = (Scene*) hscene;
Expand Down
Loading