Debian Codegraph @

gst-libs/gst/cuda/stub/cuda.h

raw
1 /* CUDA stub header
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Library General Public
5 * License as published by the Free Software Foundation; either
6 * version 2 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Library General Public License for more details.
12 *
13 * You should have received a copy of the GNU Library General Public
14 * License along with this library; if not, write to the
15 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
16 * Boston, MA 02110-1301, USA.
17 */
18
19 #ifndef __GST_CUDA_STUB_H__
20 #define __GST_CUDA_STUB_H__
21
22 #include <glib.h>
23
24 G_BEGIN_DECLS
25
26 typedef gpointer CUcontext;
27 typedef gpointer CUgraphicsResource;
28 typedef gpointer CUstream;
29 typedef gpointer CUarray;
30 typedef gpointer CUmodule;
31 typedef gpointer CUfunction;
32 typedef gpointer CUmipmappedArray;
33 typedef gpointer CUevent;
34 typedef gpointer CUmemoryPool;
35 typedef gpointer CUexternalMemory;
36 typedef gpointer CUexternalSemaphore;
37
38 typedef guint64 CUtexObject;
39 typedef guintptr CUdeviceptr;
40 typedef gint CUdevice;
41
42 typedef struct CUuuid_st
43 {
44 char bytes[16];
45 } CUuuid;
46
47 typedef enum
48 {
49 CUDA_SUCCESS = 0,
50 CUDA_ERROR_NO_DEVICE = 100,
51 CUDA_ERROR_ALREADY_MAPPED = 208,
52 CUDA_ERROR_NOT_SUPPORTED = 801,
53 } CUresult;
54
55 typedef enum
56 {
57 CU_MEMORYTYPE_HOST = 1,
58 CU_MEMORYTYPE_DEVICE = 2,
59 CU_MEMORYTYPE_ARRAY = 3,
60 CU_MEMORYTYPE_UNIFIED = 4,
61 } CUmemorytype;
62
63 typedef enum
64 {
65 CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT = 14,
66 CU_DEVICE_ATTRIBUTE_UNIFIED_ADDRESSING = 41,
67 CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR = 75,
68 CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR = 76,
69 CU_DEVICE_ATTRIBUTE_VIRTUAL_MEMORY_MANAGEMENT_SUPPORTED = 102,
70 CU_DEVICE_ATTRIBUTE_HANDLE_TYPE_POSIX_FILE_DESCRIPTOR_SUPPORTED = 103,
71 CU_DEVICE_ATTRIBUTE_HANDLE_TYPE_WIN32_HANDLE_SUPPORTED = 104,
72 CU_DEVICE_ATTRIBUTE_HANDLE_TYPE_WIN32_KMT_HANDLE_SUPPORTED = 105,
73 CU_DEVICE_ATTRIBUTE_MEMORY_POOLS_SUPPORTED = 115,
74 } CUdevice_attribute;
75
76 typedef enum
77 {
78 CU_GRAPHICS_REGISTER_FLAGS_NONE = 0x00,
79 CU_GRAPHICS_REGISTER_FLAGS_READ_ONLY = 0x01,
80 CU_GRAPHICS_REGISTER_FLAGS_WRITE_DISCARD = 0x02,
81 CU_GRAPHICS_REGISTER_FLAGS_SURFACE_LOAD_STORE = 0x04,
82 CU_GRAPHICS_REGISTER_FLAGS_TEXTURE_GATHER = 0x08,
83 } CUgraphicsRegisterFlags;
84
85 typedef enum
86 {
87 CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE = 0x00,
88 CU_GRAPHICS_MAP_RESOURCE_FLAGS_READ_ONLY = 0x01,
89 CU_GRAPHICS_MAP_RESOURCE_FLAGS_WRITE_DISCARD = 0x02,
90 } CUgraphicsMapResourceFlags;
91
92 typedef enum
93 {
94 CU_STREAM_DEFAULT = 0x0,
95 CU_STREAM_NON_BLOCKING = 0x1
96 } CUstream_flags;
97
98 typedef enum
99 {
100 CU_TR_FILTER_MODE_POINT = 0,
101 CU_TR_FILTER_MODE_LINEAR = 1
102 } CUfilter_mode;
103
104 typedef enum
105 {
106 CU_TR_ADDRESS_MODE_WRAP = 0,
107 CU_TR_ADDRESS_MODE_CLAMP = 1,
108 CU_TR_ADDRESS_MODE_MIRROR = 2,
109 CU_TR_ADDRESS_MODE_BORDER = 3
110 } CUaddress_mode;
111
112 typedef enum
113 {
114 CU_RESOURCE_TYPE_ARRAY = 0,
115 CU_RESOURCE_TYPE_MIPMAPPED_ARRAY = 1,
116 CU_RESOURCE_TYPE_LINEAR = 2,
117 CU_RESOURCE_TYPE_PITCH2D = 3
118 } CUresourcetype;
119
120 typedef enum
121 {
122 CU_AD_FORMAT_UNSIGNED_INT8 = 1,
123 CU_AD_FORMAT_UNSIGNED_INT16 = 2,
124 } CUarray_format;
125
126 typedef enum
127 {
128 CU_RES_VIEW_FORMAT_NONE = 0,
129 } CUresourceViewFormat;
130
131 typedef enum
132 {
133 CU_EVENT_DEFAULT = 0x0,
134 CU_EVENT_BLOCKING_SYNC = 0x1,
135 CU_EVENT_DISABLE_TIMING = 0x2,
136 CU_EVENT_INTERPROCESS = 0x4,
137 } CUevent_flags;
138
139 typedef enum
140 {
141 CU_LIMIT_STACK_SIZE = 0x0,
142 CU_LIMIT_PRINTF_FIFO_SIZE = 0x1,
143 CU_LIMIT_MALLOC_HEAP_SIZE = 0x2,
144 CU_LIMIT_DEV_RUNTIME_SYNC_DEPTH = 0x3,
145 CU_LIMIT_DEV_RUNTIME_PENDING_LAUNCH_COUNT = 0x4,
146 CU_LIMIT_MAX_L2_FETCH_GRANULARITY = 0x5,
147 CU_LIMIT_PERSISTING_L2_CACHE_SIZE = 0x6,
148 CU_LIMIT_SHMEM_SIZE = 0x7,
149 CU_LIMIT_CIG_ENABLED = 0x8,
150 CU_LIMIT_CIG_SHMEM_FALLBACK_ENABLED = 0x9,
151 } CUlimit;
152
153 typedef struct
154 {
155 gsize srcXInBytes;
156 gsize srcY;
157 CUmemorytype srcMemoryType;
158 gconstpointer srcHost;
159 CUdeviceptr srcDevice;
160 CUarray srcArray;
161 gsize srcPitch;
162
163 gsize dstXInBytes;
164 gsize dstY;
165 CUmemorytype dstMemoryType;
166 gpointer dstHost;
167 CUdeviceptr dstDevice;
168 CUarray dstArray;
169 gsize dstPitch;
170
171 gsize WidthInBytes;
172 gsize Height;
173 } CUDA_MEMCPY2D;
174
175 typedef struct
176 {
177 CUaddress_mode addressMode[3];
178 CUfilter_mode filterMode;
179 guint flags;
180 guint maxAnisotropy;
181 CUfilter_mode mipmapFilterMode;
182 gfloat mipmapLevelBias;
183 gfloat minMipmapLevelClamp;
184 gfloat maxMipmapLevelClamp;
185 gfloat borderColor[4];
186 gint reserved[12];
187 } CUDA_TEXTURE_DESC;
188
189 typedef struct
190 {
191 CUresourcetype resType;
192
193 union {
194 struct {
195 CUarray hArray;
196 } array;
197 struct {
198 CUmipmappedArray hMipmappedArray;
199 } mipmap;
200 struct {
201 CUdeviceptr devPtr;
202 CUarray_format format;
203 guint numChannels;
204 gsize sizeInBytes;
205 } linear;
206 struct {
207 CUdeviceptr devPtr;
208 CUarray_format format;
209 guint numChannels;
210 gsize width;
211 gsize height;
212 gsize pitchInBytes;
213 } pitch2D;
214 struct {
215 gint reserved[32];
216 } reserved;
217 } res;
218
219 guint flags;
220 } CUDA_RESOURCE_DESC;
221
222 typedef struct
223 {
224 CUresourceViewFormat format;
225 gsize width;
226 gsize height;
227 gsize depth;
228 guint firstMipmapLevel;
229 guint lastMipmapLevel;
230 guint firstLayer;
231 guint lastLayer;
232 guint reserved[16];
233 } CUDA_RESOURCE_VIEW_DESC;
234
235 typedef enum
236 {
237 CU_IPC_MEM_LAZY_ENABLE_PEER_ACCESS = 0x1
238 } CUipcMem_flags;
239
240 #define CU_IPC_HANDLE_SIZE 64
241 typedef struct
242 {
243 char reserved[CU_IPC_HANDLE_SIZE];
244 } CUipcMemHandle;
245
246 typedef struct
247 {
248 char reserved[CU_IPC_HANDLE_SIZE];
249 } CUipcEventHandle;
250
251 typedef unsigned long long CUmemGenericAllocationHandle;
252
253 typedef enum
254 {
255 CU_MEM_HANDLE_TYPE_NONE = 0x0,
256 CU_MEM_HANDLE_TYPE_POSIX_FILE_DESCRIPTOR = 0x1,
257 CU_MEM_HANDLE_TYPE_WIN32 = 0x2,
258 CU_MEM_HANDLE_TYPE_WIN32_KMT = 0x4,
259 CU_MEM_HANDLE_TYPE_MAX = 0x7FFFFFFF
260 } CUmemAllocationHandleType;
261
262 typedef enum
263 {
264 CU_MEM_ACCESS_FLAGS_PROT_NONE = 0x0,
265 CU_MEM_ACCESS_FLAGS_PROT_READ = 0x1,
266 CU_MEM_ACCESS_FLAGS_PROT_READWRITE = 0x3,
267 CU_MEM_ACCESS_FLAGS_PROT_MAX = 0x7FFFFFFF
268 } CUmemAccess_flags;
269
270 typedef enum
271 {
272 CU_MEM_LOCATION_TYPE_INVALID = 0x0,
273 CU_MEM_LOCATION_TYPE_DEVICE = 0x1,
274 CU_MEM_LOCATION_TYPE_MAX = 0x7FFFFFFF
275 } CUmemLocationType;
276
277 typedef enum CUmemAllocationType_enum {
278 CU_MEM_ALLOCATION_TYPE_INVALID = 0x0,
279 CU_MEM_ALLOCATION_TYPE_PINNED = 0x1,
280 CU_MEM_ALLOCATION_TYPE_MAX = 0x7FFFFFFF
281 } CUmemAllocationType;
282
283 typedef enum
284 {
285 CU_MEM_ALLOC_GRANULARITY_MINIMUM = 0x0,
286 CU_MEM_ALLOC_GRANULARITY_RECOMMENDED = 0x1
287 } CUmemAllocationGranularity_flags;
288
289 typedef struct
290 {
291 CUmemLocationType type;
292 int id;
293 } CUmemLocation;
294
295 typedef struct
296 {
297 unsigned char compressionType;
298 unsigned char gpuDirectRDMACapable;
299 unsigned short usage;
300 unsigned char reserved[4];
301 } CUmemAllocationPropAllocFlags;
302
303 typedef struct
304 {
305 CUmemAllocationType type;
306 CUmemAllocationHandleType requestedHandleTypes;
307 CUmemLocation location;
308 void *win32HandleMetaData;
309 CUmemAllocationPropAllocFlags allocFlags;
310 } CUmemAllocationProp;
311
312 typedef struct
313 {
314 CUmemLocation location;
315 CUmemAccess_flags flags;
316 } CUmemAccessDesc;
317
318 typedef struct
319 {
320 CUmemAllocationType allocType;
321 CUmemAllocationHandleType handleTypes;
322 CUmemLocation location;
323 void *win32SecurityAttributes;
324 size_t maxSize;
325 unsigned char reserved[56];
326 } CUmemPoolProps;
327
328 typedef enum
329 {
330 CU_MEMPOOL_ATTR_REUSE_FOLLOW_EVENT_DEPENDENCIES = 1,
331 CU_MEMPOOL_ATTR_REUSE_ALLOW_OPPORTUNISTIC,
332 CU_MEMPOOL_ATTR_REUSE_ALLOW_INTERNAL_DEPENDENCIES,
333 CU_MEMPOOL_ATTR_RELEASE_THRESHOLD,
334 CU_MEMPOOL_ATTR_RESERVED_MEM_CURRENT,
335 CU_MEMPOOL_ATTR_RESERVED_MEM_HIGH,
336 CU_MEMPOOL_ATTR_USED_MEM_CURRENT,
337 CU_MEMPOOL_ATTR_USED_MEM_HIGH,
338 } CUmemPool_attribute;
339
340 typedef struct
341 {
342 unsigned long long offset;
343 unsigned long long size;
344 unsigned int flags;
345 unsigned int reserved[16];
346 } CUDA_EXTERNAL_MEMORY_BUFFER_DESC;
347
348 typedef enum
349 {
350 CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD = 1,
351 CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32 = 2,
352 CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT = 3,
353 CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_HEAP = 4,
354 CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE = 5,
355 CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_RESOURCE = 6,
356 CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_RESOURCE_KMT = 7,
357 CU_EXTERNAL_MEMORY_HANDLE_TYPE_NVSCIBUF = 8
358 } CUexternalMemoryHandleType;
359
360 /**
361 * CUDA_EXTERNAL_MEMORY_HANDLE_DESC: (skip) (attributes doc.skip=true)
362 */
363 typedef struct
364 {
365 CUexternalMemoryHandleType type;
366 union {
367 int fd;
368 struct {
369 void *handle;
370 const void *name;
371 } win32;
372 const void *nvSciBufObject;
373 } handle;
374 unsigned long long size;
375 unsigned int flags;
376 unsigned int reserved[16];
377 } CUDA_EXTERNAL_MEMORY_HANDLE_DESC;
378
379 typedef enum
380 {
381 CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD = 1,
382 CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32 = 2,
383 CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT = 3,
384 CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE = 4,
385 CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_FENCE = 5,
386 CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_NVSCISYNC = 6,
387 CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_KEYED_MUTEX = 7,
388 CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_KEYED_MUTEX_KMT = 8,
389 CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TIMELINE_SEMAPHORE_FD = 9,
390 CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TIMELINE_SEMAPHORE_WIN32 = 10
391 } CUexternalSemaphoreHandleType;
392
393 /**
394 * CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC: (skip) (attributes doc.skip=true)
395 */
396 typedef struct
397 {
398 CUexternalSemaphoreHandleType type;
399 union {
400 int fd;
401 struct {
402 void *handle;
403 const void *name;
404 } win32;
405 const void* nvSciSyncObj;
406 } handle;
407 unsigned int flags;
408 unsigned int reserved[16];
409 } CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC;
410
411 /**
412 * CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS: (skip) (attributes doc.skip=true)
413 */
414 typedef struct
415 {
416 struct {
417 struct {
418 unsigned long long value;
419 } fence;
420 union {
421 void *fence;
422 unsigned long long reserved;
423 } nvSciSync;
424 struct {
425 unsigned long long key;
426 } keyedMutex;
427 unsigned int reserved[12];
428 } params;
429 unsigned int flags;
430 unsigned int reserved[16];
431 } CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS;
432
433 /**
434 * CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS: (skip) (attributes doc.skip=true)
435 */
436 typedef struct
437 {
438 struct {
439 struct {
440 unsigned long long value;
441 } fence;
442 union {
443 void *fence;
444 unsigned long long reserved;
445 } nvSciSync;
446 struct {
447 unsigned long long key;
448 unsigned int timeoutMs;
449 } keyedMutex;
450 unsigned int reserved[10];
451 } params;
452 unsigned int flags;
453 unsigned int reserved[16];
454 } CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS;
455
456 typedef struct
457 {
458 size_t Width;
459 size_t Height;
460 size_t Depth;
461 CUarray_format Format;
462 unsigned int NumChannels;
463 unsigned int Flags;
464 } CUDA_ARRAY3D_DESCRIPTOR;
465
466 typedef struct
467 {
468 unsigned long long offset;
469 CUDA_ARRAY3D_DESCRIPTOR arrayDesc;
470 unsigned int numLevels;
471 unsigned int reserved[16];
472 } CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC;
473
474 #define CUDA_VERSION 10000
475
476 #ifdef _WIN32
477 #define CUDAAPI __stdcall
478 #else
479 #define CUDAAPI
480 #endif
481
482 #define cuCtxCreate cuCtxCreate_v2
483 #define cuCtxDestroy cuCtxDestroy_v2
484 #define cuCtxPopCurrent cuCtxPopCurrent_v2
485 #define cuCtxPushCurrent cuCtxPushCurrent_v2
486 #define cuGraphicsResourceGetMappedPointer cuGraphicsResourceGetMappedPointer_v2
487 #define cuGraphicsResourceSetMapFlags cuGraphicsResourceSetMapFlags_v2
488
489 #define cuStreamDestroy cuStreamDestroy_v2
490
491 #define cuMemAlloc cuMemAlloc_v2
492 #define cuMemAllocPitch cuMemAllocPitch_v2
493 #define cuMemAllocHost cuMemAllocHost_v2
494 #define cuMemcpy2D cuMemcpy2D_v2
495 #define cuMemcpy2DAsync cuMemcpy2DAsync_v2
496 #define cuMemcpyDtoD cuMemcpyDtoD_v2
497 #define cuMemcpyDtoDAsync cuMemcpyDtoDAsync_v2
498 #define cuMemcpyDtoH cuMemcpyDtoH_v2
499 #define cuMemcpyDtoHAsync cuMemcpyDtoHAsync_v2
500 #define cuMemcpyHtoD cuMemcpyHtoD_v2
501 #define cuMemcpyHtoDAsync cuMemcpyHtoDAsync_v2
502 #define cuMemFree cuMemFree_v2
503 #define cuMemsetD2D8 cuMemsetD2D8_v2
504 #define cuMemsetD2D16 cuMemsetD2D16_v2
505 #define cuMemsetD2D32 cuMemsetD2D32_v2
506
507 #define cuEventDestroy cuEventDestroy_v2
508
509 #define CU_TRSF_READ_AS_INTEGER 1
510
511 G_END_DECLS
512
513 #endif /* __GST_CUDA_STUB_H__ */