• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 } CUgraphicsRegisterFlags;
64 
65 typedef enum
66 {
67   CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE = 0x00,
68   CU_GRAPHICS_MAP_RESOURCE_FLAGS_READ_ONLY = 0x01,
69   CU_GRAPHICS_MAP_RESOURCE_FLAGS_WRITE_DISCARD = 0x02,
70 } CUgraphicsMapResourceFlags;
71 
72 typedef enum
73 {
74   CU_STREAM_DEFAULT = 0x0,
75   CU_STREAM_NON_BLOCKING = 0x1
76 } CUstream_flags;
77 
78 typedef enum
79 {
80   CU_TR_FILTER_MODE_POINT = 0,
81   CU_TR_FILTER_MODE_LINEAR = 1
82 } CUfilter_mode;
83 
84 typedef enum
85 {
86   CU_TR_ADDRESS_MODE_WRAP = 0,
87   CU_TR_ADDRESS_MODE_CLAMP = 1,
88   CU_TR_ADDRESS_MODE_MIRROR = 2,
89   CU_TR_ADDRESS_MODE_BORDER = 3
90 } CUaddress_mode;
91 
92 typedef enum
93 {
94   CU_RESOURCE_TYPE_ARRAY = 0,
95   CU_RESOURCE_TYPE_MIPMAPPED_ARRAY = 1,
96   CU_RESOURCE_TYPE_LINEAR = 2,
97   CU_RESOURCE_TYPE_PITCH2D = 3
98 } CUresourcetype;
99 
100 typedef enum
101 {
102   CU_AD_FORMAT_UNSIGNED_INT8  = 1,
103   CU_AD_FORMAT_UNSIGNED_INT16 = 2,
104 } CUarray_format;
105 
106 typedef enum
107 {
108   CU_RES_VIEW_FORMAT_NONE = 0,
109 } CUresourceViewFormat;
110 
111 typedef struct
112 {
113   gsize srcXInBytes;
114   gsize srcY;
115   CUmemorytype srcMemoryType;
116   gconstpointer srcHost;
117   CUdeviceptr srcDevice;
118   CUarray srcArray;
119   gsize srcPitch;
120 
121   gsize dstXInBytes;
122   gsize dstY;
123   CUmemorytype dstMemoryType;
124   gpointer dstHost;
125   CUdeviceptr dstDevice;
126   CUarray dstArray;
127   gsize dstPitch;
128 
129   gsize WidthInBytes;
130   gsize Height;
131 } CUDA_MEMCPY2D;
132 
133 typedef enum
134 {
135   CU_GL_DEVICE_LIST_ALL = 0x01,
136 } CUGLDeviceList;
137 
138 typedef struct
139 {
140   CUaddress_mode addressMode[3];
141   CUfilter_mode filterMode;
142   guint flags;
143   guint maxAnisotropy;
144   CUfilter_mode mipmapFilterMode;
145   gfloat mipmapLevelBias;
146   gfloat minMipmapLevelClamp;
147   gfloat maxMipmapLevelClamp;
148   gfloat borderColor[4];
149   gint reserved[12];
150 } CUDA_TEXTURE_DESC;
151 
152 typedef struct
153 {
154   CUresourcetype resType;
155 
156   union {
157     struct {
158       CUarray hArray;
159     } array;
160     struct {
161       CUmipmappedArray hMipmappedArray;
162     } mipmap;
163     struct {
164       CUdeviceptr devPtr;
165       CUarray_format format;
166       guint numChannels;
167       gsize sizeInBytes;
168     } linear;
169     struct {
170       CUdeviceptr devPtr;
171       CUarray_format format;
172       guint numChannels;
173       gsize width;
174       gsize height;
175       gsize pitchInBytes;
176     } pitch2D;
177     struct {
178         gint reserved[32];
179     } reserved;
180   } res;
181 
182   guint flags;
183 } CUDA_RESOURCE_DESC;
184 
185 typedef struct
186 {
187   CUresourceViewFormat format;
188   gsize width;
189   gsize height;
190   gsize depth;
191   guint firstMipmapLevel;
192   guint lastMipmapLevel;
193   guint firstLayer;
194   guint lastLayer;
195   guint reserved[16];
196 } CUDA_RESOURCE_VIEW_DESC;
197 
198 #define CUDA_VERSION 10000
199 
200 #ifdef _WIN32
201 #define CUDAAPI __stdcall
202 #else
203 #define CUDAAPI
204 #endif
205 
206 #define cuCtxCreate cuCtxCreate_v2
207 #define cuCtxDestroy cuCtxDestroy_v2
208 #define cuCtxPopCurrent cuCtxPopCurrent_v2
209 #define cuCtxPushCurrent cuCtxPushCurrent_v2
210 #define cuGraphicsResourceGetMappedPointer cuGraphicsResourceGetMappedPointer_v2
211 #define cuGraphicsResourceSetMapFlags cuGraphicsResourceSetMapFlags_v2
212 
213 #define cuMemAlloc cuMemAlloc_v2
214 #define cuMemAllocPitch cuMemAllocPitch_v2
215 #define cuMemAllocHost  cuMemAllocHost_v2
216 #define cuMemcpy2D cuMemcpy2D_v2
217 #define cuMemcpy2DAsync cuMemcpy2DAsync_v2
218 #define cuMemFree cuMemFree_v2
219 #define cuGLGetDevices cuGLGetDevices_v2
220 
221 #define CU_TRSF_READ_AS_INTEGER 1
222 
223 G_END_DECLS
224 
225 #endif /* __GST_CUDA_STUB_H__ */
226