nvenc: Give more details about errors
[platform/upstream/gstreamer.git] / subprojects / gst-plugins-bad / sys / nvcodec / stub / cuda.h
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
34 typedef guint64  CUtexObject;
35 typedef guintptr CUdeviceptr;
36 typedef gint CUdevice;
37
38 typedef enum
39 {
40   CUDA_SUCCESS = 0,
41 } CUresult;
42
43 typedef enum
44 {
45   CU_MEMORYTYPE_HOST = 1,
46   CU_MEMORYTYPE_DEVICE = 2,
47   CU_MEMORYTYPE_ARRAY = 3,
48   CU_MEMORYTYPE_UNIFIED = 4,
49 } CUmemorytype;
50
51 typedef enum
52 {
53   CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT = 14,
54   CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR = 75,
55   CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR = 76,
56 } CUdevice_attribute;
57
58 typedef enum
59 {
60   CU_GRAPHICS_REGISTER_FLAGS_NONE = 0x00,
61   CU_GRAPHICS_REGISTER_FLAGS_READ_ONLY = 0x01,
62   CU_GRAPHICS_REGISTER_FLAGS_WRITE_DISCARD = 0x02,
63   CU_GRAPHICS_REGISTER_FLAGS_SURFACE_LOAD_STORE = 0x04,
64   CU_GRAPHICS_REGISTER_FLAGS_TEXTURE_GATHER = 0x08,
65 } CUgraphicsRegisterFlags;
66
67 typedef enum
68 {
69   CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE = 0x00,
70   CU_GRAPHICS_MAP_RESOURCE_FLAGS_READ_ONLY = 0x01,
71   CU_GRAPHICS_MAP_RESOURCE_FLAGS_WRITE_DISCARD = 0x02,
72 } CUgraphicsMapResourceFlags;
73
74 typedef enum
75 {
76   CU_STREAM_DEFAULT = 0x0,
77   CU_STREAM_NON_BLOCKING = 0x1
78 } CUstream_flags;
79
80 typedef enum
81 {
82   CU_TR_FILTER_MODE_POINT = 0,
83   CU_TR_FILTER_MODE_LINEAR = 1
84 } CUfilter_mode;
85
86 typedef enum
87 {
88   CU_TR_ADDRESS_MODE_WRAP = 0,
89   CU_TR_ADDRESS_MODE_CLAMP = 1,
90   CU_TR_ADDRESS_MODE_MIRROR = 2,
91   CU_TR_ADDRESS_MODE_BORDER = 3
92 } CUaddress_mode;
93
94 typedef enum
95 {
96   CU_RESOURCE_TYPE_ARRAY = 0,
97   CU_RESOURCE_TYPE_MIPMAPPED_ARRAY = 1,
98   CU_RESOURCE_TYPE_LINEAR = 2,
99   CU_RESOURCE_TYPE_PITCH2D = 3
100 } CUresourcetype;
101
102 typedef enum
103 {
104   CU_AD_FORMAT_UNSIGNED_INT8  = 1,
105   CU_AD_FORMAT_UNSIGNED_INT16 = 2,
106 } CUarray_format;
107
108 typedef enum
109 {
110   CU_RES_VIEW_FORMAT_NONE = 0,
111 } CUresourceViewFormat;
112
113 typedef struct
114 {
115   gsize srcXInBytes;
116   gsize srcY;
117   CUmemorytype srcMemoryType;
118   gconstpointer srcHost;
119   CUdeviceptr srcDevice;
120   CUarray srcArray;
121   gsize srcPitch;
122
123   gsize dstXInBytes;
124   gsize dstY;
125   CUmemorytype dstMemoryType;
126   gpointer dstHost;
127   CUdeviceptr dstDevice;
128   CUarray dstArray;
129   gsize dstPitch;
130
131   gsize WidthInBytes;
132   gsize Height;
133 } CUDA_MEMCPY2D;
134
135 typedef enum
136 {
137   CU_GL_DEVICE_LIST_ALL = 0x01,
138 } CUGLDeviceList;
139
140 typedef enum
141 {
142   CU_D3D11_DEVICE_LIST_ALL = 0x01,
143   CU_D3D11_DEVICE_LIST_CURRENT_FRAME = 0x02,
144   CU_D3D11_DEVICE_LIST_NEXT_FRAME = 0x03,
145 } CUD3D11DeviceList;
146
147 typedef struct
148 {
149   CUaddress_mode addressMode[3];
150   CUfilter_mode filterMode;
151   guint flags;
152   guint maxAnisotropy;
153   CUfilter_mode mipmapFilterMode;
154   gfloat mipmapLevelBias;
155   gfloat minMipmapLevelClamp;
156   gfloat maxMipmapLevelClamp;
157   gfloat borderColor[4];
158   gint reserved[12];
159 } CUDA_TEXTURE_DESC;
160
161 typedef struct
162 {
163   CUresourcetype resType;
164
165   union {
166     struct {
167       CUarray hArray;
168     } array;
169     struct {
170       CUmipmappedArray hMipmappedArray;
171     } mipmap;
172     struct {
173       CUdeviceptr devPtr;
174       CUarray_format format;
175       guint numChannels;
176       gsize sizeInBytes;
177     } linear;
178     struct {
179       CUdeviceptr devPtr;
180       CUarray_format format;
181       guint numChannels;
182       gsize width;
183       gsize height;
184       gsize pitchInBytes;
185     } pitch2D;
186     struct {
187         gint reserved[32];
188     } reserved;
189   } res;
190
191   guint flags;
192 } CUDA_RESOURCE_DESC;
193
194 typedef struct
195 {
196   CUresourceViewFormat format;
197   gsize width;
198   gsize height;
199   gsize depth;
200   guint firstMipmapLevel;
201   guint lastMipmapLevel;
202   guint firstLayer;
203   guint lastLayer;
204   guint reserved[16];
205 } CUDA_RESOURCE_VIEW_DESC;
206
207 #define CUDA_VERSION 10000
208
209 #ifdef _WIN32
210 #define CUDAAPI __stdcall
211 #else
212 #define CUDAAPI
213 #endif
214
215 #define cuCtxCreate cuCtxCreate_v2
216 #define cuCtxDestroy cuCtxDestroy_v2
217 #define cuCtxPopCurrent cuCtxPopCurrent_v2
218 #define cuCtxPushCurrent cuCtxPushCurrent_v2
219 #define cuGraphicsResourceGetMappedPointer cuGraphicsResourceGetMappedPointer_v2
220 #define cuGraphicsResourceSetMapFlags cuGraphicsResourceSetMapFlags_v2
221
222 #define cuMemAlloc cuMemAlloc_v2
223 #define cuMemAllocPitch cuMemAllocPitch_v2
224 #define cuMemAllocHost  cuMemAllocHost_v2
225 #define cuMemcpy2D cuMemcpy2D_v2
226 #define cuMemcpy2DAsync cuMemcpy2DAsync_v2
227 #define cuMemFree cuMemFree_v2
228 #define cuGLGetDevices cuGLGetDevices_v2
229
230 #define CU_TRSF_READ_AS_INTEGER 1
231
232 G_END_DECLS
233
234 #endif /* __GST_CUDA_STUB_H__ */