HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
oidn.h
Go to the documentation of this file.
1 // Copyright 2009-2021 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 
4 #pragma once
5 
6 #include <stddef.h>
7 #include <stdbool.h>
8 #include <stdint.h>
9 
10 #include "config.h"
11 
13 
14 // -----------------------------------------------------------------------------
15 // Device
16 // -----------------------------------------------------------------------------
17 
18 // Device types
19 typedef enum
20 {
21  OIDN_DEVICE_TYPE_DEFAULT = 0, // select device automatically
22 
23  OIDN_DEVICE_TYPE_CPU = 1, // CPU device
25 
26 // Error codes
27 typedef enum
28 {
29  OIDN_ERROR_NONE = 0, // no error occurred
30  OIDN_ERROR_UNKNOWN = 1, // an unknown error occurred
31  OIDN_ERROR_INVALID_ARGUMENT = 2, // an invalid argument was specified
32  OIDN_ERROR_INVALID_OPERATION = 3, // the operation is not allowed
33  OIDN_ERROR_OUT_OF_MEMORY = 4, // not enough memory to execute the operation
34  OIDN_ERROR_UNSUPPORTED_HARDWARE = 5, // the hardware (e.g. CPU) is not supported
35  OIDN_ERROR_CANCELLED = 6, // the operation was cancelled by the user
36 } OIDNError;
37 
38 // Error callback function
39 typedef void (*OIDNErrorFunction)(void* userPtr, OIDNError code, const char* message);
40 
41 // Device handle
42 typedef struct OIDNDeviceImpl* OIDNDevice;
43 
44 // Creates a new device.
46 
47 // Retains the device (increments the reference count).
49 
50 // Releases the device (decrements the reference count).
52 
53 // Sets a boolean parameter of the device.
54 OIDN_API void oidnSetDevice1b(OIDNDevice device, const char* name, bool value);
55 
56 // Sets an integer parameter of the device.
57 OIDN_API void oidnSetDevice1i(OIDNDevice device, const char* name, int value);
58 
59 // Gets a boolean parameter of the device.
60 OIDN_API bool oidnGetDevice1b(OIDNDevice device, const char* name);
61 
62 // Gets an integer parameter of the device (e.g. "version").
63 OIDN_API int oidnGetDevice1i(OIDNDevice device, const char* name);
64 
65 // Sets the error callback function of the device.
67 
68 // Returns the first unqueried error code stored in the device for the current
69 // thread, optionally also returning a string message (if not NULL), and clears
70 // the stored error. Can be called with a NULL device as well to check why a
71 // device creation failed.
72 OIDN_API OIDNError oidnGetDeviceError(OIDNDevice device, const char** outMessage);
73 
74 // Commits all previous changes to the device.
75 // Must be called before first using the device (e.g. creating filters).
77 
78 // -----------------------------------------------------------------------------
79 // Buffer
80 // -----------------------------------------------------------------------------
81 
82 // Formats for images and other data stored in buffers
83 typedef enum
84 {
86 
87  // 32-bit single-precision floating point scalar and vector formats
92 } OIDNFormat;
93 
94 // Access modes for mapping buffers
95 typedef enum
96 {
97  OIDN_ACCESS_READ = 0, // read-only access
98  OIDN_ACCESS_WRITE = 1, // write-only access
99  OIDN_ACCESS_READ_WRITE = 2, // read and write access
100  OIDN_ACCESS_WRITE_DISCARD = 3, // write-only access, previous contents discarded
101 } OIDNAccess;
102 
103 // Buffer handle
104 typedef struct OIDNBufferImpl* OIDNBuffer;
105 
106 // Creates a new buffer (data allocated and owned by the device).
107 OIDN_API OIDNBuffer oidnNewBuffer(OIDNDevice device, size_t byteSize);
108 
109 // Creates a new shared buffer (data allocated and owned by the user).
110 OIDN_API OIDNBuffer oidnNewSharedBuffer(OIDNDevice device, void* ptr, size_t byteSize);
111 
112 // Maps a region of the buffer to host memory.
113 // If byteSize is 0, the maximum available amount of memory will be mapped.
114 OIDN_API void* oidnMapBuffer(OIDNBuffer buffer, OIDNAccess access, size_t byteOffset, size_t byteSize);
115 
116 // Unmaps a region of the buffer.
117 // mappedPtr must be a pointer returned by a previous call to oidnMapBuffer.
118 OIDN_API void oidnUnmapBuffer(OIDNBuffer buffer, void* mappedPtr);
119 
120 // Retains the buffer (increments the reference count).
122 
123 // Releases the buffer (decrements the reference count).
125 
126 // -----------------------------------------------------------------------------
127 // Filter
128 // -----------------------------------------------------------------------------
129 
130 // Progress monitor callback function
131 typedef bool (*OIDNProgressMonitorFunction)(void* userPtr, double n);
132 
133 // Filter handle
134 typedef struct OIDNFilterImpl* OIDNFilter;
135 
136 // Creates a new filter of the specified type (e.g. "RT").
137 OIDN_API OIDNFilter oidnNewFilter(OIDNDevice device, const char* type);
138 
139 // Retains the filter (increments the reference count).
141 
142 // Releases the filter (decrements the reference count).
144 
145 // Sets an image parameter of the filter (stored in a buffer).
146 // If bytePixelStride and/or byteRowStride are zero, these will be computed automatically.
149  size_t width, size_t height,
150  size_t byteOffset,
151  size_t bytePixelStride, size_t byteRowStride);
152 
153 // Sets an image parameter of the filter (owned by the user).
154 // If bytePixelStride and/or byteRowStride are zero, these will be computed automatically.
156  void* ptr, OIDNFormat format,
157  size_t width, size_t height,
158  size_t byteOffset,
159  size_t bytePixelStride, size_t byteRowStride);
160 
161 // Removes an image parameter of the filter that was previously set.
163 
164 // Sets an opaque data parameter of the filter (owned by the user).
166  void* ptr, size_t byteSize);
167 
168 // Notifies the filter that the contents of an opaque data parameter has been changed.
170 
171 // Removes an opaque data parameter of the filter that was previously set.
173 
174 // Sets a boolean parameter of the filter.
175 OIDN_API void oidnSetFilter1b(OIDNFilter filter, const char* name, bool value);
176 
177 // Gets a boolean parameter of the filter.
178 OIDN_API bool oidnGetFilter1b(OIDNFilter filter, const char* name);
179 
180 // Sets an integer parameter of the filter.
181 OIDN_API void oidnSetFilter1i(OIDNFilter filter, const char* name, int value);
182 
183 // Gets an integer parameter of the filter.
184 OIDN_API int oidnGetFilter1i(OIDNFilter filter, const char* name);
185 
186 // Sets a float parameter of the filter.
187 OIDN_API void oidnSetFilter1f(OIDNFilter filter, const char* name, float value);
188 
189 // Gets a float parameter of the filter.
190 OIDN_API float oidnGetFilter1f(OIDNFilter filter, const char* name);
191 
192 // Sets the progress monitor callback function of the filter.
194 
195 // Commits all previous changes to the filter.
196 // Must be called before first executing the filter.
198 
199 // Executes the filter.
201 
GLuint GLsizei const GLchar * message
Definition: glcorearb.h:2543
OIDN_API void oidnRemoveFilterData(OIDNFilter filter, const char *name)
OIDN_API int oidnGetDevice1i(OIDNDevice device, const char *name)
#define OIDN_API_NAMESPACE_BEGIN
Definition: config.h:25
OIDN_API bool oidnGetDevice1b(OIDNDevice device, const char *name)
OIDN_API void oidnUnmapBuffer(OIDNBuffer buffer, void *mappedPtr)
OIDN_API void oidnExecuteFilter(OIDNFilter filter)
OIDN_API int oidnGetFilter1i(OIDNFilter filter, const char *name)
OIDN_API void oidnReleaseDevice(OIDNDevice device)
OIDN_API void oidnReleaseFilter(OIDNFilter filter)
void
Definition: png.h:1083
OIDNFormat
Definition: oidn.h:83
GLuint const GLchar * name
Definition: glcorearb.h:786
struct OIDNFilterImpl * OIDNFilter
Definition: oidn.h:134
#define OIDN_API
Definition: config.h:52
OIDN_API void oidnSetDevice1b(OIDNDevice device, const char *name, bool value)
OIDN_API void oidnRemoveFilterImage(OIDNFilter filter, const char *name)
OIDN_API void oidnRetainFilter(OIDNFilter filter)
OIDN_API void oidnRetainBuffer(OIDNBuffer buffer)
OIDNDeviceType
Definition: oidn.h:19
struct OIDNBufferImpl * OIDNBuffer
Definition: oidn.h:104
OIDN_API void oidnSetFilter1f(OIDNFilter filter, const char *name, float value)
void(* OIDNErrorFunction)(void *userPtr, OIDNError code, const char *message)
Definition: oidn.h:39
OIDN_API OIDNBuffer oidnNewSharedBuffer(OIDNDevice device, void *ptr, size_t byteSize)
#define OIDN_API_NAMESPACE_END
Definition: config.h:26
Definition: core.h:760
OIDN_API void oidnUpdateFilterData(OIDNFilter filter, const char *name)
OIDN_API void * oidnMapBuffer(OIDNBuffer buffer, OIDNAccess access, size_t byteOffset, size_t byteSize)
OIDN_API void oidnReleaseBuffer(OIDNBuffer buffer)
OIDN_API void oidnRetainDevice(OIDNDevice device)
OIDN_API bool oidnGetFilter1b(OIDNFilter filter, const char *name)
OIDN_API void oidnCommitFilter(OIDNFilter filter)
OIDN_API void oidnSetFilterProgressMonitorFunction(OIDNFilter filter, OIDNProgressMonitorFunction func, void *userPtr)
OIDN_API void oidnSetFilter1b(OIDNFilter filter, const char *name, bool value)
OIDN_API void oidnSetDevice1i(OIDNDevice device, const char *name, int value)
OIDN_API void oidnCommitDevice(OIDNDevice device)
OIDN_API OIDNBuffer oidnNewBuffer(OIDNDevice device, size_t byteSize)
OIDN_API OIDNDevice oidnNewDevice(OIDNDeviceType type)
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glcorearb.h:1297
OIDN_API void oidnSetDeviceErrorFunction(OIDNDevice device, OIDNErrorFunction func, void *userPtr)
OIDN_API float oidnGetFilter1f(OIDNFilter filter, const char *name)
OIDN_API void oidnSetSharedFilterData(OIDNFilter filter, const char *name, void *ptr, size_t byteSize)
GLint GLsizei width
Definition: glcorearb.h:103
GLint GLsizei GLsizei height
Definition: glcorearb.h:103
GLdouble n
Definition: glcorearb.h:2008
GLuint GLint GLboolean GLint GLenum access
Definition: glcorearb.h:2222
GLint GLint GLsizei GLint GLenum format
Definition: glcorearb.h:108
GLenum func
Definition: glcorearb.h:783
bool(* OIDNProgressMonitorFunction)(void *userPtr, double n)
Definition: oidn.h:131
OIDNError
Definition: oidn.h:27
OIDN_API void oidnSetSharedFilterImage(OIDNFilter filter, const char *name, void *ptr, OIDNFormat format, size_t width, size_t height, size_t byteOffset, size_t bytePixelStride, size_t byteRowStride)
struct OIDNDeviceImpl * OIDNDevice
Definition: oidn.h:42
auto ptr(T p) -> const void *
Definition: format.h:2448
OIDN_API void oidnSetFilter1i(OIDNFilter filter, const char *name, int value)
OIDN_API void oidnSetFilterImage(OIDNFilter filter, const char *name, OIDNBuffer buffer, OIDNFormat format, size_t width, size_t height, size_t byteOffset, size_t bytePixelStride, size_t byteRowStride)
Definition: core.h:1131
OIDN_API OIDNFilter oidnNewFilter(OIDNDevice device, const char *type)
OIDNAccess
Definition: oidn.h:95
type
Definition: core.h:1059
OIDN_API OIDNError oidnGetDeviceError(OIDNDevice device, const char **outMessage)