cuda: Remove GST_CUDA_HAS_D3D define from header

... and fix d3d11 specific enum type name

GST_CUDA_HAS_D3D is a build time define which indicates whether
GstD3D11 library is available or not, but DirectX SDK headers
must be available on the build system already.

Expose Direct3D related symbols if the build target is Windows
(i.e., if G_OS_WIN32 is defined)

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3018>
This commit is contained in:
Seungha Yang 2022-09-13 01:02:50 +09:00 committed by GStreamer Marge Bot
parent c4681ac428
commit 219bb769a2
8 changed files with 59 additions and 27 deletions

View file

@ -4,6 +4,16 @@
#include <cuda.h> #include <cuda.h>
#include <cudaGL.h> #include <cudaGL.h>
#ifdef G_OS_WIN32
#ifndef INITGUID
#include <initguid.h>
#endif /* INITGUID */
#include <d3d11.h>
#include <dxgi.h>
#include <cudaD3D11.h>
#endif /* G_OS_WIN32 */
G_BEGIN_DECLS G_BEGIN_DECLS
/* cuda.h */ /* cuda.h */
@ -182,23 +192,23 @@ CUresult CUDAAPI CuGLGetDevices (unsigned int * pCudaDeviceCount,
CUGLDeviceList deviceList); CUGLDeviceList deviceList);
#ifdef GST_CUDA_HAS_D3D #ifdef G_OS_WIN32
/* cudaD3D11.h */ /* cudaD3D11.h */
GST_CUDA_API GST_CUDA_API
CUresult CUDAAPI CuGraphicsD3D11RegisterResource(CUgraphicsResource * pCudaResource, CUresult CUDAAPI CuGraphicsD3D11RegisterResource(CUgraphicsResource * pCudaResource,
gpointer pD3DResource, ID3D11Resource * pD3DResource,
unsigned int Flags); unsigned int Flags);
GST_CUDA_API GST_CUDA_API
CUresult CUDAAPI CuD3D11GetDevice(CUdevice * device, CUresult CUDAAPI CuD3D11GetDevice(CUdevice * device,
gpointer pAdapter); IDXGIAdapter * pAdapter);
GST_CUDA_API GST_CUDA_API
CUresult CUDAAPI CuD3D11GetDevices(unsigned int * pCudaDeviceCount, CUresult CUDAAPI CuD3D11GetDevices(unsigned int * pCudaDeviceCount,
CUdevice* pCudaDevices, CUdevice* pCudaDevices,
unsigned int cudaDeviceCount, unsigned int cudaDeviceCount,
gpointer pD3D11Device, ID3D11Device * pD3D11Device,
CUD3D11DeviceList deviceList); CUd3d11DeviceList deviceList);
#endif #endif
G_END_DECLS G_END_DECLS

View file

