• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GStreamer
2  * Copyright (C) 2019 Seungha Yang <seungha.yang@navercorp.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19 
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
23 
24 #include "gstcudaloader.h"
25 #include <gmodule.h>
26 
27 GST_DEBUG_CATEGORY_EXTERN (gst_nvcodec_debug);
28 #define GST_CAT_DEFAULT gst_nvcodec_debug
29 
30 #ifndef G_OS_WIN32
31 #define CUDA_LIBNAME "libcuda.so.1"
32 #else
33 #define CUDA_LIBNAME "nvcuda.dll"
34 #endif
35 
36 #define LOAD_SYMBOL(name,func) G_STMT_START { \
37   if (!g_module_symbol (module, G_STRINGIFY (name), (gpointer *) &vtable->func)) { \
38     GST_ERROR ("Failed to load '%s' from %s, %s", G_STRINGIFY (name), filename, g_module_error()); \
39     goto error; \
40   } \
41 } G_STMT_END;
42 
43 typedef struct _GstNvCodecCudaVTable
44 {
45   gboolean loaded;
46 
47     CUresult (CUDAAPI * CuInit) (unsigned int Flags);
48     CUresult (CUDAAPI * CuGetErrorName) (CUresult error, const char **pStr);
49     CUresult (CUDAAPI * CuGetErrorString) (CUresult error, const char **pStr);
50 
51     CUresult (CUDAAPI * CuCtxCreate) (CUcontext * pctx, unsigned int flags,
52       CUdevice dev);
53     CUresult (CUDAAPI * CuCtxDestroy) (CUcontext ctx);
54     CUresult (CUDAAPI * CuCtxPopCurrent) (CUcontext * pctx);
55     CUresult (CUDAAPI * CuCtxPushCurrent) (CUcontext ctx);
56 
57     CUresult (CUDAAPI * CuCtxEnablePeerAccess) (CUcontext peerContext,
58       unsigned int Flags);
59     CUresult (CUDAAPI * CuCtxDisablePeerAccess) (CUcontext peerContext);
60     CUresult (CUDAAPI * CuGraphicsMapResources) (unsigned int count,
61       CUgraphicsResource * resources, CUstream hStream);
62     CUresult (CUDAAPI * CuGraphicsUnmapResources) (unsigned int count,
63       CUgraphicsResource * resources, CUstream hStream);
64     CUresult (CUDAAPI * CuGraphicsSubResourceGetMappedArray) (CUarray * pArray,
65       CUgraphicsResource resource, unsigned int arrayIndex,
66       unsigned int mipLevel);
67     CUresult (CUDAAPI * CuGraphicsResourceGetMappedPointer) (CUdeviceptr *
68       pDevPtr, size_t * pSize, CUgraphicsResource resource);
69     CUresult (CUDAAPI *
70       CuGraphicsUnregisterResource) (CUgraphicsResource resource);
71 
72     CUresult (CUDAAPI * CuMemAlloc) (CUdeviceptr * dptr, unsigned int bytesize);
73     CUresult (CUDAAPI * CuMemAllocPitch) (CUdeviceptr * dptr, size_t * pPitch,
74       size_t WidthInBytes, size_t Height, unsigned int ElementSizeBytes);
75     CUresult (CUDAAPI * CuMemAllocHost) (void **pp, unsigned int bytesize);
76     CUresult (CUDAAPI * CuMemcpy2D) (const CUDA_MEMCPY2D * pCopy);
77     CUresult (CUDAAPI * CuMemcpy2DAsync) (const CUDA_MEMCPY2D * pCopy,
78       CUstream hStream);
79 
80     CUresult (CUDAAPI * CuMemFree) (CUdeviceptr dptr);
81     CUresult (CUDAAPI * CuMemFreeHost) (void *p);
82 
83     CUresult (CUDAAPI * CuStreamCreate) (CUstream * phStream,
84       unsigned int Flags);
85     CUresult (CUDAAPI * CuStreamDestroy) (CUstream hStream);
86     CUresult (CUDAAPI * CuStreamSynchronize) (CUstream hStream);
87 
88     CUresult (CUDAAPI * CuDeviceGet) (CUdevice * device, int ordinal);
89     CUresult (CUDAAPI * CuDeviceGetCount) (int *count);
90     CUresult (CUDAAPI * CuDeviceGetName) (char *name, int len, CUdevice dev);
91     CUresult (CUDAAPI * CuDeviceGetAttribute) (int *pi,
92       CUdevice_attribute attrib, CUdevice dev);
93     CUresult (CUDAAPI * CuDeviceCanAccessPeer) (int *canAccessPeer,
94       CUdevice dev, CUdevice peerDev);
95     CUresult (CUDAAPI * CuDriverGetVersion) (int *driverVersion);
96 
97     CUresult (CUDAAPI * CuModuleLoadData) (CUmodule * module,
98       const void *image);
99     CUresult (CUDAAPI * CuModuleUnload) (CUmodule module);
100     CUresult (CUDAAPI * CuModuleGetFunction) (CUfunction * hfunc,
101       CUmodule hmod, const char *name);
102     CUresult (CUDAAPI * CuTexObjectCreate) (CUtexObject * pTexObject,
103       const CUDA_RESOURCE_DESC * pResDesc, const CUDA_TEXTURE_DESC * pTexDesc,
104       const CUDA_RESOURCE_VIEW_DESC * pResViewDesc);
105     CUresult (CUDAAPI * CuTexObjectDestroy) (CUtexObject texObject);
106     CUresult (CUDAAPI * CuLaunchKernel) (CUfunction f, unsigned int gridDimX,
107       unsigned int gridDimY, unsigned int gridDimZ,
108       unsigned int blockDimX, unsigned int blockDimY, unsigned int blockDimZ,
109       unsigned int sharedMemBytes, CUstream hStream, void **kernelParams,
110       void **extra);
111 
112     CUresult (CUDAAPI * CuGraphicsGLRegisterImage) (CUgraphicsResource *
113       pCudaResource, unsigned int image, unsigned int target,
114       unsigned int Flags);
115     CUresult (CUDAAPI * CuGraphicsGLRegisterBuffer) (CUgraphicsResource *
116       pCudaResource, unsigned int buffer, unsigned int Flags);
117     CUresult (CUDAAPI *
118       CuGraphicsResourceSetMapFlags) (CUgraphicsResource resource,
119       unsigned int flags);
120     CUresult (CUDAAPI * CuGLGetDevices) (unsigned int *pCudaDeviceCount,
121       CUdevice * pCudaDevices, unsigned int cudaDeviceCount,
122       CUGLDeviceList deviceList);
123 } GstNvCodecCudaVTable;
124 
125 static GstNvCodecCudaVTable gst_cuda_vtable = { 0, };
126 
127 gboolean
gst_cuda_load_library(void)128 gst_cuda_load_library (void)
129 {
130   GModule *module;
131   const gchar *filename = CUDA_LIBNAME;
132   GstNvCodecCudaVTable *vtable;
133 
134   if (gst_cuda_vtable.loaded)
135     return TRUE;
136 
137   module = g_module_open (filename, G_MODULE_BIND_LAZY);
138   if (module == NULL) {
139     GST_WARNING ("Could not open library %s, %s", filename, g_module_error ());
140     return FALSE;
141   }
142 
143   vtable = &gst_cuda_vtable;
144 
145   /* cuda.h */
146   LOAD_SYMBOL (cuInit, CuInit);
147   LOAD_SYMBOL (cuGetErrorName, CuGetErrorName);
148   LOAD_SYMBOL (cuGetErrorString, CuGetErrorString);
149   LOAD_SYMBOL (cuCtxCreate, CuCtxCreate);
150   LOAD_SYMBOL (cuCtxDestroy, CuCtxDestroy);
151   LOAD_SYMBOL (cuCtxPopCurrent, CuCtxPopCurrent);
152   LOAD_SYMBOL (cuCtxPushCurrent, CuCtxPushCurrent);
153   LOAD_SYMBOL (cuCtxEnablePeerAccess, CuCtxEnablePeerAccess);
154   LOAD_SYMBOL (cuCtxDisablePeerAccess, CuCtxDisablePeerAccess);
155 
156   LOAD_SYMBOL (cuGraphicsMapResources, CuGraphicsMapResources);
157   LOAD_SYMBOL (cuGraphicsUnmapResources, CuGraphicsUnmapResources);
158   LOAD_SYMBOL (cuGraphicsSubResourceGetMappedArray,
159       CuGraphicsSubResourceGetMappedArray);
160   LOAD_SYMBOL (cuGraphicsResourceGetMappedPointer,
161       CuGraphicsResourceGetMappedPointer);
162   LOAD_SYMBOL (cuGraphicsUnregisterResource, CuGraphicsUnregisterResource);
163 
164   LOAD_SYMBOL (cuMemAlloc, CuMemAlloc);
165   LOAD_SYMBOL (cuMemAllocPitch, CuMemAllocPitch);
166   LOAD_SYMBOL (cuMemAllocHost, CuMemAllocHost);
167   LOAD_SYMBOL (cuMemcpy2D, CuMemcpy2D);
168   LOAD_SYMBOL (cuMemcpy2DAsync, CuMemcpy2DAsync);
169 
170   LOAD_SYMBOL (cuMemFree, CuMemFree);
171   LOAD_SYMBOL (cuMemFreeHost, CuMemFreeHost);
172 
173   LOAD_SYMBOL (cuStreamCreate, CuStreamCreate);
174   LOAD_SYMBOL (cuStreamDestroy, CuStreamDestroy);
175   LOAD_SYMBOL (cuStreamSynchronize, CuStreamSynchronize);
176 
177   LOAD_SYMBOL (cuDeviceGet, CuDeviceGet);
178   LOAD_SYMBOL (cuDeviceGetCount, CuDeviceGetCount);
179   LOAD_SYMBOL (cuDeviceGetName, CuDeviceGetName);
180   LOAD_SYMBOL (cuDeviceGetAttribute, CuDeviceGetAttribute);
181   LOAD_SYMBOL (cuDeviceCanAccessPeer, CuDeviceCanAccessPeer);
182 
183   LOAD_SYMBOL (cuDriverGetVersion, CuDriverGetVersion);
184 
185   LOAD_SYMBOL (cuModuleLoadData, CuModuleLoadData);
186   LOAD_SYMBOL (cuModuleUnload, CuModuleUnload);
187   LOAD_SYMBOL (cuModuleGetFunction, CuModuleGetFunction);
188   LOAD_SYMBOL (cuTexObjectCreate, CuTexObjectCreate);
189   LOAD_SYMBOL (cuTexObjectDestroy, CuTexObjectDestroy);
190   LOAD_SYMBOL (cuLaunchKernel, CuLaunchKernel);
191 
192   /* cudaGL.h */
193   LOAD_SYMBOL (cuGraphicsGLRegisterImage, CuGraphicsGLRegisterImage);
194   LOAD_SYMBOL (cuGraphicsGLRegisterBuffer, CuGraphicsGLRegisterBuffer);
195   LOAD_SYMBOL (cuGraphicsResourceSetMapFlags, CuGraphicsResourceSetMapFlags);
196   LOAD_SYMBOL (cuGLGetDevices, CuGLGetDevices);
197 
198   vtable->loaded = TRUE;
199 
200   return TRUE;
201 
202 error:
203   g_module_close (module);
204 
205   return FALSE;
206 }
207 
208 CUresult CUDAAPI
CuInit(unsigned int Flags)209 CuInit (unsigned int Flags)
210 {
211   g_assert (gst_cuda_vtable.CuInit != NULL);
212 
213   return gst_cuda_vtable.CuInit (Flags);
214 }
215 
216 CUresult CUDAAPI
CuGetErrorName(CUresult error,const char ** pStr)217 CuGetErrorName (CUresult error, const char **pStr)
218 {
219   g_assert (gst_cuda_vtable.CuGetErrorName != NULL);
220 
221   return gst_cuda_vtable.CuGetErrorName (error, pStr);
222 }
223 
224 CUresult CUDAAPI
CuGetErrorString(CUresult error,const char ** pStr)225 CuGetErrorString (CUresult error, const char **pStr)
226 {
227   g_assert (gst_cuda_vtable.CuGetErrorString != NULL);
228 
229   return gst_cuda_vtable.CuGetErrorString (error, pStr);
230 }
231 
232 CUresult CUDAAPI
CuCtxCreate(CUcontext * pctx,unsigned int flags,CUdevice dev)233 CuCtxCreate (CUcontext * pctx, unsigned int flags, CUdevice dev)
234 {
235   g_assert (gst_cuda_vtable.CuCtxCreate != NULL);
236 
237   return gst_cuda_vtable.CuCtxCreate (pctx, flags, dev);
238 }
239 
240 CUresult CUDAAPI
CuCtxDestroy(CUcontext ctx)241 CuCtxDestroy (CUcontext ctx)
242 {
243   g_assert (gst_cuda_vtable.CuCtxDestroy != NULL);
244 
245   return gst_cuda_vtable.CuCtxDestroy (ctx);
246 }
247 
248 CUresult CUDAAPI
CuCtxPopCurrent(CUcontext * pctx)249 CuCtxPopCurrent (CUcontext * pctx)
250 {
251   g_assert (gst_cuda_vtable.CuCtxPopCurrent != NULL);
252 
253   return gst_cuda_vtable.CuCtxPopCurrent (pctx);
254 }
255 
256 CUresult CUDAAPI
CuCtxPushCurrent(CUcontext ctx)257 CuCtxPushCurrent (CUcontext ctx)
258 {
259   g_assert (gst_cuda_vtable.CuCtxPushCurrent != NULL);
260 
261   return gst_cuda_vtable.CuCtxPushCurrent (ctx);
262 }
263 
264 CUresult CUDAAPI
CuCtxEnablePeerAccess(CUcontext peerContext,unsigned int Flags)265 CuCtxEnablePeerAccess (CUcontext peerContext, unsigned int Flags)
266 {
267   g_assert (gst_cuda_vtable.CuCtxEnablePeerAccess != NULL);
268 
269   return gst_cuda_vtable.CuCtxEnablePeerAccess (peerContext, Flags);
270 }
271 
272 CUresult CUDAAPI
CuCtxDisablePeerAccess(CUcontext peerContext)273 CuCtxDisablePeerAccess (CUcontext peerContext)
274 {
275   g_assert (gst_cuda_vtable.CuCtxDisablePeerAccess != NULL);
276 
277   return gst_cuda_vtable.CuCtxDisablePeerAccess (peerContext);
278 }
279 
280 CUresult CUDAAPI
CuGraphicsMapResources(unsigned int count,CUgraphicsResource * resources,CUstream hStream)281 CuGraphicsMapResources (unsigned int count, CUgraphicsResource * resources,
282     CUstream hStream)
283 {
284   g_assert (gst_cuda_vtable.CuGraphicsMapResources != NULL);
285 
286   return gst_cuda_vtable.CuGraphicsMapResources (count, resources, hStream);
287 }
288 
289 CUresult CUDAAPI
CuGraphicsUnmapResources(unsigned int count,CUgraphicsResource * resources,CUstream hStream)290 CuGraphicsUnmapResources (unsigned int count, CUgraphicsResource * resources,
291     CUstream hStream)
292 {
293   g_assert (gst_cuda_vtable.CuGraphicsUnmapResources != NULL);
294 
295   return gst_cuda_vtable.CuGraphicsUnmapResources (count, resources, hStream);
296 }
297 
298 CUresult CUDAAPI
CuGraphicsSubResourceGetMappedArray(CUarray * pArray,CUgraphicsResource resource,unsigned int arrayIndex,unsigned int mipLevel)299 CuGraphicsSubResourceGetMappedArray (CUarray * pArray,
300     CUgraphicsResource resource, unsigned int arrayIndex, unsigned int mipLevel)
301 {
302   g_assert (gst_cuda_vtable.CuGraphicsSubResourceGetMappedArray != NULL);
303 
304   return gst_cuda_vtable.CuGraphicsSubResourceGetMappedArray (pArray, resource,
305       arrayIndex, mipLevel);
306 }
307 
308 CUresult CUDAAPI
CuGraphicsResourceGetMappedPointer(CUdeviceptr * pDevPtr,size_t * pSize,CUgraphicsResource resource)309 CuGraphicsResourceGetMappedPointer (CUdeviceptr * pDevPtr, size_t * pSize,
310     CUgraphicsResource resource)
311 {
312   g_assert (gst_cuda_vtable.CuGraphicsResourceGetMappedPointer != NULL);
313 
314   return gst_cuda_vtable.CuGraphicsResourceGetMappedPointer (pDevPtr, pSize,
315       resource);
316 }
317 
318 CUresult CUDAAPI
CuGraphicsUnregisterResource(CUgraphicsResource resource)319 CuGraphicsUnregisterResource (CUgraphicsResource resource)
320 {
321   g_assert (gst_cuda_vtable.CuGraphicsUnregisterResource != NULL);
322 
323   return gst_cuda_vtable.CuGraphicsUnregisterResource (resource);
324 }
325 
326 CUresult CUDAAPI
CuMemAlloc(CUdeviceptr * dptr,unsigned int bytesize)327 CuMemAlloc (CUdeviceptr * dptr, unsigned int bytesize)
328 {
329   g_assert (gst_cuda_vtable.CuMemAlloc != NULL);
330 
331   return gst_cuda_vtable.CuMemAlloc (dptr, bytesize);
332 }
333 
334 CUresult CUDAAPI
CuMemAllocPitch(CUdeviceptr * dptr,size_t * pPitch,size_t WidthInBytes,size_t Height,unsigned int ElementSizeBytes)335 CuMemAllocPitch (CUdeviceptr * dptr, size_t * pPitch, size_t WidthInBytes,
336     size_t Height, unsigned int ElementSizeBytes)
337 {
338   g_assert (gst_cuda_vtable.CuMemAllocPitch != NULL);
339 
340   return gst_cuda_vtable.CuMemAllocPitch (dptr, pPitch, WidthInBytes, Height,
341       ElementSizeBytes);
342 }
343 
344 CUresult CUDAAPI
CuMemAllocHost(void ** pp,unsigned int bytesize)345 CuMemAllocHost (void **pp, unsigned int bytesize)
346 {
347   g_assert (gst_cuda_vtable.CuMemAllocHost != NULL);
348 
349   return gst_cuda_vtable.CuMemAllocHost (pp, bytesize);
350 }
351 
352 CUresult CUDAAPI
CuMemcpy2D(const CUDA_MEMCPY2D * pCopy)353 CuMemcpy2D (const CUDA_MEMCPY2D * pCopy)
354 {
355   g_assert (gst_cuda_vtable.CuMemcpy2D != NULL);
356 
357   return gst_cuda_vtable.CuMemcpy2D (pCopy);
358 }
359 
360 CUresult CUDAAPI
CuMemcpy2DAsync(const CUDA_MEMCPY2D * pCopy,CUstream hStream)361 CuMemcpy2DAsync (const CUDA_MEMCPY2D * pCopy, CUstream hStream)
362 {
363   g_assert (gst_cuda_vtable.CuMemcpy2DAsync != NULL);
364 
365   return gst_cuda_vtable.CuMemcpy2DAsync (pCopy, hStream);
366 }
367 
368 CUresult CUDAAPI
CuMemFree(CUdeviceptr dptr)369 CuMemFree (CUdeviceptr dptr)
370 {
371   g_assert (gst_cuda_vtable.CuMemFree != NULL);
372 
373   return gst_cuda_vtable.CuMemFree (dptr);
374 }
375 
376 CUresult CUDAAPI
CuMemFreeHost(void * p)377 CuMemFreeHost (void *p)
378 {
379   g_assert (gst_cuda_vtable.CuMemFreeHost != NULL);
380 
381   return gst_cuda_vtable.CuMemFreeHost (p);
382 }
383 
384 CUresult CUDAAPI
CuStreamCreate(CUstream * phStream,unsigned int Flags)385 CuStreamCreate (CUstream * phStream, unsigned int Flags)
386 {
387   g_assert (gst_cuda_vtable.CuStreamCreate != NULL);
388 
389   return gst_cuda_vtable.CuStreamCreate (phStream, Flags);
390 }
391 
392 CUresult CUDAAPI
CuStreamDestroy(CUstream hStream)393 CuStreamDestroy (CUstream hStream)
394 {
395   g_assert (gst_cuda_vtable.CuStreamDestroy != NULL);
396 
397   return gst_cuda_vtable.CuStreamDestroy (hStream);
398 }
399 
400 CUresult CUDAAPI
CuStreamSynchronize(CUstream hStream)401 CuStreamSynchronize (CUstream hStream)
402 {
403   g_assert (gst_cuda_vtable.CuStreamSynchronize != NULL);
404 
405   return gst_cuda_vtable.CuStreamSynchronize (hStream);
406 }
407 
408 CUresult CUDAAPI
CuDeviceGet(CUdevice * device,int ordinal)409 CuDeviceGet (CUdevice * device, int ordinal)
410 {
411   g_assert (gst_cuda_vtable.CuDeviceGet != NULL);
412 
413   return gst_cuda_vtable.CuDeviceGet (device, ordinal);
414 }
415 
416 CUresult CUDAAPI
CuDeviceGetCount(int * count)417 CuDeviceGetCount (int *count)
418 {
419   g_assert (gst_cuda_vtable.CuDeviceGetCount != NULL);
420 
421   return gst_cuda_vtable.CuDeviceGetCount (count);
422 }
423 
424 CUresult CUDAAPI
CuDeviceGetName(char * name,int len,CUdevice dev)425 CuDeviceGetName (char *name, int len, CUdevice dev)
426 {
427   g_assert (gst_cuda_vtable.CuDeviceGetName != NULL);
428 
429   return gst_cuda_vtable.CuDeviceGetName (name, len, dev);
430 }
431 
432 CUresult CUDAAPI
CuDeviceGetAttribute(int * pi,CUdevice_attribute attrib,CUdevice dev)433 CuDeviceGetAttribute (int *pi, CUdevice_attribute attrib, CUdevice dev)
434 {
435   g_assert (gst_cuda_vtable.CuDeviceGetAttribute != NULL);
436 
437   return gst_cuda_vtable.CuDeviceGetAttribute (pi, attrib, dev);
438 }
439 
440 CUresult CUDAAPI
CuDeviceCanAccessPeer(int * canAccessPeer,CUdevice dev,CUdevice peerDev)441 CuDeviceCanAccessPeer (int *canAccessPeer, CUdevice dev, CUdevice peerDev)
442 {
443   g_assert (gst_cuda_vtable.CuDeviceCanAccessPeer != NULL);
444 
445   return gst_cuda_vtable.CuDeviceCanAccessPeer (canAccessPeer, dev, peerDev);
446 }
447 
448 CUresult CUDAAPI
CuDriverGetVersion(int * driverVersion)449 CuDriverGetVersion (int *driverVersion)
450 {
451   g_assert (gst_cuda_vtable.CuDriverGetVersion != NULL);
452 
453   return gst_cuda_vtable.CuDriverGetVersion (driverVersion);
454 }
455 
456 CUresult CUDAAPI
CuModuleLoadData(CUmodule * module,const void * image)457 CuModuleLoadData (CUmodule * module, const void *image)
458 {
459   g_assert (gst_cuda_vtable.CuModuleLoadData != NULL);
460 
461   return gst_cuda_vtable.CuModuleLoadData (module, image);
462 }
463 
464 CUresult CUDAAPI
CuModuleUnload(CUmodule module)465 CuModuleUnload (CUmodule module)
466 {
467   g_assert (gst_cuda_vtable.CuModuleUnload != NULL);
468 
469   return gst_cuda_vtable.CuModuleUnload (module);
470 }
471 
472 CUresult CUDAAPI
CuModuleGetFunction(CUfunction * hfunc,CUmodule hmod,const char * name)473 CuModuleGetFunction (CUfunction * hfunc, CUmodule hmod, const char *name)
474 {
475   g_assert (gst_cuda_vtable.CuModuleGetFunction != NULL);
476 
477   return gst_cuda_vtable.CuModuleGetFunction (hfunc, hmod, name);
478 }
479 
480 CUresult CUDAAPI
CuTexObjectCreate(CUtexObject * pTexObject,const CUDA_RESOURCE_DESC * pResDesc,const CUDA_TEXTURE_DESC * pTexDesc,const CUDA_RESOURCE_VIEW_DESC * pResViewDesc)481 CuTexObjectCreate (CUtexObject * pTexObject,
482     const CUDA_RESOURCE_DESC * pResDesc, const CUDA_TEXTURE_DESC * pTexDesc,
483     const CUDA_RESOURCE_VIEW_DESC * pResViewDesc)
484 {
485   g_assert (gst_cuda_vtable.CuTexObjectCreate != NULL);
486 
487   return gst_cuda_vtable.CuTexObjectCreate (pTexObject, pResDesc, pTexDesc,
488       pResViewDesc);
489 }
490 
491 CUresult CUDAAPI
CuTexObjectDestroy(CUtexObject texObject)492 CuTexObjectDestroy (CUtexObject texObject)
493 {
494   g_assert (gst_cuda_vtable.CuTexObjectDestroy != NULL);
495 
496   return gst_cuda_vtable.CuTexObjectDestroy (texObject);
497 }
498 
499 CUresult CUDAAPI
CuLaunchKernel(CUfunction f,unsigned int gridDimX,unsigned int gridDimY,unsigned int gridDimZ,unsigned int blockDimX,unsigned int blockDimY,unsigned int blockDimZ,unsigned int sharedMemBytes,CUstream hStream,void ** kernelParams,void ** extra)500 CuLaunchKernel (CUfunction f, unsigned int gridDimX,
501     unsigned int gridDimY, unsigned int gridDimZ,
502     unsigned int blockDimX, unsigned int blockDimY, unsigned int blockDimZ,
503     unsigned int sharedMemBytes, CUstream hStream, void **kernelParams,
504     void **extra)
505 {
506   g_assert (gst_cuda_vtable.CuLaunchKernel != NULL);
507 
508   return gst_cuda_vtable.CuLaunchKernel (f, gridDimX, gridDimY, gridDimZ,
509       blockDimX, blockDimY, blockDimZ, sharedMemBytes, hStream, kernelParams,
510       extra);
511 }
512 
513 /* cudaGL.h */
514 CUresult CUDAAPI
CuGraphicsGLRegisterImage(CUgraphicsResource * pCudaResource,unsigned int image,unsigned int target,unsigned int Flags)515 CuGraphicsGLRegisterImage (CUgraphicsResource * pCudaResource,
516     unsigned int image, unsigned int target, unsigned int Flags)
517 {
518   g_assert (gst_cuda_vtable.CuGraphicsGLRegisterImage != NULL);
519 
520   return gst_cuda_vtable.CuGraphicsGLRegisterImage (pCudaResource, image,
521       target, Flags);
522 }
523 
524 CUresult CUDAAPI
CuGraphicsGLRegisterBuffer(CUgraphicsResource * pCudaResource,unsigned int buffer,unsigned int Flags)525 CuGraphicsGLRegisterBuffer (CUgraphicsResource * pCudaResource,
526     unsigned int buffer, unsigned int Flags)
527 {
528   g_assert (gst_cuda_vtable.CuGraphicsGLRegisterBuffer != NULL);
529 
530   return gst_cuda_vtable.CuGraphicsGLRegisterBuffer (pCudaResource, buffer,
531       Flags);
532 }
533 
534 CUresult CUDAAPI
CuGraphicsResourceSetMapFlags(CUgraphicsResource resource,unsigned int flags)535 CuGraphicsResourceSetMapFlags (CUgraphicsResource resource, unsigned int flags)
536 {
537   g_assert (gst_cuda_vtable.CuGraphicsResourceSetMapFlags != NULL);
538 
539   return gst_cuda_vtable.CuGraphicsResourceSetMapFlags (resource, flags);
540 }
541 
542 CUresult CUDAAPI
CuGLGetDevices(unsigned int * pCudaDeviceCount,CUdevice * pCudaDevices,unsigned int cudaDeviceCount,CUGLDeviceList deviceList)543 CuGLGetDevices (unsigned int *pCudaDeviceCount, CUdevice * pCudaDevices,
544     unsigned int cudaDeviceCount, CUGLDeviceList deviceList)
545 {
546   g_assert (gst_cuda_vtable.CuGLGetDevices != NULL);
547 
548   return gst_cuda_vtable.CuGLGetDevices (pCudaDeviceCount, pCudaDevices,
549       cudaDeviceCount, deviceList);
550 }
551