From 8c3d516a14096f195a821c99a6b7f58f6d9469cd Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Thu, 24 Oct 2024 06:10:13 +0900 Subject: [PATCH] d3d12: Additional fixes for MinGW build Various fixes for GCC build, including actual bug fixes Part-of: --- .../gst-libs/gst/d3d12/gstd3d12device.cpp | 14 -------------- .../gst-libs/gst/d3d12/meson.build | 4 ++++ .../sys/d3d12/gstd3d12decoder.cpp | 4 ++-- .../sys/d3d12/gstd3d12decodercpbpool.cpp | 6 ------ .../gst-plugins-bad/sys/d3d12/gstd3d12mipgen.cpp | 2 +- .../sys/d3d12/gstd3d12pluginutils.cpp | 3 +++ .../sys/d3d12/gstd3d12testsrc.cpp | 7 ------- .../sys/d3d12/gstd3d12window-win32.cpp | 4 ++-- .../gst-plugins-bad/sys/d3d12/meson.build | 4 ++++ .../sys/nvcodec/gstcudainterop_d3d12.cpp | 16 ++++++++++------ 10 files changed, 26 insertions(+), 38 deletions(-) diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12device.cpp b/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12device.cpp index abd31fae6e..4340cf9225 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12device.cpp +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12device.cpp @@ -773,20 +773,6 @@ gst_d3d12_device_get_property (GObject * object, guint prop_id, } } -static void -make_buffer_format (GstVideoFormat format, GstD3D12Format * d3d12_format) -{ - d3d12_format->format = format; - d3d12_format->dimension = D3D12_RESOURCE_DIMENSION_BUFFER; - d3d12_format->dxgi_format = DXGI_FORMAT_UNKNOWN; - d3d12_format->support1 = D3D12_FORMAT_SUPPORT1_NONE; - d3d12_format->support2 = D3D12_FORMAT_SUPPORT2_NONE; - for (guint i = 0; i < GST_VIDEO_MAX_PLANES; i++) { - d3d12_format->resource_format[i] = DXGI_FORMAT_UNKNOWN; - d3d12_format->uav_format[i] = DXGI_FORMAT_UNKNOWN; - } -} - static void gst_d3d12_device_setup_format_table (GstD3D12Device * self) { diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/meson.build b/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/meson.build index eab0ba4b86..501037347c 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/meson.build +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/meson.build @@ -54,6 +54,10 @@ else '-Wno-redundant-decls', # include/directxmath/DirectXMathMatrix.inl:1161:16: error: variable 'aa' set but not used '-Wno-unused-but-set-variable', + # include/directx/d3dx12_pipeline_state_stream.h:28: error: ignoring '#pragma warning ' + '-Wno-unknown-pragmas', + # Various warnings in DirectX-Headers headers + '-Wno-switch', ]) endif diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12decoder.cpp b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12decoder.cpp index 5957456472..343837c2a5 100644 --- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12decoder.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12decoder.cpp @@ -947,8 +947,8 @@ gst_d3d12_decoder_new_picture_with_size (GstD3D12Decoder * decoder, return GST_FLOW_ERROR; } - if (priv->session->coded_width >= width && - priv->session->coded_height >= height) { + if (priv->session->coded_width >= (gint) width && + priv->session->coded_height >= (gint) height) { return gst_d3d12_decoder_new_picture (decoder, videodec, picture); } diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12decodercpbpool.cpp b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12decodercpbpool.cpp index 598cdef1fb..59530e9a91 100644 --- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12decodercpbpool.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12decodercpbpool.cpp @@ -113,12 +113,6 @@ struct _GstD3D12DecoderCpb : public GstMiniObject D3D12_VIDEO_DECODE_COMPRESSED_BITSTREAM bs = { }; }; -bool operator<(const std::shared_ptr & a, - const std::shared_ptr & b) -{ - return a->alloc_size_ < b->alloc_size_; -} - struct GstD3D12DecoderCpbPoolPrivate { ~GstD3D12DecoderCpbPoolPrivate () diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12mipgen.cpp b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12mipgen.cpp index 4c2f86ea8d..38b346cd3a 100644 --- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12mipgen.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12mipgen.cpp @@ -272,7 +272,7 @@ gst_d3d12_mip_gen_execute (GstD3D12MipGen * gen, ID3D12Resource * resource, srv_desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D; srv_desc.Texture2D.MipLevels = desc.MipLevels; - for (guint srcMip = 0; srcMip < desc.MipLevels - 1;) { + for (UINT16 srcMip = 0; srcMip < desc.MipLevels - 1;) { guint64 srcWidth = desc.Width >> srcMip; guint srcHeight = desc.Height >> srcMip; guint dstWidth = static_cast < guint > (srcWidth >> 1); diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12pluginutils.cpp b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12pluginutils.cpp index 890295adbb..b72d1f6488 100644 --- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12pluginutils.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12pluginutils.cpp @@ -32,6 +32,8 @@ using namespace DirectX; /* *INDENT-ON* */ +/* Enable this once we use debug print in this file */ +#if 0 #ifndef GST_DISABLE_GST_DEBUG #define GST_CAT_DEFAULT ensure_debug_category() static GstDebugCategory * @@ -46,6 +48,7 @@ ensure_debug_category (void) return cat; } #endif /* GST_DISABLE_GST_DEBUG */ +#endif GType gst_d3d12_sampling_method_get_type (void) diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12testsrc.cpp b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12testsrc.cpp index 139655d982..cee7ebd5c7 100644 --- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12testsrc.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12testsrc.cpp @@ -1188,13 +1188,6 @@ setup_d2d_render (GstD3D12TestSrc * self, RenderContext * ctx) auto priv = self->priv; HRESULT hr; - static const D3D_FEATURE_LEVEL feature_levels[] = { - D3D_FEATURE_LEVEL_12_1, - D3D_FEATURE_LEVEL_12_0, - D3D_FEATURE_LEVEL_11_1, - D3D_FEATURE_LEVEL_11_0, - }; - if (!priv->d2d_factory) { ComPtr < ID2D1Factory > d2d_factory; hr = D2D1CreateFactory (D2D1_FACTORY_TYPE_MULTI_THREADED, diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12window-win32.cpp b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12window-win32.cpp index b5d3bb091f..f1d7b9c900 100644 --- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12window-win32.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12window-win32.cpp @@ -51,12 +51,12 @@ SwapChainProxy::SwapChainProxy (GstD3D12Window * window, SIZE_T id) window_ = (GstD3D12Window *) gst_object_ref (window); id_ = id; - GST_DEBUG_OBJECT (window_, "Creating proxy %" G_GSIZE_FORMAT, id_); + GST_DEBUG_OBJECT (window_, "Creating proxy %u", (guint) id_); } SwapChainProxy::~SwapChainProxy () { - GST_DEBUG_OBJECT (window_, "Destroying proxy %" G_GSIZE_FORMAT, id_); + GST_DEBUG_OBJECT (window_, "Destroying proxy %u", (guint) id_); swapchain_ = nullptr; if (window_thread_ && hwnd_ && hwnd_ != parent_hwnd_) { diff --git a/subprojects/gst-plugins-bad/sys/d3d12/meson.build b/subprojects/gst-plugins-bad/sys/d3d12/meson.build index ab42a01fad..a4b71d46e8 100644 --- a/subprojects/gst-plugins-bad/sys/d3d12/meson.build +++ b/subprojects/gst-plugins-bad/sys/d3d12/meson.build @@ -56,6 +56,10 @@ else '-Wno-redundant-decls', # include/directxmath/DirectXMathMatrix.inl:1161:16: error: variable 'aa' set but not used '-Wno-unused-but-set-variable', + # include/directx/d3dx12_pipeline_state_stream.h:28: error: ignoring '#pragma warning ' + '-Wno-unknown-pragmas', + # Various warnings in DirectX-Headers headers + '-Wno-switch', ]) endif diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudainterop_d3d12.cpp b/subprojects/gst-plugins-bad/sys/nvcodec/gstcudainterop_d3d12.cpp index 0275459e45..4f8be3eda5 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudainterop_d3d12.cpp +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstcudainterop_d3d12.cpp @@ -576,13 +576,15 @@ gst_cuda_d3d12_interop_upload_async (GstCudaD3D12Interop * interop, src_box[i].left = 0; src_box[i].top = 0; - src_box[i].right = MIN (frame_12.plane_rect[i].right, - priv->layout[i].Footprint.Width); - src_box[i].bottom = MIN (frame_12.plane_rect[i].bottom, + src_box[i].right = MIN ((UINT) frame_12.plane_rect[i].right, + (UINT) priv->layout[i].Footprint.Width); + src_box[i].bottom = MIN ((UINT) frame_12.plane_rect[i].bottom, priv->layout[i].Footprint.Height); src_box[i].front = 0; src_box[i].back = 1; + args[i].src_box = &src_box[i]; + args[i].src.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX; args[i].src.pResource = frame_12.data[i]; args[i].src.SubresourceIndex = frame_12.subresource_index[i]; @@ -790,13 +792,15 @@ gst_cuda_d3d12_interop_download_async (GstCudaD3D12Interop * interop, for (guint i = 0; i < GST_VIDEO_INFO_N_PLANES (&priv->info); i++) { src_box[i].left = 0; src_box[i].top = 0; - src_box[i].right = MIN (frame_12.plane_rect[i].right, - priv->layout[i].Footprint.Width); - src_box[i].bottom = MIN (frame_12.plane_rect[i].bottom, + src_box[i].right = MIN ((UINT) frame_12.plane_rect[i].right, + (UINT) priv->layout[i].Footprint.Width); + src_box[i].bottom = MIN ((UINT) frame_12.plane_rect[i].bottom, priv->layout[i].Footprint.Height); src_box[i].front = 0; src_box[i].back = 1; + args[i].src_box = &src_box[i]; + args[i].src.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT; args[i].src.pResource = resource->resource.Get (); args[i].src.PlacedFootprint = priv->layout[i];