Skip to content

Commit 3ed7c9a

Browse files
committed
Add D3D11 interop functions
1 parent 9b57e4c commit 3ed7c9a

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

include/ffnvcodec/dynlink_cuda.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,13 @@ typedef enum CUeglColorFormat
216216
CU_EGL_COLOR_FORMAT_Y12V12U12_420_SEMIPLANAR = 0x19,
217217
} CUeglColorFormat;
218218

219+
typedef enum CUd3d11DeviceList_enum
220+
{
221+
CU_D3D11_DEVICE_LIST_ALL = 1,
222+
CU_D3D11_DEVICE_LIST_CURRENT_FRAME = 2,
223+
CU_D3D11_DEVICE_LIST_NEXT_FRAME = 3,
224+
} CUd3d11DeviceList;
225+
219226
#ifndef CU_UUID_HAS_BEEN_DEFINED
220227
#define CU_UUID_HAS_BEEN_DEFINED
221228
typedef struct CUuuid_st {
@@ -442,7 +449,7 @@ typedef CUresult CUDAAPI tcuEventQuery(CUevent hEvent);
442449
typedef CUresult CUDAAPI tcuEventRecord(CUevent hEvent, CUstream hStream);
443450

444451
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);
445-
typedef CUresult CUDAAPI tcuLinkCreate(unsigned int numOptions, CUjit_option* options, void** optionValues, CUlinkState* stateOut);
452+
typedef CUresult CUDAAPI tcuLinkCreate(unsigned int numOptions, CUjit_option* options, void** optionValues, CUlinkState* stateOut);
446453
typedef CUresult CUDAAPI tcuLinkAddData(CUlinkState state, CUjitInputType type, void* data, size_t size, const char* name, unsigned int numOptions, CUjit_option* options, void** optionValues);
447454
typedef CUresult CUDAAPI tcuLinkComplete(CUlinkState state, void** cubinOut, size_t* sizeOut);
448455
typedef CUresult CUDAAPI tcuLinkDestroy(CUlinkState state);
@@ -459,6 +466,7 @@ typedef CUresult CUDAAPI tcuGraphicsUnregisterResource(CUgraphicsResource resour
459466
typedef CUresult CUDAAPI tcuGraphicsMapResources(unsigned int count, CUgraphicsResource* resources, CUstream hStream);
460467
typedef CUresult CUDAAPI tcuGraphicsUnmapResources(unsigned int count, CUgraphicsResource* resources, CUstream hStream);
461468
typedef CUresult CUDAAPI tcuGraphicsSubResourceGetMappedArray(CUarray* pArray, CUgraphicsResource resource, unsigned int arrayIndex, unsigned int mipLevel);
469+
typedef CUresult CUDAAPI tcuGraphicsResourceGetMappedPointer(CUdeviceptr *devPtrOut, size_t *sizeOut, CUgraphicsResource resource);
462470

463471
typedef CUresult CUDAAPI tcuImportExternalMemory(CUexternalMemory* extMem_out, const CUDA_EXTERNAL_MEMORY_HANDLE_DESC* memHandleDesc);
464472
typedef CUresult CUDAAPI tcuDestroyExternalMemory(CUexternalMemory extMem);
@@ -480,4 +488,8 @@ typedef CUresult CUDAAPI tcuEGLStreamProducerDisconnect(CUeglStreamConnection* c
480488
typedef CUresult CUDAAPI tcuEGLStreamConsumerDisconnect(CUeglStreamConnection* conn);
481489
typedef CUresult CUDAAPI tcuEGLStreamProducerPresentFrame(CUeglStreamConnection* conn, CUeglFrame eglframe, CUstream* pStream);
482490
typedef CUresult CUDAAPI tcuEGLStreamProducerReturnFrame(CUeglStreamConnection* conn, CUeglFrame* eglframe, CUstream* pStream);
491+
492+
typedef CUresult CUDAAPI tcuD3D11GetDevice(CUdevice *device, void *dxgiAdapter);
493+
typedef CUresult CUDAAPI tcuD3D11GetDevices(unsigned int *deviceCountOut, CUdevice *devices, unsigned int deviceCount, void *d3d11device, CUd3d11DeviceList listType);
494+
typedef CUresult CUDAAPI tcuGraphicsD3D11RegisterResource(CUgraphicsResource *cudaResourceOut, void *d3d11Resource, unsigned int flags);
483495
#endif

include/ffnvcodec/dynlink_loader.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ typedef struct CudaFunctions {
202202
tcuGraphicsMapResources *cuGraphicsMapResources;
203203
tcuGraphicsUnmapResources *cuGraphicsUnmapResources;
204204
tcuGraphicsSubResourceGetMappedArray *cuGraphicsSubResourceGetMappedArray;
205+
tcuGraphicsResourceGetMappedPointer *cuGraphicsResourceGetMappedPointer;
205206

206207
tcuImportExternalMemory *cuImportExternalMemory;
207208
tcuDestroyExternalMemory *cuDestroyExternalMemory;
@@ -225,6 +226,12 @@ typedef struct CudaFunctions {
225226
tcuEGLStreamProducerPresentFrame *cuEGLStreamProducerPresentFrame;
226227
tcuEGLStreamProducerReturnFrame *cuEGLStreamProducerReturnFrame;
227228

229+
#if defined(_WIN32) || defined(__CYGWIN__)
230+
tcuD3D11GetDevice *cuD3D11GetDevice;
231+
tcuD3D11GetDevices *cuD3D11GetDevices;
232+
tcuGraphicsD3D11RegisterResource *cuGraphicsD3D11RegisterResource;
233+
#endif
234+
228235
FFNV_LIB_HANDLE lib;
229236
} CudaFunctions;
230237
#else
@@ -358,6 +365,7 @@ static inline int cuda_load_functions(CudaFunctions **functions, void *logctx)
358365
LOAD_SYMBOL(cuGraphicsMapResources, tcuGraphicsMapResources, "cuGraphicsMapResources");
359366
LOAD_SYMBOL(cuGraphicsUnmapResources, tcuGraphicsUnmapResources, "cuGraphicsUnmapResources");
360367
LOAD_SYMBOL(cuGraphicsSubResourceGetMappedArray, tcuGraphicsSubResourceGetMappedArray, "cuGraphicsSubResourceGetMappedArray");
368+
LOAD_SYMBOL(cuGraphicsResourceGetMappedPointer, tcuGraphicsResourceGetMappedPointer, "cuGraphicsResourceGetMappedPointer_v2");
361369

362370
LOAD_SYMBOL_OPT(cuDeviceGetUuid, tcuDeviceGetUuid, "cuDeviceGetUuid");
363371
LOAD_SYMBOL_OPT(cuImportExternalMemory, tcuImportExternalMemory, "cuImportExternalMemory");
@@ -381,6 +389,12 @@ static inline int cuda_load_functions(CudaFunctions **functions, void *logctx)
381389
LOAD_SYMBOL_OPT(cuEGLStreamProducerPresentFrame, tcuEGLStreamProducerPresentFrame, "cuEGLStreamProducerPresentFrame");
382390
LOAD_SYMBOL_OPT(cuEGLStreamProducerReturnFrame, tcuEGLStreamProducerReturnFrame, "cuEGLStreamProducerReturnFrame");
383391

392+
#if defined(_WIN32) || defined(__CYGWIN__)
393+
LOAD_SYMBOL(cuD3D11GetDevice, tcuD3D11GetDevice, "cuD3D11GetDevice");
394+
LOAD_SYMBOL(cuD3D11GetDevices, tcuD3D11GetDevices, "cuD3D11GetDevices");
395+
LOAD_SYMBOL(cuGraphicsD3D11RegisterResource, tcuGraphicsD3D11RegisterResource, "cuGraphicsD3D11RegisterResource");
396+
#endif
397+
384398
GENERIC_LOAD_FUNC_FINALE(cuda);
385399
}
386400
#endif

0 commit comments

Comments
 (0)