Skip to content

Commit 0ed616e

Browse files
committed
Add getters for device callback functions and user pointers to the C API.
1 parent 5730b15 commit 0ed616e

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed

include/embree4/rtcore_device.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,22 @@ typedef void (*RTCErrorFunction)(void* userPtr, enum RTCError code, const char*
108108
/* Sets the error callback function. */
109109
RTC_API void rtcSetDeviceErrorFunction(RTCDevice device, RTCErrorFunction error, void* userPtr);
110110

111+
/* Gets the error callback function pointer. */
112+
RTC_API RTCErrorFunction rtcGetDeviceErrorFunction(RTCDevice device);
113+
114+
/* Gets the error callback function user pointer. */
115+
RTC_API void* rtcGetDeviceErrorFunctionUserPtr(RTCDevice device);
116+
111117
/* Memory monitor callback function */
112118
typedef bool (*RTCMemoryMonitorFunction)(void* ptr, ssize_t bytes, bool post);
113119

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

123+
/* Gets the memory monitor callback function pointer. */
124+
RTC_API RTCMemoryMonitorFunction rtcGetDeviceMemoryMonitorFunction(RTCDevice device);
125+
126+
/* Gets the memory monitor callback function user pointer. */
127+
RTC_API void* rtcGetDeviceMemoryMonitorFunctionUserPtr(RTCDevice device);
128+
117129
RTC_NAMESPACE_END

kernels/common/rtcore.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,28 @@ RTC_NAMESPACE_BEGIN;
163163
RTC_CATCH_END(device);
164164
}
165165

166+
RTC_API RTCErrorFunction rtcGetDeviceErrorFunction(RTCDevice hdevice)
167+
{
168+
Device* device = (Device*) hdevice;
169+
RTC_CATCH_BEGIN;
170+
RTC_TRACE(rtcGetDeviceErrorFunction);
171+
RTC_VERIFY_HANDLE(hdevice);
172+
return device->getErrorFunction();
173+
RTC_CATCH_END(device);
174+
return nullptr;
175+
}
176+
177+
RTC_API void* rtcGetDeviceErrorFunctionUserPtr(RTCDevice hdevice)
178+
{
179+
Device* device = (Device*) hdevice;
180+
RTC_CATCH_BEGIN;
181+
RTC_TRACE(rtcGetDeviceErrorFunctionUserPtr);
182+
RTC_VERIFY_HANDLE(hdevice);
183+
return device->getErrorFunctionUserPtr();
184+
RTC_CATCH_END(device);
185+
return nullptr;
186+
}
187+
166188
RTC_API void rtcSetDeviceMemoryMonitorFunction(RTCDevice hdevice, RTCMemoryMonitorFunction memoryMonitor, void* userPtr)
167189
{
168190
Device* device = (Device*) hdevice;
@@ -172,6 +194,28 @@ RTC_NAMESPACE_BEGIN;
172194
RTC_CATCH_END(device);
173195
}
174196

197+
RTC_API RTCMemoryMonitorFunction rtcGetDeviceMemoryMonitorFunction(RTCDevice hdevice)
198+
{
199+
Device* device = (Device*) hdevice;
200+
RTC_CATCH_BEGIN;
201+
RTC_TRACE(rtcGetDeviceMemoryMonitorFunction);
202+
RTC_VERIFY_HANDLE(hdevice);
203+
return device->getMemoryMonitorFunction();
204+
RTC_CATCH_END(device);
205+
return nullptr;
206+
}
207+
208+
RTC_API void* rtcGetDeviceMemoryMonitorFunctionUserPtr(RTCDevice hdevice)
209+
{
210+
Device* device = (Device*) hdevice;
211+
RTC_CATCH_BEGIN;
212+
RTC_TRACE(rtcGetDeviceMemoryMonitorFunctionUserPtr);
213+
RTC_VERIFY_HANDLE(hdevice);
214+
return device->getMemoryMonitorFunctionUserPtr();
215+
RTC_CATCH_END(device);
216+
return nullptr;
217+
}
218+
175219
RTC_API RTCBuffer rtcNewBuffer(RTCDevice hdevice, size_t byteSize)
176220
{
177221
RTC_CATCH_BEGIN;

kernels/common/state.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,16 @@ namespace embree
189189
error_function_userptr = uptr;
190190
}
191191

192+
RTCErrorFunction getErrorFunction() const
193+
{
194+
return error_function;
195+
}
196+
197+
void* getErrorFunctionUserPtr() const
198+
{
199+
return error_function_userptr;
200+
}
201+
192202
RTCErrorFunction error_function;
193203
void* error_function_userptr;
194204

@@ -199,6 +209,16 @@ namespace embree
199209
memory_monitor_userptr = uptr;
200210
}
201211

212+
RTCMemoryMonitorFunction getMemoryMonitorFunction() const
213+
{
214+
return memory_monitor_function;
215+
}
216+
217+
void* getMemoryMonitorFunctionUserPtr() const
218+
{
219+
return memory_monitor_userptr;
220+
}
221+
202222
RTCMemoryMonitorFunction memory_monitor_function;
203223
void* memory_monitor_userptr;
204224
};

0 commit comments

Comments
 (0)