Skip to content
Permalink
Browse files

Add CUDA OpenGL Interop symbols and types

This will allow mpv to use this loader, instead of having to maintain
its own code.

I've bumped the 'nano' version to provide a unique version associated
with adding these additional symbols.
  • Loading branch information
philipl committed Apr 15, 2018
1 parent 441bdc5 commit 03fc16d29fbab95c8de2f752d9c76db53199a818
Showing with 36 additions and 2 deletions.
  1. +1 −1 ffnvcodec.pc.in
  2. +21 −1 include/ffnvcodec/dynlink_cuda.h
  3. +14 −0 include/ffnvcodec/dynlink_loader.h
@@ -3,5 +3,5 @@ includedir=${prefix}/include

Name: ffnvcodec
Description: FFmpeg version of Nvidia Codec SDK headers
Version: 8.1.24.0
Version: 8.1.24.1
Cflags: -I${includedir}
@@ -56,7 +56,8 @@ typedef enum cudaError_enum {

typedef enum CUmemorytype_enum {
CU_MEMORYTYPE_HOST = 1,
CU_MEMORYTYPE_DEVICE = 2
CU_MEMORYTYPE_DEVICE = 2,
CU_MEMORYTYPE_ARRAY = 3
} CUmemorytype;

typedef enum CUlimit_enum {
@@ -88,6 +89,18 @@ typedef struct CUDA_MEMCPY2D_st {
size_t Height;
} CUDA_MEMCPY2D;

typedef unsigned int GLenum;
typedef unsigned int GLuint;
typedef struct CUgraphicsResource_st *CUgraphicsResource;

typedef enum CUGLDeviceList_enum {
CU_GL_DEVICE_LIST_ALL = 1,
CU_GL_DEVICE_LIST_CURRENT_FRAME = 2,
CU_GL_DEVICE_LIST_NEXT_FRAME = 3,
} CUGLDeviceList;

#define CU_GRAPHICS_REGISTER_FLAGS_WRITE_DISCARD 2

typedef CUresult CUDAAPI tcuInit(unsigned int Flags);
typedef CUresult CUDAAPI tcuDeviceGetCount(int *count);
typedef CUresult CUDAAPI tcuDeviceGet(CUdevice *device, int ordinal);
@@ -104,4 +117,11 @@ typedef CUresult CUDAAPI tcuMemcpy2D_v2(const CUDA_MEMCPY2D *pcopy);
typedef CUresult CUDAAPI tcuGetErrorName(CUresult error, const char** pstr);
typedef CUresult CUDAAPI tcuGetErrorString(CUresult error, const char** pstr);

typedef CUresult CUDAAPI tcuGLGetDevices_v2(unsigned int* pCudaDeviceCount, CUdevice* pCudaDevices, unsigned int cudaDeviceCount, CUGLDeviceList deviceList);
typedef CUresult CUDAAPI tcuGraphicsGLRegisterImage(CUgraphicsResource* pCudaResource, GLuint image, GLenum target, unsigned int Flags);
typedef CUresult CUDAAPI tcuGraphicsUnregisterResource(CUgraphicsResource resource);
typedef CUresult CUDAAPI tcuGraphicsMapResources(unsigned int count, CUgraphicsResource* resources, CUstream hStream);
typedef CUresult CUDAAPI tcuGraphicsUnmapResources(unsigned int count, CUgraphicsResource* resources, CUstream hStream);
typedef CUresult CUDAAPI tcuGraphicsSubResourceGetMappedArray(CUarray* pArray, CUgraphicsResource resource, unsigned int arrayIndex, unsigned int mipLevel);

#endif
@@ -152,6 +152,13 @@ typedef struct CudaFunctions {
tcuGetErrorName *cuGetErrorName;
tcuGetErrorString *cuGetErrorString;

tcuGLGetDevices_v2 *cuGLGetDevices;
tcuGraphicsGLRegisterImage *cuGraphicsGLRegisterImage;
tcuGraphicsUnregisterResource *cuGraphicsUnregisterResource;
tcuGraphicsMapResources *cuGraphicsMapResources;
tcuGraphicsUnmapResources *cuGraphicsUnmapResources;
tcuGraphicsSubResourceGetMappedArray *cuGraphicsSubResourceGetMappedArray;

FFNV_LIB_HANDLE lib;
} CudaFunctions;
#else
@@ -232,6 +239,13 @@ static inline int cuda_load_functions(CudaFunctions **functions, void *logctx)
LOAD_SYMBOL(cuGetErrorName, tcuGetErrorName, "cuGetErrorName");
LOAD_SYMBOL(cuGetErrorString, tcuGetErrorString, "cuGetErrorString");

LOAD_SYMBOL(cuGLGetDevices, tcuGLGetDevices_v2, "cuGLGetDevices_v2");
LOAD_SYMBOL(cuGraphicsGLRegisterImage, tcuGraphicsGLRegisterImage, "cuGraphicsGLRegisterImage");
LOAD_SYMBOL(cuGraphicsUnregisterResource, tcuGraphicsUnregisterResource, "cuGraphicsUnregisterResource");
LOAD_SYMBOL(cuGraphicsMapResources, tcuGraphicsMapResources, "cuGraphicsMapResources");
LOAD_SYMBOL(cuGraphicsUnmapResources, tcuGraphicsUnmapResources, "cuGraphicsUnmapResources");
LOAD_SYMBOL(cuGraphicsSubResourceGetMappedArray, tcuGraphicsSubResourceGetMappedArray, "cuGraphicsSubResourceGetMappedArray");

GENERIC_LOAD_FUNC_FINALE(cuda);
}
#endif

0 comments on commit 03fc16d

Please sign in to comment.