]> git.sesse.net Git - ffmpeg/blob - compat/cuda/dynlink_cuda.h
Merge commit 'cbe28bc069dde1d53d937ee10700bb123279c7c8'
[ffmpeg] / compat / cuda / dynlink_cuda.h
1 /*
2  * This copyright notice applies to this header file only:
3  *
4  * Copyright (c) 2016
5  *
6  * Permission is hereby granted, free of charge, to any person
7  * obtaining a copy of this software and associated documentation
8  * files (the "Software"), to deal in the Software without
9  * restriction, including without limitation the rights to use,
10  * copy, modify, merge, publish, distribute, sublicense, and/or sell
11  * copies of the software, and to permit persons to whom the
12  * software is furnished to do so, subject to the following
13  * conditions:
14  *
15  * The above copyright notice and this permission notice shall be
16  * included in all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  */
27
28 #if !defined(AV_COMPAT_DYNLINK_CUDA_H) && !defined(CUDA_VERSION)
29 #define AV_COMPAT_DYNLINK_CUDA_H
30
31 #include <stddef.h>
32
33 #define CUDA_VERSION 7050
34
35 #if defined(_WIN32) || defined(__CYGWIN__)
36 #define CUDAAPI __stdcall
37 #else
38 #define CUDAAPI
39 #endif
40
41 #define CU_CTX_SCHED_BLOCKING_SYNC 4
42
43 typedef int CUdevice;
44 typedef void* CUarray;
45 typedef void* CUcontext;
46 typedef void* CUstream;
47 #if defined(__x86_64) || defined(AMD64) || defined(_M_AMD64)
48 typedef unsigned long long CUdeviceptr;
49 #else
50 typedef unsigned int CUdeviceptr;
51 #endif
52
53 typedef enum cudaError_enum {
54     CUDA_SUCCESS = 0
55 } CUresult;
56
57 typedef enum CUmemorytype_enum {
58     CU_MEMORYTYPE_HOST = 1,
59     CU_MEMORYTYPE_DEVICE = 2
60 } CUmemorytype;
61
62 typedef struct CUDA_MEMCPY2D_st {
63     size_t srcXInBytes;
64     size_t srcY;
65     CUmemorytype srcMemoryType;
66     const void *srcHost;
67     CUdeviceptr srcDevice;
68     CUarray srcArray;
69     size_t srcPitch;
70
71     size_t dstXInBytes;
72     size_t dstY;
73     CUmemorytype dstMemoryType;
74     void *dstHost;
75     CUdeviceptr dstDevice;
76     CUarray dstArray;
77     size_t dstPitch;
78
79     size_t WidthInBytes;
80     size_t Height;
81 } CUDA_MEMCPY2D;
82
83 typedef CUresult CUDAAPI tcuInit(unsigned int Flags);
84 typedef CUresult CUDAAPI tcuDeviceGetCount(int *count);
85 typedef CUresult CUDAAPI tcuDeviceGet(CUdevice *device, int ordinal);
86 typedef CUresult CUDAAPI tcuDeviceGetName(char *name, int len, CUdevice dev);
87 typedef CUresult CUDAAPI tcuDeviceComputeCapability(int *major, int *minor, CUdevice dev);
88 typedef CUresult CUDAAPI tcuCtxCreate_v2(CUcontext *pctx, unsigned int flags, CUdevice dev);
89 typedef CUresult CUDAAPI tcuCtxPushCurrent_v2(CUcontext *pctx);
90 typedef CUresult CUDAAPI tcuCtxPopCurrent_v2(CUcontext *pctx);
91 typedef CUresult CUDAAPI tcuCtxDestroy_v2(CUcontext ctx);
92 typedef CUresult CUDAAPI tcuMemAlloc_v2(CUdeviceptr *dptr, size_t bytesize);
93 typedef CUresult CUDAAPI tcuMemFree_v2(CUdeviceptr dptr);
94 typedef CUresult CUDAAPI tcuMemcpy2D_v2(const CUDA_MEMCPY2D *pcopy);
95 typedef CUresult CUDAAPI tcuGetErrorName(CUresult error, const char** pstr);
96 typedef CUresult CUDAAPI tcuGetErrorString(CUresult error, const char** pstr);
97
98 #endif