Skip to content

Commit 94c72c5

Browse files
committed
Add some CUDA kernel interaction APIs
1 parent 1f058a1 commit 94c72c5

File tree

3 files changed

+91
-1
lines changed

3 files changed

+91
-1
lines changed

ffnvcodec.pc.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ includedir=${prefix}/include
33

44
Name: ffnvcodec
55
Description: FFmpeg version of Nvidia Codec SDK headers
6-
Version: 8.2.15.4
6+
Version: 8.2.15.5
77
Cflags: -I${includedir}

include/ffnvcodec/dynlink_cuda.h

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ typedef void* CUarray;
4545
typedef void* CUcontext;
4646
typedef void* CUstream;
4747
typedef void* CUevent;
48+
typedef void* CUfunction;
49+
typedef void* CUmodule;
50+
typedef void* CUtexObject;
4851
typedef void* CUmipmappedArray;
4952
typedef void* CUgraphicsResource;
5053
typedef void* CUexternalMemory;
@@ -85,6 +88,25 @@ typedef enum CUlimit_enum {
8588
CU_LIMIT_DEV_RUNTIME_PENDING_LAUNCH_COUNT = 4
8689
} CUlimit;
8790

91+
typedef enum CUresourcetype_enum {
92+
CU_RESOURCE_TYPE_ARRAY = 0x00,
93+
CU_RESOURCE_TYPE_MIPMAPPED_ARRAY = 0x01,
94+
CU_RESOURCE_TYPE_LINEAR = 0x02,
95+
CU_RESOURCE_TYPE_PITCH2D = 0x03
96+
} CUresourcetype;
97+
98+
typedef enum CUaddress_mode_enum {
99+
CU_TR_ADDRESS_MODE_WRAP = 0,
100+
CU_TR_ADDRESS_MODE_CLAMP = 1,
101+
CU_TR_ADDRESS_MODE_MIRROR = 2,
102+
CU_TR_ADDRESS_MODE_BORDER = 3
103+
} CUaddress_mode;
104+
105+
typedef enum CUfilter_mode_enum {
106+
CU_TR_FILTER_MODE_POINT = 0,
107+
CU_TR_FILTER_MODE_LINEAR = 1
108+
} CUfilter_mode;
109+
88110
typedef enum CUgraphicsRegisterFlags_enum {
89111
CU_GRAPHICS_REGISTER_FLAGS_NONE = 0,
90112
CU_GRAPHICS_REGISTER_FLAGS_READ_ONLY = 1,
@@ -136,6 +158,52 @@ typedef struct CUDA_MEMCPY2D_st {
136158
size_t Height;
137159
} CUDA_MEMCPY2D;
138160

161+
typedef struct CUDA_RESOURCE_DESC_st {
162+
CUresourcetype resType;
163+
union {
164+
struct {
165+
CUarray hArray;
166+
} array;
167+
struct {
168+
CUmipmappedArray hMipmappedArray;
169+
} mipmap;
170+
struct {
171+
CUdeviceptr devPtr;
172+
CUarray_format format;
173+
unsigned int numChannels;
174+
size_t sizeInBytes;
175+
} linear;
176+
struct {
177+
CUdeviceptr devPtr;
178+
CUarray_format format;
179+
unsigned int numChannels;
180+
size_t width;
181+
size_t height;
182+
size_t pitchInBytes;
183+
} pitch2D;
184+
struct {
185+
int reserved[32];
186+
} reserved;
187+
} res;
188+
unsigned int flags;
189+
} CUDA_RESOURCE_DESC;
190+
191+
typedef struct CUDA_TEXTURE_DESC_st {
192+
CUaddress_mode addressMode[3];
193+
CUfilter_mode filterMode;
194+
unsigned int flags;
195+
unsigned int maxAnisotropy;
196+
CUfilter_mode mipmapFilterMode;
197+
float mipmapLevelBias;
198+
float minMipmapLevelClamp;
199+
float maxMipmapLevelClamp;
200+
float borderColor[4];
201+
int reserved[12];
202+
} CUDA_TEXTURE_DESC;
203+
204+
/* Unused type */
205+
typedef struct CUDA_RESOURCE_VIEW_DESC_st CUDA_RESOURCE_VIEW_DESC;
206+
139207
typedef unsigned int GLenum;
140208
typedef unsigned int GLuint;
141209

@@ -210,6 +278,7 @@ typedef struct CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC_st {
210278
#define CU_STREAM_NON_BLOCKING 1
211279
#define CU_EVENT_BLOCKING_SYNC 1
212280
#define CU_EVENT_DISABLE_TIMING 2
281+
#define CU_TRSF_READ_AS_INTEGER 1
213282

214283
typedef void CUDAAPI CUstreamCallback(CUstream hStream, CUresult status, void *userdata);
215284

@@ -242,6 +311,13 @@ typedef CUresult CUDAAPI tcuEventSynchronize(CUevent hEvent);
242311
typedef CUresult CUDAAPI tcuEventQuery(CUevent hEvent);
243312
typedef CUresult CUDAAPI tcuEventRecord(CUevent hEvent, CUstream hStream);
244313

314+
typedef CUresult CUDAAPI tcuLaunchKernel(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);
315+
typedef CUresult CUDAAPI tcuModuleLoadData(CUmodule* module, const void* image);
316+
typedef CUresult CUDAAPI tcuModuleUnload(CUmodule hmod);
317+
typedef CUresult CUDAAPI tcuModuleGetFunction(CUfunction* hfunc, CUmodule hmod, const char* name);
318+
typedef CUresult CUDAAPI tcuTexObjectCreate(CUtexObject* pTexObject, const CUDA_RESOURCE_DESC* pResDesc, const CUDA_TEXTURE_DESC* pTexDesc, const CUDA_RESOURCE_VIEW_DESC* pResViewDesc);
319+
typedef CUresult CUDAAPI tcuTexObjectDestroy(CUtexObject texObject);
320+
245321
typedef CUresult CUDAAPI tcuGLGetDevices_v2(unsigned int* pCudaDeviceCount, CUdevice* pCudaDevices, unsigned int cudaDeviceCount, CUGLDeviceList deviceList);
246322
typedef CUresult CUDAAPI tcuGraphicsGLRegisterImage(CUgraphicsResource* pCudaResource, GLuint image, GLenum target, unsigned int Flags);
247323
typedef CUresult CUDAAPI tcuGraphicsUnregisterResource(CUgraphicsResource resource);

include/ffnvcodec/dynlink_loader.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,13 @@ typedef struct CudaFunctions {
165165
tcuEventQuery *cuEventQuery;
166166
tcuEventRecord *cuEventRecord;
167167

168+
tcuLaunchKernel *cuLaunchKernel;
169+
tcuModuleLoadData *cuModuleLoadData;
170+
tcuModuleUnload *cuModuleUnload;
171+
tcuModuleGetFunction *cuModuleGetFunction;
172+
tcuTexObjectCreate *cuTexObjectCreate;
173+
tcuTexObjectDestroy *cuTexObjectDestroy;
174+
168175
tcuGLGetDevices_v2 *cuGLGetDevices;
169176
tcuGraphicsGLRegisterImage *cuGraphicsGLRegisterImage;
170177
tcuGraphicsUnregisterResource *cuGraphicsUnregisterResource;
@@ -278,6 +285,13 @@ static inline int cuda_load_functions(CudaFunctions **functions, void *logctx)
278285
LOAD_SYMBOL(cuEventQuery, tcuEventQuery, "cuEventQuery");
279286
LOAD_SYMBOL(cuEventRecord, tcuEventRecord, "cuEventRecord");
280287

288+
LOAD_SYMBOL(cuLaunchKernel, tcuLaunchKernel, "cuLaunchKernel");
289+
LOAD_SYMBOL(cuModuleLoadData, tcuModuleLoadData, "cuModuleLoadData");
290+
LOAD_SYMBOL(cuModuleUnload, tcuModuleUnload, "cuModuleUnload");
291+
LOAD_SYMBOL(cuModuleGetFunction, tcuModuleGetFunction, "cuModuleGetFunction");
292+
LOAD_SYMBOL(cuTexObjectCreate, tcuTexObjectCreate, "cuTexObjectCreate");
293+
LOAD_SYMBOL(cuTexObjectDestroy, tcuTexObjectDestroy, "cuTexObjectDestroy");
294+
281295
LOAD_SYMBOL(cuGLGetDevices, tcuGLGetDevices_v2, "cuGLGetDevices_v2");
282296
LOAD_SYMBOL(cuGraphicsGLRegisterImage, tcuGraphicsGLRegisterImage, "cuGraphicsGLRegisterImage");
283297
LOAD_SYMBOL(cuGraphicsUnregisterResource, tcuGraphicsUnregisterResource, "cuGraphicsUnregisterResource");

0 commit comments

Comments
 (0)