Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4116dbf0b2 | ||
|
|
2410366638 |
+47
-2
@@ -801,6 +801,29 @@ as `handleType`). To maximize compatibility, we recommend to always use dedicate
|
||||
allocations if possible because some backends support only dedicated allocations
|
||||
for certain external memory types.
|
||||
|
||||
Importing external memory either transfers or retains ownership of the provided
|
||||
handle depending on its kind, following the conventions of the underlying
|
||||
compute and graphics APIs:
|
||||
|
||||
- When importing from a POSIX file descriptor (`oidnNewSharedBufferFromFD`), a
|
||||
*successful* import transfers ownership of the file descriptor to Open Image
|
||||
Denoise. The application *must not* close the file descriptor, nor perform
|
||||
any other operation on it, after the import. The file descriptor is closed
|
||||
automatically when it is no longer needed (i.e., when the imported buffer is
|
||||
released). If the import fails (the function returns `NULL`), ownership is
|
||||
*not* transferred and the application remains responsible for closing the
|
||||
file descriptor.
|
||||
|
||||
- When importing from a Win32 handle (`oidnNewSharedBufferFromWin32Handle`),
|
||||
ownership of the handle is *not* transferred to Open Image Denoise. The
|
||||
application retains ownership and must release the handle using the
|
||||
appropriate system call (e.g., `CloseHandle` for NT handle types) once it is
|
||||
no longer needed. Because NT handles hold their own reference to the
|
||||
underlying memory, the handle may be closed any time after a successful
|
||||
import. Global share (KMT) handles, however, do *not* hold such a reference,
|
||||
so the imported buffer must be released before the underlying memory is
|
||||
destroyed.
|
||||
|
||||
Metal buffers can be imported directly with
|
||||
|
||||
OIDNBuffer oidnNewSharedBufferFromMetal(OIDNDevice device, MTLBuffer_id buffer);
|
||||
@@ -925,6 +948,28 @@ Name Description
|
||||
------------------------------------------------------------ ---------------------------------------
|
||||
: Supported external semaphore type flags, i.e., valid constants of type `OIDNExternalSemaphoreTypeFlag`.
|
||||
|
||||
As with external buffers, importing an external semaphore transfers or retains
|
||||
ownership of the provided handle depending on its kind:
|
||||
|
||||
- When importing from a POSIX file descriptor (`oidnNewSharedSemaphoreFromFD`),
|
||||
a *successful* import transfers ownership of the file descriptor to Open
|
||||
Image Denoise. The application *must not* close the file descriptor, nor
|
||||
perform any other operation on it, after the import. The file descriptor is
|
||||
closed automatically when it is no longer needed (i.e., when the imported
|
||||
semaphore is released). If the import fails (the function returns `NULL`),
|
||||
ownership is *not* transferred and the application remains responsible for
|
||||
closing the file descriptor.
|
||||
|
||||
- When importing from a Win32 handle (`oidnNewSharedSemaphoreFromWin32Handle`),
|
||||
ownership of the handle is *not* transferred to Open Image Denoise. The
|
||||
application retains ownership and must release the handle using the
|
||||
appropriate system call (e.g., `CloseHandle` for NT handle types) once it is
|
||||
no longer needed. Because NT handles hold their own reference to the
|
||||
underlying semaphore, the handle may be closed any time after a successful
|
||||
import. Global share (KMT) handles, however, do *not* hold such a reference,
|
||||
so the imported semaphore must be released before the underlying semaphore is
|
||||
destroyed.
|
||||
|
||||
The reference counted semaphore objects can be retained and released with
|
||||
|
||||
void oidnRetainSemaphore(OIDNSemaphore semaphore);
|
||||
@@ -1020,7 +1065,7 @@ filters can be used.
|
||||
To unset a previously set image parameter, returning it to a state as if it had
|
||||
not been set, call
|
||||
|
||||
void oidnRemoveFilterImage(OIDNFilter filter, const char* name);
|
||||
void oidnUnsetFilterImage(OIDNFilter filter, const char* name);
|
||||
|
||||
Some special data used by filters are opaque/untyped (e.g. trained model weights
|
||||
blobs), which can be specified with the `oidnSetSharedFilterData` function:
|
||||
@@ -1040,7 +1085,7 @@ updated by calling
|
||||
|
||||
Unsetting an opaque data parameter can be performed with
|
||||
|
||||
void oidnRemoveFilterData(OIDNFilter filter, const char* name);
|
||||
void oidnUnsetFilterData(OIDNFilter filter, const char* name);
|
||||
|
||||
Filters may have parameters other than buffers as well, which you can set and
|
||||
get using the following functions:
|
||||
|
||||
@@ -331,11 +331,14 @@ OIDN_API OIDNBuffer oidnNewBufferWithStorage(OIDNDevice device, size_t byteSize,
|
||||
OIDN_API OIDNBuffer oidnNewSharedBuffer(OIDNDevice device, void* devPtr, size_t byteSize);
|
||||
|
||||
// Creates a shared buffer by importing external memory from a POSIX file descriptor.
|
||||
// On success, ownership of the file descriptor is transferred to the device, so the application
|
||||
// must not close it; on failure (returns NULL), the application retains ownership of it.
|
||||
OIDN_API OIDNBuffer oidnNewSharedBufferFromFD(OIDNDevice device,
|
||||
OIDNExternalMemoryTypeFlags fdType,
|
||||
int fd, size_t byteSize);
|
||||
|
||||
// Creates a shared buffer by importing external memory from a Win32 handle.
|
||||
// Ownership of the handle is not transferred to the device, so the application must release it.
|
||||
OIDN_API OIDNBuffer oidnNewSharedBufferFromWin32Handle(OIDNDevice device,
|
||||
OIDNExternalMemoryTypeFlags handleType,
|
||||
void* handle, const void* name, size_t byteSize);
|
||||
@@ -419,11 +422,14 @@ typedef OIDNFlags OIDNExternalSemaphoreTypeFlags;
|
||||
typedef struct OIDNSemaphoreImpl* OIDNSemaphore;
|
||||
|
||||
// Creates a shared semaphore by importing an external semaphore from a POSIX file descriptor.
|
||||
// On success, ownership of the file descriptor is transferred to the device, so the application
|
||||
// must not close it; on failure (returns NULL), the application retains ownership of it.
|
||||
OIDN_API OIDNSemaphore oidnNewSharedSemaphoreFromFD(OIDNDevice device,
|
||||
OIDNExternalSemaphoreTypeFlags fdType,
|
||||
int fd);
|
||||
|
||||
// Creates a shared semaphore by importing an external semaphore from a Win32 handle.
|
||||
// Ownership of the handle is not transferred to the device, so the application must release it.
|
||||
OIDN_API OIDNSemaphore oidnNewSharedSemaphoreFromWin32Handle(OIDNDevice device,
|
||||
OIDNExternalSemaphoreTypeFlags handleType,
|
||||
void* handle, const void* name);
|
||||
|
||||
@@ -877,6 +877,8 @@ OIDN_NAMESPACE_BEGIN
|
||||
}
|
||||
|
||||
// Creates a shared buffer by importing external memory from a POSIX file descriptor.
|
||||
// On success, ownership of the file descriptor is transferred to the device, so the application
|
||||
// must not close it; on failure the application retains ownership of it.
|
||||
BufferRef newBuffer(ExternalMemoryTypeFlags fdType, int fd, size_t byteSize) const
|
||||
{
|
||||
return oidnNewSharedBufferFromFD(
|
||||
@@ -884,6 +886,7 @@ OIDN_NAMESPACE_BEGIN
|
||||
}
|
||||
|
||||
// Creates a shared buffer by importing external memory from a Win32 handle.
|
||||
// Ownership of the handle is not transferred to the device, so the application must release it.
|
||||
BufferRef newBuffer(ExternalMemoryTypeFlags handleType, void* handle, const void* name, size_t byteSize) const
|
||||
{
|
||||
return oidnNewSharedBufferFromWin32Handle(
|
||||
@@ -899,12 +902,17 @@ OIDN_NAMESPACE_BEGIN
|
||||
}
|
||||
#endif
|
||||
|
||||
// Creates a shared semaphore by importing an external semaphore from a POSIX file descriptor.
|
||||
// On success, ownership of the file descriptor is transferred to the device, so the application
|
||||
// must not close it; on failure the application retains ownership of it.
|
||||
SemaphoreRef newSemaphore(ExternalSemaphoreTypeFlags fdType, int fd) const
|
||||
{
|
||||
return oidnNewSharedSemaphoreFromFD(
|
||||
handle, static_cast<OIDNExternalSemaphoreTypeFlags>(fdType), fd);
|
||||
}
|
||||
|
||||
// Creates a shared semaphore by importing an external semaphore from a Win32 handle.
|
||||
// Ownership of the handle is not transferred to the device, so the application must release it.
|
||||
SemaphoreRef newSemaphore(ExternalSemaphoreTypeFlags handleType, void* handle, const void* name) const
|
||||
{
|
||||
return oidnNewSharedSemaphoreFromWin32Handle(
|
||||
|
||||
Reference in New Issue
Block a user