@ -182,7 +182,7 @@ gst_cuda_context_find_dxgi_adapter_luid (CUdevice cuda_device)
continue; continue;
} }
cuda_ret = CuD3D11GetDevice (&other_dev, adapter); cuda_ret = CuD3D11GetDevice (&other_dev, (IDXGIAdapter *) adapter);
IDXGIAdapter1_Release (adapter); IDXGIAdapter1_Release (adapter);
if (cuda_ret == CUDA_SUCCESS && other_dev == cuda_device) { if (cuda_ret == CUDA_SUCCESS && other_dev == cuda_device) {

View file

@ -123,13 +123,15 @@ typedef struct _GstNvCodecCudaVTable
CUdevice * pCudaDevices, unsigned int cudaDeviceCount, CUdevice * pCudaDevices, unsigned int cudaDeviceCount,
CUGLDeviceList deviceList); CUGLDeviceList deviceList);
#ifdef G_OS_WIN32
CUresult (CUDAAPI * CuGraphicsD3D11RegisterResource) (CUgraphicsResource * CUresult (CUDAAPI * CuGraphicsD3D11RegisterResource) (CUgraphicsResource *
pCudaResource, gpointer pD3DResource, unsigned int Flags); pCudaResource, ID3D11Resource * pD3DResource, unsigned int Flags);
CUresult (CUDAAPI * CuD3D11GetDevice) (CUdevice * device, CUresult (CUDAAPI * CuD3D11GetDevice) (CUdevice * device,
gpointer pAdapter); IDXGIAdapter * pAdapter);
CUresult (CUDAAPI * CuD3D11GetDevices) (unsigned int *pCudaDeviceCount, CUresult (CUDAAPI * CuD3D11GetDevices) (unsigned int *pCudaDeviceCount,
CUdevice * pCudaDevices, unsigned int cudaDeviceCount, CUdevice * pCudaDevices, unsigned int cudaDeviceCount,
gpointer pD3D11Device, CUD3D11DeviceList deviceList); ID3D11Device * pD3D11Device, CUd3d11DeviceList deviceList);
#endif
} GstNvCodecCudaVTable; } GstNvCodecCudaVTable;
/* *INDENT-ON* */ /* *INDENT-ON* */
@ -223,7 +225,7 @@ gst_cuda_load_library (void)
LOAD_SYMBOL (cuGraphicsGLRegisterBuffer, CuGraphicsGLRegisterBuffer); LOAD_SYMBOL (cuGraphicsGLRegisterBuffer, CuGraphicsGLRegisterBuffer);
LOAD_SYMBOL (cuGLGetDevices, CuGLGetDevices); LOAD_SYMBOL (cuGLGetDevices, CuGLGetDevices);
#ifdef GST_CUDA_HAS_D3D #ifdef G_OS_WIN32
/* cudaD3D11.h */ /* cudaD3D11.h */
LOAD_SYMBOL (cuGraphicsD3D11RegisterResource, LOAD_SYMBOL (cuGraphicsD3D11RegisterResource,
CuGraphicsD3D11RegisterResource); CuGraphicsD3D11RegisterResource);
@ -590,10 +592,10 @@ CuGLGetDevices (unsigned int *pCudaDeviceCount, CUdevice * pCudaDevices,
} }
/* cudaD3D11.h */ /* cudaD3D11.h */
#ifdef GST_CUDA_HAS_D3D #ifdef G_OS_WIN32
CUresult CUDAAPI CUresult CUDAAPI
CuGraphicsD3D11RegisterResource (CUgraphicsResource * pCudaResource, CuGraphicsD3D11RegisterResource (CUgraphicsResource * pCudaResource,
gpointer pD3DResource, unsigned int Flags) ID3D11Resource * pD3DResource, unsigned int Flags)
{ {
g_assert (gst_cuda_vtable.CuGraphicsD3D11RegisterResource != NULL); g_assert (gst_cuda_vtable.CuGraphicsD3D11RegisterResource != NULL);
@ -602,7 +604,7 @@ CuGraphicsD3D11RegisterResource (CUgraphicsResource * pCudaResource,
} }
CUresult CUDAAPI CUresult CUDAAPI
CuD3D11GetDevice (CUdevice * device, gpointer pAdapter) CuD3D11GetDevice (CUdevice * device, IDXGIAdapter * pAdapter)
{ {
g_assert (gst_cuda_vtable.CuD3D11GetDevice != NULL); g_assert (gst_cuda_vtable.CuD3D11GetDevice != NULL);
@ -611,9 +613,8 @@ CuD3D11GetDevice (CUdevice * device, gpointer pAdapter)
CUresult CUDAAPI CUresult CUDAAPI
CuD3D11GetDevices (unsigned int *pCudaDeviceCount, CuD3D11GetDevices (unsigned int *pCudaDeviceCount,
CUdevice * pCudaDevices, CUdevice * pCudaDevices, unsigned int cudaDeviceCount,
unsigned int cudaDeviceCount, ID3D11Device * pD3D11Device, CUd3d11DeviceList deviceList)
gpointer pD3D11Device, CUD3D11DeviceList deviceList)
{ {
g_assert (gst_cuda_vtable.CuD3D11GetDevices != NULL); g_assert (gst_cuda_vtable.CuD3D11GetDevices != NULL);

View file

@ -495,7 +495,7 @@ gst_cuda_graphics_resource_register_gl_buffer (GstCudaGraphicsResource *
return TRUE; return TRUE;
} }
#ifdef GST_CUDA_HAS_D3D #ifdef G_OS_WIN32
/** /**
* gst_cuda_graphics_resource_register_d3d11_resource: (skip) * gst_cuda_graphics_resource_register_d3d11_resource: (skip)
* @resource a #GstCudaGraphicsResource * @resource a #GstCudaGraphicsResource
@ -512,7 +512,7 @@ gst_cuda_graphics_resource_register_gl_buffer (GstCudaGraphicsResource *
*/ */
gboolean gboolean
gst_cuda_graphics_resource_register_d3d11_resource (GstCudaGraphicsResource * gst_cuda_graphics_resource_register_d3d11_resource (GstCudaGraphicsResource *
resource, gpointer d3d11_resource, CUgraphicsRegisterFlags flags) resource, ID3D11Resource * d3d11_resource, CUgraphicsRegisterFlags flags)
{ {
CUresult cuda_ret; CUresult cuda_ret;

View file

@ -162,10 +162,10 @@ gboolean gst_cuda_graphics_resource_register_gl_buffer (GstCudaGraphicsRe
guint buffer, guint buffer,
CUgraphicsRegisterFlags flags); CUgraphicsRegisterFlags flags);
#ifdef GST_CUDA_HAS_D3D #ifdef G_OS_WIN32
GST_CUDA_API GST_CUDA_API
gboolean gst_cuda_graphics_resource_register_d3d11_resource (GstCudaGraphicsResource * resource, gboolean gst_cuda_graphics_resource_register_d3d11_resource (GstCudaGraphicsResource * resource,
gpointer d3d11_resource, ID3D11Resource * d3d11_resource,
CUgraphicsRegisterFlags flags); CUgraphicsRegisterFlags flags);
#endif #endif

View file

@ -23,6 +23,20 @@ if host_system not in ['windows', 'linux']
subdir_done() subdir_done()
endif endif
cuda_win32_headers = [
'initguid.h',
'd3d11.h',
'dxgi.h',
]
if host_system == 'windows'
foreach h : cuda_win32_headers
if not cc.has_header(h)
subdir_done()
endif
endforeach
endif
cuda_stubinc = include_directories('./stub') cuda_stubinc = include_directories('./stub')
extra_c_args = ['-DGST_USE_UNSTABLE_API'] extra_c_args = ['-DGST_USE_UNSTABLE_API']

View file

@ -132,13 +132,6 @@ typedef struct
gsize Height; gsize Height;
} CUDA_MEMCPY2D; } CUDA_MEMCPY2D;
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 typedef struct
{ {
CUaddress_mode addressMode[3]; CUaddress_mode addressMode[3];

View file

@ -0,0 +1,14 @@
#pragma once
#include <glib.h>
G_BEGIN_DECLS
typedef enum
{
CU_D3D11_DEVICE_LIST_ALL = 0x01,
CU_D3D11_DEVICE_LIST_CURRENT_FRAME = 0x02,
CU_D3D11_DEVICE_LIST_NEXT_FRAME = 0x03,
} CUd3d11DeviceList;
G_END_DECLS