@@ -141,6 +141,10 @@ OIDN_API_NAMESPACE_BEGIN
141141 }
142142 }
143143
144+ // -----------------------------------------------------------------------------------------------
145+ // Physical Device
146+ // -----------------------------------------------------------------------------------------------
147+
144148 OIDN_API int oidnGetNumPhysicalDevices ()
145149 {
146150 OIDN_TRY
@@ -193,6 +197,10 @@ OIDN_API_NAMESPACE_BEGIN
193197 return nullptr ;
194198 }
195199
200+ // -----------------------------------------------------------------------------------------------
201+ // Device
202+ // -----------------------------------------------------------------------------------------------
203+
196204 OIDN_API bool oidnIsCPUDeviceSupported ()
197205 {
198206 OIDN_TRY
@@ -554,6 +562,10 @@ OIDN_API_NAMESPACE_BEGIN
554562 OIDN_CATCH_DEVICE (device)
555563 }
556564
565+ // -----------------------------------------------------------------------------------------------
566+ // Buffer
567+ // -----------------------------------------------------------------------------------------------
568+
557569 OIDN_API OIDNBuffer oidnNewBuffer (OIDNDevice hDevice, size_t byteSize)
558570 {
559571 Device* device = reinterpret_cast <Device*>(hDevice);
@@ -735,6 +747,100 @@ OIDN_API_NAMESPACE_BEGIN
735747 return nullptr ;
736748 }
737749
750+ // -----------------------------------------------------------------------------------------------
751+ // Semaphore
752+ // -----------------------------------------------------------------------------------------------
753+
754+ OIDN_API OIDNSemaphore oidnNewSharedSemaphoreFromFD (OIDNDevice hDevice,
755+ OIDNExternalSemaphoreTypeFlag fdType,
756+ int fd)
757+ {
758+ Device* device = reinterpret_cast <Device*>(hDevice);
759+ OIDN_TRY
760+ checkHandle (hDevice);
761+ OIDN_LOCK_DEVICE (device);
762+ device->checkCommitted ();
763+ if (!(static_cast <ExternalSemaphoreTypeFlag>(fdType) & device->getExternalSemaphoreTypes ()))
764+ throw Exception (Error::InvalidArgument, " external semaphore type not supported by the device" );
765+ Ref<Semaphore> semaphore = device->newExternalSemaphore (
766+ static_cast <ExternalSemaphoreTypeFlag>(fdType), fd);
767+ return reinterpret_cast <OIDNSemaphore>(semaphore.detach ());
768+ OIDN_CATCH_DEVICE (device)
769+ return nullptr ;
770+ }
771+
772+ OIDN_API OIDNSemaphore oidnNewSharedSemaphoreFromWin32Handle (OIDNDevice hDevice,
773+ OIDNExternalSemaphoreTypeFlag handleType,
774+ void * handle, const void * name)
775+ {
776+ Device* device = reinterpret_cast <Device*>(hDevice);
777+ OIDN_TRY
778+ checkHandle (hDevice);
779+ OIDN_LOCK_DEVICE (device);
780+ device->checkCommitted ();
781+ if (!(static_cast <ExternalSemaphoreTypeFlag>(handleType) & device->getExternalSemaphoreTypes ()))
782+ throw Exception (Error::InvalidArgument, " external semaphore type not supported by the device" );
783+ if ((!handle && !name) || (handle && name))
784+ throw Exception (Error::InvalidArgument, " exactly one of the external memory handle and name must be non-null" );
785+ Ref<Semaphore> semaphore = device->newExternalSemaphore (
786+ static_cast <ExternalSemaphoreTypeFlag>(handleType), handle, name);
787+ return reinterpret_cast <OIDNSemaphore>(semaphore.detach ());
788+ OIDN_CATCH_DEVICE (device)
789+ return nullptr ;
790+ }
791+
792+ OIDN_API void oidnSignalSemaphoresAsync (OIDNDevice hDevice,
793+ const OIDNSemaphore* hSemaphores,
794+ const uint64_t * values,
795+ int numSemaphores)
796+ {
797+ Device* device = reinterpret_cast <Device*>(hDevice);
798+ OIDN_TRY
799+ checkHandle (hDevice);
800+ OIDN_LOCK_DEVICE (device);
801+ device->checkCommitted ();
802+ device->submitSignalSemaphores (
803+ reinterpret_cast <Semaphore* const *>(hSemaphores),
804+ values,
805+ numSemaphores);
806+ OIDN_CATCH_DEVICE (device)
807+ }
808+
809+ OIDN_API void oidnWaitSemaphoresAsync (OIDNDevice hDevice,
810+ const OIDNSemaphore* hSemaphores,
811+ const uint64_t * values,
812+ const uint32_t * timeoutsMs,
813+ int numSemaphores)
814+ {
815+ Device* device = reinterpret_cast <Device*>(hDevice);
816+ OIDN_TRY
817+ checkHandle (hDevice);
818+ OIDN_LOCK_DEVICE (device);
819+ device->checkCommitted ();
820+ device->submitWaitSemaphores (
821+ reinterpret_cast <Semaphore* const *>(hSemaphores),
822+ values,
823+ timeoutsMs,
824+ numSemaphores);
825+ OIDN_CATCH_DEVICE (device)
826+ }
827+
828+ OIDN_API void oidnRetainSemaphore (OIDNSemaphore hSemaphore)
829+ {
830+ Semaphore* semaphore = reinterpret_cast <Semaphore*>(hSemaphore);
831+ retainObject (semaphore);
832+ }
833+
834+ OIDN_API void oidnReleaseSemaphore (OIDNSemaphore hSemaphore)
835+ {
836+ Semaphore* semaphore = reinterpret_cast <Semaphore*>(hSemaphore);
837+ releaseObject (semaphore);
838+ }
839+
840+ // -----------------------------------------------------------------------------------------------
841+ // Filter
842+ // -----------------------------------------------------------------------------------------------
843+
738844 OIDN_API OIDNFilter oidnNewFilter (OIDNDevice hDevice, const char * type)
739845 {
740846 Device* device = reinterpret_cast <Device*>(hDevice);
0 commit comments