diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudaloader.c b/subprojects/gst-plugins-bad/sys/nvcodec/gstcudaloader.c index f0eddfaaca..d9ea49a89e 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudaloader.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstcudaloader.c @@ -62,6 +62,9 @@ typedef struct _GstNvCodecCudaVTable CUgraphicsResource * resources, CUstream hStream); CUresult (CUDAAPI * CuGraphicsUnmapResources) (unsigned int count, CUgraphicsResource * resources, CUstream hStream); + CUresult (CUDAAPI * + CuGraphicsResourceSetMapFlags) (CUgraphicsResource resource, + unsigned int flags); CUresult (CUDAAPI * CuGraphicsSubResourceGetMappedArray) (CUarray * pArray, CUgraphicsResource resource, unsigned int arrayIndex, unsigned int mipLevel); @@ -115,12 +118,17 @@ typedef struct _GstNvCodecCudaVTable unsigned int Flags); CUresult (CUDAAPI * CuGraphicsGLRegisterBuffer) (CUgraphicsResource * pCudaResource, unsigned int buffer, unsigned int Flags); - CUresult (CUDAAPI * - CuGraphicsResourceSetMapFlags) (CUgraphicsResource resource, - unsigned int flags); CUresult (CUDAAPI * CuGLGetDevices) (unsigned int *pCudaDeviceCount, CUdevice * pCudaDevices, unsigned int cudaDeviceCount, CUGLDeviceList deviceList); + + CUresult (CUDAAPI * CuGraphicsD3D11RegisterResource) (CUgraphicsResource * + pCudaResource, gpointer pD3DResource, unsigned int Flags); + CUresult (CUDAAPI * CuD3D11GetDevice) (CUdevice * device, + gpointer pAdapter); + CUresult (CUDAAPI * CuD3D11GetDevices) (unsigned int *pCudaDeviceCount, + CUdevice * pCudaDevices, unsigned int cudaDeviceCount, + gpointer pD3D11Device, CUD3D11DeviceList deviceList); } GstNvCodecCudaVTable; /* *INDENT-ON* */ @@ -157,6 +165,7 @@ gst_cuda_load_library (void) LOAD_SYMBOL (cuGraphicsMapResources, CuGraphicsMapResources); LOAD_SYMBOL (cuGraphicsUnmapResources, CuGraphicsUnmapResources); + LOAD_SYMBOL (cuGraphicsResourceSetMapFlags, CuGraphicsResourceSetMapFlags); LOAD_SYMBOL (cuGraphicsSubResourceGetMappedArray, CuGraphicsSubResourceGetMappedArray); LOAD_SYMBOL (cuGraphicsResourceGetMappedPointer, @@ -194,9 +203,16 @@ gst_cuda_load_library (void) /* cudaGL.h */ LOAD_SYMBOL (cuGraphicsGLRegisterImage, CuGraphicsGLRegisterImage); LOAD_SYMBOL (cuGraphicsGLRegisterBuffer, CuGraphicsGLRegisterBuffer); - LOAD_SYMBOL (cuGraphicsResourceSetMapFlags, CuGraphicsResourceSetMapFlags); LOAD_SYMBOL (cuGLGetDevices, CuGLGetDevices); +#ifdef HAVE_NVCODEC_GST_D3D11 + /* cudaD3D11.h */ + LOAD_SYMBOL (cuGraphicsD3D11RegisterResource, + CuGraphicsD3D11RegisterResource); + LOAD_SYMBOL (cuD3D11GetDevice, CuD3D11GetDevice); + LOAD_SYMBOL (cuD3D11GetDevices, CuD3D11GetDevices); +#endif + vtable->loaded = TRUE; return TRUE; @@ -297,6 +313,14 @@ CuGraphicsUnmapResources (unsigned int count, CUgraphicsResource * resources, return gst_cuda_vtable.CuGraphicsUnmapResources (count, resources, hStream); } +CUresult CUDAAPI +CuGraphicsResourceSetMapFlags (CUgraphicsResource resource, unsigned int flags) +{ + g_assert (gst_cuda_vtable.CuGraphicsResourceSetMapFlags != NULL); + + return gst_cuda_vtable.CuGraphicsResourceSetMapFlags (resource, flags); +} + CUresult CUDAAPI CuGraphicsSubResourceGetMappedArray (CUarray * pArray, CUgraphicsResource resource, unsigned int arrayIndex, unsigned int mipLevel) @@ -537,14 +561,6 @@ CuGraphicsGLRegisterBuffer (CUgraphicsResource * pCudaResource, Flags); } -CUresult CUDAAPI -CuGraphicsResourceSetMapFlags (CUgraphicsResource resource, unsigned int flags) -{ - g_assert (gst_cuda_vtable.CuGraphicsResourceSetMapFlags != NULL); - - return gst_cuda_vtable.CuGraphicsResourceSetMapFlags (resource, flags); -} - CUresult CUDAAPI CuGLGetDevices (unsigned int *pCudaDeviceCount, CUdevice * pCudaDevices, unsigned int cudaDeviceCount, CUGLDeviceList deviceList) @@ -554,3 +570,34 @@ CuGLGetDevices (unsigned int *pCudaDeviceCount, CUdevice * pCudaDevices, return gst_cuda_vtable.CuGLGetDevices (pCudaDeviceCount, pCudaDevices, cudaDeviceCount, deviceList); } + +/* cudaD3D11.h */ +CUresult CUDAAPI +CuGraphicsD3D11RegisterResource (CUgraphicsResource * pCudaResource, + gpointer pD3DResource, unsigned int Flags) +{ + g_assert (gst_cuda_vtable.CuGraphicsD3D11RegisterResource != NULL); + + return gst_cuda_vtable.CuGraphicsD3D11RegisterResource (pCudaResource, + pD3DResource, Flags); +} + +CUresult CUDAAPI +CuD3D11GetDevice (CUdevice * device, gpointer pAdapter) +{ + g_assert (gst_cuda_vtable.CuD3D11GetDevice != NULL); + + return gst_cuda_vtable.CuD3D11GetDevice (device, pAdapter); +} + +CUresult CUDAAPI +CuD3D11GetDevices (unsigned int *pCudaDeviceCount, + CUdevice * pCudaDevices, + unsigned int cudaDeviceCount, + gpointer pD3D11Device, CUD3D11DeviceList deviceList) +{ + g_assert (gst_cuda_vtable.CuD3D11GetDevices != NULL); + + return gst_cuda_vtable.CuD3D11GetDevices (pCudaDeviceCount, pCudaDevices, + cudaDeviceCount, pD3D11Device, deviceList); +} diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudaloader.h b/subprojects/gst-plugins-bad/sys/nvcodec/gstcudaloader.h index 74a78d3127..3d3253bffb 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudaloader.h +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstcudaloader.h @@ -60,6 +60,9 @@ CUresult CUDAAPI CuGraphicsUnmapResources (unsigned int count, CUgraphicsResource * resources, CUstream hStream); +CUresult CUDAAPI CuGraphicsResourceSetMapFlags (CUgraphicsResource resource, + unsigned int flags); + CUresult CUDAAPI CuGraphicsSubResourceGetMappedArray (CUarray * pArray, CUgraphicsResource resource, unsigned int arrayIndex, @@ -155,13 +158,24 @@ CUresult CUDAAPI CuGraphicsGLRegisterBuffer (CUgraphicsResource * pCudaResource, unsigned int buffer, unsigned int Flags); -CUresult CUDAAPI CuGraphicsResourceSetMapFlags (CUgraphicsResource resource, - unsigned int flags); - CUresult CUDAAPI CuGLGetDevices (unsigned int * pCudaDeviceCount, CUdevice * pCudaDevices, unsigned int cudaDeviceCount, CUGLDeviceList deviceList); +/* cudaD3D11.h */ +CUresult CUDAAPI CuGraphicsD3D11RegisterResource(CUgraphicsResource * pCudaResource, + gpointer pD3DResource, + unsigned int Flags); + +CUresult CUDAAPI CuD3D11GetDevice(CUdevice * device, + gpointer pAdapter); + +CUresult CUDAAPI CuD3D11GetDevices(unsigned int * pCudaDeviceCount, + CUdevice* pCudaDevices, + unsigned int cudaDeviceCount, + gpointer pD3D11Device, + CUD3D11DeviceList deviceList); + G_END_DECLS #endif /* __GST_CUDA_LOADER_H__ */ diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/stub/cuda.h b/subprojects/gst-plugins-bad/sys/nvcodec/stub/cuda.h index a63d0ae129..1ca0a04a23 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/stub/cuda.h +++ b/subprojects/gst-plugins-bad/sys/nvcodec/stub/cuda.h @@ -135,6 +135,13 @@ typedef enum CU_GL_DEVICE_LIST_ALL = 0x01, } CUGLDeviceList; +typedef enum +{ + CU_D3D11_DEVICE_LIST_ALL = 0x01, + CU_D3D11_DEVICE_LIST_CURRENT_FRAME = 0x02, + CU_D3D11_DEVICE_LIST_NEXT_FRAME = 0x03, +} CUD3D11DeviceList; + typedef struct { CUaddress_mode addressMode[3];