From: Seungha Yang Date: Mon, 12 Sep 2022 16:02:50 +0000 (+0900) Subject: cuda: Remove GST_CUDA_HAS_D3D define from header X-Git-Tag: 1.22.0~965 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=219bb769a29a595460648b1f042c5ee70d5c3bd8;p=platform%2Fupstream%2Fgstreamer.git 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: --- diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/cuda/cuda-gst.h b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/cuda-gst.h index 37bb4f9..381264a 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/cuda/cuda-gst.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/cuda-gst.h @@ -4,6 +4,16 @@ #include #include +#ifdef G_OS_WIN32 +#ifndef INITGUID +#include +#endif /* INITGUID */ + +#include +#include +#include +#endif /* G_OS_WIN32 */ + G_BEGIN_DECLS /* cuda.h */ @@ -182,23 +192,23 @@ CUresult CUDAAPI CuGLGetDevices (unsigned int * pCudaDeviceCount, CUGLDeviceList deviceList); -#ifdef GST_CUDA_HAS_D3D +#ifdef G_OS_WIN32 /* cudaD3D11.h */ GST_CUDA_API CUresult CUDAAPI CuGraphicsD3D11RegisterResource(CUgraphicsResource * pCudaResource, - gpointer pD3DResource, + ID3D11Resource * pD3DResource, unsigned int Flags); GST_CUDA_API CUresult CUDAAPI CuD3D11GetDevice(CUdevice * device, - gpointer pAdapter); + IDXGIAdapter * pAdapter); GST_CUDA_API CUresult CUDAAPI CuD3D11GetDevices(unsigned int * pCudaDeviceCount, CUdevice* pCudaDevices, unsigned int cudaDeviceCount, - gpointer pD3D11Device, - CUD3D11DeviceList deviceList); + ID3D11Device * pD3D11Device, + CUd3d11DeviceList deviceList); #endif G_END_DECLS diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudacontext.c b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudacontext.c index bd611dc..aed158a 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudacontext.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudacontext.c @@ -182,7 +182,7 @@ gst_cuda_context_find_dxgi_adapter_luid (CUdevice cuda_device) continue; } - cuda_ret = CuD3D11GetDevice (&other_dev, adapter); + cuda_ret = CuD3D11GetDevice (&other_dev, (IDXGIAdapter *) adapter); IDXGIAdapter1_Release (adapter); if (cuda_ret == CUDA_SUCCESS && other_dev == cuda_device) { diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudaloader.c b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudaloader.c index 064987f..fffcbef 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudaloader.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudaloader.c @@ -123,13 +123,15 @@ typedef struct _GstNvCodecCudaVTable CUdevice * pCudaDevices, unsigned int cudaDeviceCount, CUGLDeviceList deviceList); +#ifdef G_OS_WIN32 CUresult (CUDAAPI * CuGraphicsD3D11RegisterResource) (CUgraphicsResource * - pCudaResource, gpointer pD3DResource, unsigned int Flags); + pCudaResource, ID3D11Resource * pD3DResource, unsigned int Flags); CUresult (CUDAAPI * CuD3D11GetDevice) (CUdevice * device, - gpointer pAdapter); + IDXGIAdapter * pAdapter); CUresult (CUDAAPI * CuD3D11GetDevices) (unsigned int *pCudaDeviceCount, CUdevice * pCudaDevices, unsigned int cudaDeviceCount, - gpointer pD3D11Device, CUD3D11DeviceList deviceList); + ID3D11Device * pD3D11Device, CUd3d11DeviceList deviceList); +#endif } GstNvCodecCudaVTable; /* *INDENT-ON* */ @@ -223,7 +225,7 @@ gst_cuda_load_library (void) LOAD_SYMBOL (cuGraphicsGLRegisterBuffer, CuGraphicsGLRegisterBuffer); LOAD_SYMBOL (cuGLGetDevices, CuGLGetDevices); -#ifdef GST_CUDA_HAS_D3D +#ifdef G_OS_WIN32 /* cudaD3D11.h */ LOAD_SYMBOL (cuGraphicsD3D11RegisterResource, CuGraphicsD3D11RegisterResource); @@ -590,10 +592,10 @@ CuGLGetDevices (unsigned int *pCudaDeviceCount, CUdevice * pCudaDevices, } /* cudaD3D11.h */ -#ifdef GST_CUDA_HAS_D3D +#ifdef G_OS_WIN32 CUresult CUDAAPI CuGraphicsD3D11RegisterResource (CUgraphicsResource * pCudaResource, - gpointer pD3DResource, unsigned int Flags) + ID3D11Resource * pD3DResource, unsigned int Flags) { g_assert (gst_cuda_vtable.CuGraphicsD3D11RegisterResource != NULL); @@ -602,7 +604,7 @@ CuGraphicsD3D11RegisterResource (CUgraphicsResource * pCudaResource, } CUresult CUDAAPI -CuD3D11GetDevice (CUdevice * device, gpointer pAdapter) +CuD3D11GetDevice (CUdevice * device, IDXGIAdapter * pAdapter) { g_assert (gst_cuda_vtable.CuD3D11GetDevice != NULL); @@ -611,9 +613,8 @@ CuD3D11GetDevice (CUdevice * device, gpointer pAdapter) CUresult CUDAAPI CuD3D11GetDevices (unsigned int *pCudaDeviceCount, - CUdevice * pCudaDevices, - unsigned int cudaDeviceCount, - gpointer pD3D11Device, CUD3D11DeviceList deviceList) + CUdevice * pCudaDevices, unsigned int cudaDeviceCount, + ID3D11Device * pD3D11Device, CUd3d11DeviceList deviceList) { g_assert (gst_cuda_vtable.CuD3D11GetDevices != NULL); diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudautils.c b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudautils.c index 43e5974..9dfb0f7 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudautils.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudautils.c @@ -495,7 +495,7 @@ gst_cuda_graphics_resource_register_gl_buffer (GstCudaGraphicsResource * return TRUE; } -#ifdef GST_CUDA_HAS_D3D +#ifdef G_OS_WIN32 /** * gst_cuda_graphics_resource_register_d3d11_resource: (skip) * @resource a #GstCudaGraphicsResource @@ -512,7 +512,7 @@ gst_cuda_graphics_resource_register_gl_buffer (GstCudaGraphicsResource * */ gboolean gst_cuda_graphics_resource_register_d3d11_resource (GstCudaGraphicsResource * - resource, gpointer d3d11_resource, CUgraphicsRegisterFlags flags) + resource, ID3D11Resource * d3d11_resource, CUgraphicsRegisterFlags flags) { CUresult cuda_ret; diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudautils.h b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudautils.h index 8ade84d..8bccb8f 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudautils.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudautils.h @@ -162,10 +162,10 @@ gboolean gst_cuda_graphics_resource_register_gl_buffer (GstCudaGraphicsRe guint buffer, CUgraphicsRegisterFlags flags); -#ifdef GST_CUDA_HAS_D3D +#ifdef G_OS_WIN32 GST_CUDA_API gboolean gst_cuda_graphics_resource_register_d3d11_resource (GstCudaGraphicsResource * resource, - gpointer d3d11_resource, + ID3D11Resource * d3d11_resource, CUgraphicsRegisterFlags flags); #endif diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/cuda/meson.build b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/meson.build index 5c39b35..00ebdbc 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/cuda/meson.build +++ b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/meson.build @@ -23,6 +23,20 @@ if host_system not in ['windows', 'linux'] subdir_done() 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') extra_c_args = ['-DGST_USE_UNSTABLE_API'] diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/cuda/stub/cuda.h b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/stub/cuda.h index 8455a68..1d37813 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/cuda/stub/cuda.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/stub/cuda.h @@ -132,13 +132,6 @@ typedef struct gsize Height; } 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 { CUaddress_mode addressMode[3]; diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/cuda/stub/cudaD3D11.h b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/stub/cudaD3D11.h new file mode 100644 index 0000000..26c38f7 --- /dev/null +++ b/subprojects/gst-plugins-bad/gst-libs/gst/cuda/stub/cudaD3D11.h @@ -0,0 +1,14 @@ +#pragma once + +#include + +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