mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 02:01:12 +00:00
d3d12: Add support for cross-compile
... and fix bunch of GCC reported warnings Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6435>
This commit is contained in:
parent
6c80d2f5f8
commit
bbdfa00b7b
24 changed files with 177 additions and 161 deletions
|
@ -32,3 +32,4 @@
|
|||
#include "gstd3d12format.h"
|
||||
#include "gstd3d12memory.h"
|
||||
#include "gstd3d12utils.h"
|
||||
#include "gstd3d12compat.h"
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include <directx/d3d12.h>
|
||||
#include <directx/d3d12video.h>
|
||||
#include <dxguids/dxguids.h>
|
||||
#include <dxgi1_6.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
|
|
@ -31,6 +31,8 @@ G_DECLARE_FINAL_TYPE (GstD3D12CommandAllocatorPool,
|
|||
|
||||
typedef struct _GstD3D12CommandAllocator GstD3D12CommandAllocator;
|
||||
|
||||
GType gst_d3d12_command_allocator_get_type (void);
|
||||
|
||||
GstD3D12CommandAllocatorPool * gst_d3d12_command_allocator_pool_new (ID3D12Device * device,
|
||||
D3D12_COMMAND_LIST_TYPE type);
|
||||
|
||||
|
|
|
@ -31,6 +31,8 @@ G_DECLARE_FINAL_TYPE (GstD3D12CommandListPool,
|
|||
|
||||
typedef struct _GstD3D12CommandList GstD3D12CommandList;
|
||||
|
||||
GType gst_d3d12_command_list_get_type (void);
|
||||
|
||||
GstD3D12CommandListPool * gst_d3d12_command_list_pool_new (ID3D12Device * device,
|
||||
D3D12_COMMAND_LIST_TYPE type);
|
||||
|
||||
|
|
64
subprojects/gst-plugins-bad/sys/d3d12/gstd3d12compat.h
Normal file
64
subprojects/gst-plugins-bad/sys/d3d12/gstd3d12compat.h
Normal file
|
@ -0,0 +1,64 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2024 Seungha Yang <seungha@centricular.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include "gstd3d12_fwd.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
template <typename T>
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE
|
||||
GetCPUDescriptorHandleForHeapStart (T heap)
|
||||
{
|
||||
#if defined(_MSC_VER) || !defined(_WIN32)
|
||||
return heap->GetCPUDescriptorHandleForHeapStart ();
|
||||
#else
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE handle;
|
||||
heap->GetCPUDescriptorHandleForHeapStart (&handle);
|
||||
return handle;
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE
|
||||
GetGPUDescriptorHandleForHeapStart (T heap)
|
||||
{
|
||||
#if defined(_MSC_VER) || !defined(_WIN32)
|
||||
return heap->GetGPUDescriptorHandleForHeapStart ();
|
||||
#else
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE handle;
|
||||
heap->GetGPUDescriptorHandleForHeapStart (&handle);
|
||||
return handle;
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
D3D12_RESOURCE_DESC
|
||||
GetDesc (T resource)
|
||||
{
|
||||
#if defined(_MSC_VER) || !defined(_WIN32)
|
||||
return resource->GetDesc ();
|
||||
#else
|
||||
D3D12_RESOURCE_DESC desc;
|
||||
resource->GetDesc (&desc);
|
||||
return desc;
|
||||
#endif
|
||||
}
|
||||
#endif /* __cplusplus */
|
|
@ -2211,8 +2211,8 @@ gst_d3d12_compositor_draw_background (GstD3D12Compositor * self)
|
|||
}
|
||||
|
||||
auto cpu_handle =
|
||||
CD3DX12_CPU_DESCRIPTOR_HANDLE
|
||||
(rtv_heap->GetCPUDescriptorHandleForHeapStart ());
|
||||
CD3DX12_CPU_DESCRIPTOR_HANDLE (GetCPUDescriptorHandleForHeapStart
|
||||
(rtv_heap));
|
||||
|
||||
for (guint plane = 0; plane < num_planes; plane++) {
|
||||
D3D12_RECT rect = { };
|
||||
|
|
|
@ -502,87 +502,6 @@ gst_d3d12_convert_stop (GstBaseTransform * trans)
|
|||
return GST_BASE_TRANSFORM_CLASS (parent_class)->stop (trans);
|
||||
}
|
||||
|
||||
/* copies the given caps */
|
||||
static GstCaps *
|
||||
gst_d3d12_convert_caps_remove_format_info (GstCaps * caps)
|
||||
{
|
||||
GstStructure *st;
|
||||
GstCapsFeatures *f;
|
||||
gint i, n;
|
||||
GstCaps *res;
|
||||
GstCapsFeatures *feature =
|
||||
gst_caps_features_from_string (GST_CAPS_FEATURE_MEMORY_D3D12_MEMORY);
|
||||
|
||||
res = gst_caps_new_empty ();
|
||||
|
||||
n = gst_caps_get_size (caps);
|
||||
for (i = 0; i < n; i++) {
|
||||
st = gst_caps_get_structure (caps, i);
|
||||
f = gst_caps_get_features (caps, i);
|
||||
|
||||
/* If this is already expressed by the existing caps
|
||||
* skip this structure */
|
||||
if (i > 0 && gst_caps_is_subset_structure_full (res, st, f))
|
||||
continue;
|
||||
|
||||
st = gst_structure_copy (st);
|
||||
/* Only remove format info for the cases when we can actually convert */
|
||||
if (!gst_caps_features_is_any (f)
|
||||
&& gst_caps_features_is_equal (f, feature)) {
|
||||
gst_structure_remove_fields (st, "format", "colorimetry", "chroma-site",
|
||||
nullptr);
|
||||
}
|
||||
|
||||
gst_caps_append_structure_full (res, st, gst_caps_features_copy (f));
|
||||
}
|
||||
gst_caps_features_free (feature);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static GstCaps *
|
||||
gst_d3d12_convert_caps_rangify_size_info (GstCaps * caps)
|
||||
{
|
||||
GstStructure *st;
|
||||
GstCapsFeatures *f;
|
||||
gint i, n;
|
||||
GstCaps *res;
|
||||
GstCapsFeatures *feature =
|
||||
gst_caps_features_from_string (GST_CAPS_FEATURE_MEMORY_D3D12_MEMORY);
|
||||
|
||||
res = gst_caps_new_empty ();
|
||||
|
||||
n = gst_caps_get_size (caps);
|
||||
for (i = 0; i < n; i++) {
|
||||
st = gst_caps_get_structure (caps, i);
|
||||
f = gst_caps_get_features (caps, i);
|
||||
|
||||
/* If this is already expressed by the existing caps
|
||||
* skip this structure */
|
||||
if (i > 0 && gst_caps_is_subset_structure_full (res, st, f))
|
||||
continue;
|
||||
|
||||
st = gst_structure_copy (st);
|
||||
/* Only remove format info for the cases when we can actually convert */
|
||||
if (!gst_caps_features_is_any (f)
|
||||
&& gst_caps_features_is_equal (f, feature)) {
|
||||
gst_structure_set (st, "width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
|
||||
"height", GST_TYPE_INT_RANGE, 1, G_MAXINT, nullptr);
|
||||
|
||||
/* if pixel aspect ratio, make a range of it */
|
||||
if (gst_structure_has_field (st, "pixel-aspect-ratio")) {
|
||||
gst_structure_set (st, "pixel-aspect-ratio",
|
||||
GST_TYPE_FRACTION_RANGE, 1, G_MAXINT, G_MAXINT, 1, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
gst_caps_append_structure_full (res, st, gst_caps_features_copy (f));
|
||||
}
|
||||
gst_caps_features_free (feature);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static GstCaps *
|
||||
gst_d3d12_convert_caps_remove_format_and_rangify_size_info (GstCaps * caps)
|
||||
{
|
||||
|
|
|
@ -919,8 +919,8 @@ gst_d3d12_converter_setup_resource (GstD3D12Converter * self,
|
|||
}
|
||||
|
||||
auto cpu_handle =
|
||||
CD3DX12_CPU_DESCRIPTOR_HANDLE
|
||||
(priv->gamma_lut_heap->GetCPUDescriptorHandleForHeapStart ());
|
||||
CD3DX12_CPU_DESCRIPTOR_HANDLE (GetCPUDescriptorHandleForHeapStart
|
||||
(priv->gamma_lut_heap));
|
||||
|
||||
D3D12_SHADER_RESOURCE_VIEW_DESC srv_desc = { };
|
||||
srv_desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE1D;
|
||||
|
@ -1819,7 +1819,7 @@ gst_d3d12_converter_execute (GstD3D12Converter * self,
|
|||
std::lock_guard < std::mutex > lk (priv->prop_lock);
|
||||
auto mem = (GstD3D12Memory *) gst_buffer_peek_memory (in_buf, 0);
|
||||
auto resource = gst_d3d12_memory_get_resource_handle (mem);
|
||||
auto desc = resource->GetDesc ();
|
||||
auto desc = GetDesc (resource);
|
||||
if (desc.Width != priv->input_texture_width ||
|
||||
desc.Height != priv->input_texture_height) {
|
||||
GST_DEBUG_OBJECT (self, "Texture resolution changed %ux%u -> %ux%u",
|
||||
|
@ -1832,7 +1832,7 @@ gst_d3d12_converter_execute (GstD3D12Converter * self,
|
|||
|
||||
mem = (GstD3D12Memory *) gst_buffer_peek_memory (out_buf, 0);
|
||||
resource = gst_d3d12_memory_get_resource_handle (mem);
|
||||
desc = resource->GetDesc ();
|
||||
desc = GetDesc (resource);
|
||||
if (desc.SampleDesc.Count != priv->sample_desc.Count ||
|
||||
desc.SampleDesc.Quality != priv->sample_desc.Quality) {
|
||||
GST_DEBUG_OBJECT (self, "Sample desc updated");
|
||||
|
@ -1955,8 +1955,8 @@ gst_d3d12_converter_execute (GstD3D12Converter * self,
|
|||
gst_d3d12_fence_data_add_notify_mini_object (fence_data, descriptor);
|
||||
|
||||
auto cpu_handle =
|
||||
CD3DX12_CPU_DESCRIPTOR_HANDLE
|
||||
(srv_heap->GetCPUDescriptorHandleForHeapStart ());
|
||||
CD3DX12_CPU_DESCRIPTOR_HANDLE (GetCPUDescriptorHandleForHeapStart
|
||||
(srv_heap));
|
||||
|
||||
for (guint i = 0; i < gst_buffer_n_memory (in_buf); i++) {
|
||||
auto mem = (GstD3D12Memory *) gst_buffer_peek_memory (in_buf, i);
|
||||
|
@ -1969,14 +1969,14 @@ gst_d3d12_converter_execute (GstD3D12Converter * self,
|
|||
}
|
||||
|
||||
device->CopyDescriptorsSimple (num_planes, cpu_handle,
|
||||
mem_srv_heap->GetCPUDescriptorHandleForHeapStart (),
|
||||
GetCPUDescriptorHandleForHeapStart (mem_srv_heap),
|
||||
D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
|
||||
cpu_handle.Offset (num_planes, priv->srv_inc_size);
|
||||
}
|
||||
|
||||
if (priv->crs->HaveLut ()) {
|
||||
device->CopyDescriptorsSimple (2, cpu_handle,
|
||||
priv->gamma_lut_heap->GetCPUDescriptorHandleForHeapStart (),
|
||||
GetCPUDescriptorHandleForHeapStart (priv->gamma_lut_heap),
|
||||
D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
|
||||
}
|
||||
|
||||
|
@ -1991,8 +1991,8 @@ gst_d3d12_converter_execute (GstD3D12Converter * self,
|
|||
}
|
||||
|
||||
auto cpu_handle =
|
||||
CD3DX12_CPU_DESCRIPTOR_HANDLE
|
||||
(rtv_heap->GetCPUDescriptorHandleForHeapStart ());
|
||||
CD3DX12_CPU_DESCRIPTOR_HANDLE (GetCPUDescriptorHandleForHeapStart
|
||||
(rtv_heap));
|
||||
|
||||
for (guint plane = 0; plane < num_planes; plane++) {
|
||||
D3D12_RECT rect = { };
|
||||
|
@ -2021,7 +2021,7 @@ gst_d3d12_converter_execute (GstD3D12Converter * self,
|
|||
ID3D12DescriptorHeap *heaps[] = { srv_heap.Get () };
|
||||
cl->SetDescriptorHeaps (1, heaps);
|
||||
cl->SetGraphicsRootDescriptorTable (priv->crs->GetPsSrvIdx (),
|
||||
srv_heap->GetGPUDescriptorHandleForHeapStart ());
|
||||
GetGPUDescriptorHandleForHeapStart (srv_heap));
|
||||
cl->SetGraphicsRoot32BitConstants (priv->crs->GetVsRootConstIdx (),
|
||||
16, &priv->transform, 0);
|
||||
cl->SetGraphicsRoot32BitConstants (priv->crs->GetPsRootConstIdx (),
|
||||
|
@ -2196,7 +2196,7 @@ gst_d3d12_converter_check_needs_upload (GstD3D12Converter * self,
|
|||
return TRUE;
|
||||
|
||||
auto resource = gst_d3d12_memory_get_resource_handle (dmem);
|
||||
auto desc = resource->GetDesc ();
|
||||
auto desc = GetDesc (resource);
|
||||
if ((desc.Flags & D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE) ==
|
||||
D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE) {
|
||||
return TRUE;
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <wrl.h>
|
||||
#include <string.h>
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
|
|
|
@ -31,6 +31,8 @@ G_DECLARE_FINAL_TYPE (GstD3D12DescriptorPool,
|
|||
|
||||
typedef struct _GstD3D12Descriptor GstD3D12Descriptor;
|
||||
|
||||
GType gst_d3d12_descriptor_get_type (void);
|
||||
|
||||
GstD3D12DescriptorPool * gst_d3d12_descriptor_pool_new (ID3D12Device * device,
|
||||
const D3D12_DESCRIPTOR_HEAP_DESC * desc);
|
||||
|
||||
|
|
|
@ -253,7 +253,7 @@ public:
|
|||
return device;
|
||||
}
|
||||
|
||||
void ReleaseDevice (guint64 luid)
|
||||
void ReleaseDevice (gint64 luid)
|
||||
{
|
||||
std::lock_guard <std::mutex> lk (lock_);
|
||||
for (const auto & it : list_) {
|
||||
|
@ -399,7 +399,7 @@ gst_d3d12_device_finalize (GObject * object)
|
|||
|
||||
GST_DEBUG_OBJECT (self, "Finalize");
|
||||
|
||||
guint64 luid = 0;
|
||||
gint64 luid = 0;
|
||||
if (self->priv->inner)
|
||||
luid = self->priv->inner->adapter_luid;
|
||||
|
||||
|
@ -1187,7 +1187,7 @@ gst_d3d12_device_clear_yuv_texture (GstD3D12Device * device, GstMemory * mem)
|
|||
ComPtr < ID3D12DescriptorHeap > heap;
|
||||
|
||||
auto resource = gst_d3d12_memory_get_resource_handle (dmem);
|
||||
auto desc = resource->GetDesc ();
|
||||
auto desc = GetDesc (resource);
|
||||
|
||||
if (desc.Format != DXGI_FORMAT_NV12 && desc.Format != DXGI_FORMAT_P010 &&
|
||||
desc.Format != DXGI_FORMAT_P016) {
|
||||
|
@ -1225,8 +1225,7 @@ gst_d3d12_device_clear_yuv_texture (GstD3D12Device * device, GstMemory * mem)
|
|||
cl_base.As (&cl);
|
||||
|
||||
auto rtv_handle =
|
||||
CD3DX12_CPU_DESCRIPTOR_HANDLE (heap->GetCPUDescriptorHandleForHeapStart
|
||||
(),
|
||||
CD3DX12_CPU_DESCRIPTOR_HANDLE (GetCPUDescriptorHandleForHeapStart (heap),
|
||||
priv->rtv_inc_size);
|
||||
|
||||
const FLOAT clear_color[4] = { 0.5f, 0.5f, 0.5f, 1.0f };
|
||||
|
|
|
@ -75,15 +75,6 @@ static GList *g_dupl_list = nullptr;
|
|||
* https://github.com/microsoft/Windows-classic-samples/tree/master/Samples/DXGIDesktopDuplication
|
||||
*/
|
||||
|
||||
/* List of expected error cases */
|
||||
/* These are the errors we expect from general Dxgi API due to a transition */
|
||||
static HRESULT SystemTransitionsExpectedErrors[] = {
|
||||
DXGI_ERROR_DEVICE_REMOVED,
|
||||
DXGI_ERROR_ACCESS_LOST,
|
||||
static_cast<HRESULT>(WAIT_ABANDONED),
|
||||
S_OK
|
||||
};
|
||||
|
||||
/* These are the errors we expect from IDXGIOutput1::DuplicateOutput
|
||||
* due to a transition */
|
||||
static HRESULT CreateDuplicationExpectedErrors[] = {
|
||||
|
@ -758,10 +749,7 @@ struct _GstD3D12DxgiCapture
|
|||
GstD3D12DxgiCapturePrivate *priv;
|
||||
};
|
||||
|
||||
static void gst_d3d12_dxgi_capture_dispose (GObject * object);
|
||||
static void gst_d3d12_dxgi_capture_finalize (GObject * object);
|
||||
static void gst_d3d12_dxgi_capture_set_property (GObject * object,
|
||||
guint prop_id, const GValue * value, GParamSpec * pspec);
|
||||
static GstFlowReturn
|
||||
gst_d3d12_dxgi_capture_prepare (GstD3D12ScreenCapture * capture);
|
||||
static gboolean
|
||||
|
@ -1154,7 +1142,7 @@ gst_d3d12_dxgi_capture_prepare_unlocked (GstD3D12DxgiCapture * self)
|
|||
rtv_desc.Texture2D.PlaneSlice = 0;
|
||||
|
||||
device->CreateRenderTargetView (processed_frame.Get (), &rtv_desc,
|
||||
priv->rtv_heap->GetCPUDescriptorHandleForHeapStart ());
|
||||
GetCPUDescriptorHandleForHeapStart (priv->rtv_heap));
|
||||
|
||||
priv->ctx = std::move (ctx);
|
||||
priv->processed_frame = processed_frame;
|
||||
|
@ -1217,7 +1205,7 @@ gst_d3d12_dxgi_capture_copy_move_rects (GstD3D12DxgiCapture * self,
|
|||
if (!priv->move_frame) {
|
||||
D3D12_HEAP_PROPERTIES heap_prop =
|
||||
CD3DX12_HEAP_PROPERTIES (D3D12_HEAP_TYPE_DEFAULT);
|
||||
D3D12_RESOURCE_DESC resource_desc = priv->processed_frame->GetDesc ();
|
||||
D3D12_RESOURCE_DESC resource_desc = GetDesc (priv->processed_frame);
|
||||
resource_desc.Flags = D3D12_RESOURCE_FLAG_NONE;
|
||||
hr = device->CreateCommittedResource (&heap_prop,
|
||||
D3D12_HEAP_FLAG_NONE, &resource_desc, D3D12_RESOURCE_STATE_COPY_DEST,
|
||||
|
@ -1309,7 +1297,7 @@ gst_d3d12_dxgi_capture_copy_dirty_rects (GstD3D12DxgiCapture * self,
|
|||
srv_desc.Texture2D.MipLevels = 1;
|
||||
|
||||
device->CreateShaderResourceView (priv->shared_resource.Get (), &srv_desc,
|
||||
priv->srv_heap->GetCPUDescriptorHandleForHeapStart ());
|
||||
GetCPUDescriptorHandleForHeapStart (priv->srv_heap));
|
||||
}
|
||||
|
||||
auto desc = priv->ctx->GetDesc ();
|
||||
|
@ -1353,7 +1341,7 @@ gst_d3d12_dxgi_capture_copy_dirty_rects (GstD3D12DxgiCapture * self,
|
|||
cl->RSSetViewports (1, &priv->viewport);
|
||||
cl->RSSetScissorRects (1, &priv->scissor_rect);
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE rtv_heaps[] = {
|
||||
priv->rtv_heap->GetCPUDescriptorHandleForHeapStart ()
|
||||
GetCPUDescriptorHandleForHeapStart (priv->rtv_heap)
|
||||
};
|
||||
|
||||
cl->OMSetRenderTargets (1, rtv_heaps, FALSE, nullptr);
|
||||
|
@ -1398,7 +1386,7 @@ gst_d3d12_dxgi_capture_copy_dirty_rects (GstD3D12DxgiCapture * self,
|
|||
ID3D12DescriptorHeap *heaps[] = { priv->srv_heap.Get () };
|
||||
cl->SetDescriptorHeaps (1, heaps);
|
||||
cl->SetGraphicsRootDescriptorTable (0,
|
||||
priv->srv_heap->GetGPUDescriptorHandleForHeapStart ());
|
||||
GetGPUDescriptorHandleForHeapStart (priv->srv_heap));
|
||||
cl->IASetVertexBuffers (0, 1, &vbv);
|
||||
cl->DrawInstanced (vertex.size (), 1, 0, 0);
|
||||
|
||||
|
@ -1423,10 +1411,14 @@ gst_d3d12_dxgi_capture_draw_mouse (GstD3D12DxgiCapture * self,
|
|||
if (!info.width_ || !info.height_)
|
||||
return TRUE;
|
||||
|
||||
if (info.position_info.Position.x + info.width_ < crop_box->left ||
|
||||
info.position_info.Position.x > crop_box->right ||
|
||||
info.position_info.Position.y + info.height_ < crop_box->top ||
|
||||
info.position_info.Position.y > crop_box->bottom) {
|
||||
if (static_cast < INT > (info.position_info.Position.x + info.width_) <
|
||||
static_cast < INT > (crop_box->left) ||
|
||||
static_cast < INT > (info.position_info.Position.x) >
|
||||
static_cast < INT > (crop_box->right) ||
|
||||
static_cast < INT > (info.position_info.Position.y + info.height_) <
|
||||
static_cast < INT > (crop_box->top) ||
|
||||
static_cast < INT > (info.position_info.Position.y) >
|
||||
static_cast < INT > (crop_box->bottom)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -143,8 +143,6 @@ struct GstD3D12EncoderPrivate
|
|||
/* *INDENT-ON* */
|
||||
|
||||
static void gst_d3d12_encoder_finalize (GObject * object);
|
||||
static void gst_d3d12_encoder_set_property (GObject * object, guint prop_id,
|
||||
const GValue * value, GParamSpec * pspec);
|
||||
static void gst_d3d12_encoder_get_property (GObject * object, guint prop_id,
|
||||
GValue * value, GParamSpec * pspec);
|
||||
|
||||
|
@ -715,7 +713,7 @@ gst_d3d12_encoder_upload_frame (GstD3D12Encoder * self, GstBuffer * buffer)
|
|||
gst_memory_unmap (mem, &map_info);
|
||||
|
||||
auto resource = gst_d3d12_memory_get_resource_handle (dmem);
|
||||
auto desc = resource->GetDesc ();
|
||||
auto desc = GetDesc (resource);
|
||||
if (desc.Width >= (UINT64) priv->config.resolution.Width &&
|
||||
desc.Height >= priv->config.resolution.Height) {
|
||||
return gst_buffer_ref (buffer);
|
||||
|
@ -739,7 +737,7 @@ gst_d3d12_encoder_upload_frame (GstD3D12Encoder * self, GstBuffer * buffer)
|
|||
auto dst_resource = gst_d3d12_memory_get_resource_handle (dmem);
|
||||
D3D12_BOX src_box[2];
|
||||
|
||||
auto desc = src_resource->GetDesc ();
|
||||
auto desc = GetDesc (src_resource);
|
||||
|
||||
UINT width = MIN ((UINT) desc.Width, priv->config.resolution.Width);
|
||||
UINT height = MIN ((UINT) desc.Height, priv->config.resolution.Height);
|
||||
|
@ -803,7 +801,7 @@ gst_d3d12_encoder_upload_frame (GstD3D12Encoder * self, GstBuffer * buffer)
|
|||
auto src_data = (guint8 *) GST_VIDEO_FRAME_PLANE_DATA (&src_frame, i);
|
||||
auto dst_data = (guint8 *) GST_VIDEO_FRAME_PLANE_DATA (&dst_frame, i);
|
||||
|
||||
for (guint j = 0; j < height; j++) {
|
||||
for (gint j = 0; j < height; j++) {
|
||||
memcpy (dst_data, src_data, width_in_bytes);
|
||||
dst_data += dst_stride;
|
||||
src_data += src_stride;
|
||||
|
@ -872,7 +870,7 @@ gst_d3d12_encoder_build_command (GstD3D12Encoder * self,
|
|||
in_args->PictureControlDesc.ReferenceFrames.ppTexture2Ds[0];
|
||||
ref_pic->AddRef ();
|
||||
gst_d3d12_fence_data_add_notify_com (fence_data, ref_pic);
|
||||
auto ref_pic_desc = ref_pic->GetDesc ();
|
||||
auto ref_pic_desc = GetDesc (ref_pic);
|
||||
|
||||
for (UINT i = 0;
|
||||
i < in_args->PictureControlDesc.ReferenceFrames.NumTexture2Ds; i++) {
|
||||
|
@ -915,7 +913,7 @@ gst_d3d12_encoder_build_command (GstD3D12Encoder * self,
|
|||
D3D12_RESOURCE_STATE_COMMON));
|
||||
} else {
|
||||
auto recon_pic_desc =
|
||||
out_args->ReconstructedPicture.pReconstructedPicture->GetDesc ();
|
||||
GetDesc (out_args->ReconstructedPicture.pReconstructedPicture);
|
||||
UINT mip_slice, plane_slice, array_slice;
|
||||
|
||||
D3D12DecomposeSubresource (out_args->
|
||||
|
|
|
@ -31,6 +31,8 @@ G_DECLARE_FINAL_TYPE (GstD3D12EncoderBufferPool,
|
|||
|
||||
typedef struct _GstD3D12EncoderBuffer GstD3D12EncoderBuffer;
|
||||
|
||||
GType gst_d3d12_encoder_buffer_get_type (void);
|
||||
|
||||
GstD3D12EncoderBufferPool * gst_d3d12_encoder_buffer_pool_new (GstD3D12Device * device,
|
||||
guint metadata_size,
|
||||
guint resolved_metadata_size,
|
||||
|
|
|
@ -29,6 +29,8 @@ G_BEGIN_DECLS
|
|||
G_DECLARE_FINAL_TYPE (GstD3D12FenceDataPool,
|
||||
gst_d3d12_fence_data_pool, GST, D3D12_FENCE_DATA_POOL, GstObject);
|
||||
|
||||
GType gst_d3d12_fence_data_get_type (void);
|
||||
|
||||
GstD3D12FenceDataPool * gst_d3d12_fence_data_pool_new (void);
|
||||
|
||||
gboolean gst_d3d12_fence_data_pool_acquire (GstD3D12FenceDataPool * pool,
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include <condition_variable>
|
||||
#include <unordered_map>
|
||||
#include <memory>
|
||||
#include <algorithm>
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
using namespace Microsoft::WRL;
|
||||
|
@ -1243,7 +1244,7 @@ gst_d3d12_h264_enc_build_pps (GstD3D12H264Enc * self, guint num_ref)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static guint
|
||||
gst_d3d12_h264_enc_get_max_ref_frames (GstD3D12H264Enc * self)
|
||||
{
|
||||
auto priv = self->priv;
|
||||
|
@ -2350,8 +2351,8 @@ gst_d3d12_h264_enc_register (GstPlugin * plugin, GstD3D12Device * device,
|
|||
return;
|
||||
}
|
||||
|
||||
if (slice_mode_support & (1 <<
|
||||
D3D12_VIDEO_ENCODER_FRAME_SUBREGION_LAYOUT_MODE_FULL_FRAME)
|
||||
if ((slice_mode_support & (1 <<
|
||||
D3D12_VIDEO_ENCODER_FRAME_SUBREGION_LAYOUT_MODE_FULL_FRAME))
|
||||
== 0) {
|
||||
GST_WARNING_OBJECT (device, "Full frame encoding is not supported");
|
||||
return;
|
||||
|
|
|
@ -520,7 +520,7 @@ gst_d3d12_ipc_upload (GstD3D12IpcSink * self, GstBuffer * buf)
|
|||
D3D12_HEAP_FLAGS heap_flags = D3D12_HEAP_FLAG_NONE;
|
||||
|
||||
auto resource = gst_d3d12_memory_get_resource_handle (dmem);
|
||||
desc = resource->GetDesc ();
|
||||
desc = GetDesc (resource);
|
||||
resource->GetHeapProperties (nullptr, &heap_flags);
|
||||
if ((desc.Flags & D3D12_RESOURCE_FLAG_ALLOW_SIMULTANEOUS_ACCESS) != 0 &&
|
||||
(heap_flags & D3D12_HEAP_FLAG_SHARED) != 0) {
|
||||
|
|
|
@ -324,7 +324,7 @@ gst_d3d12_memory_set_external_fence_unlocked (GstD3D12Memory * dmem,
|
|||
}
|
||||
|
||||
priv->external_fence = nullptr;
|
||||
priv->external_fence_val;
|
||||
priv->external_fence_val = 0;
|
||||
}
|
||||
|
||||
if (fence) {
|
||||
|
@ -615,8 +615,8 @@ gst_d3d12_memory_get_shader_resource_view_heap (GstD3D12Memory * mem,
|
|||
srv_desc.Texture2D.MipLevels = 1;
|
||||
|
||||
auto cpu_handle =
|
||||
CD3DX12_CPU_DESCRIPTOR_HANDLE
|
||||
(srv_heap->GetCPUDescriptorHandleForHeapStart ());
|
||||
CD3DX12_CPU_DESCRIPTOR_HANDLE (GetCPUDescriptorHandleForHeapStart
|
||||
(srv_heap));
|
||||
|
||||
for (guint i = 0; i < priv->num_subresources; i++) {
|
||||
srv_desc.Format = priv->resource_formats[i];
|
||||
|
@ -670,8 +670,8 @@ gst_d3d12_memory_get_render_target_view_heap (GstD3D12Memory * mem,
|
|||
rtv_desc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2DMS;
|
||||
|
||||
auto cpu_handle =
|
||||
CD3DX12_CPU_DESCRIPTOR_HANDLE
|
||||
(rtv_heap->GetCPUDescriptorHandleForHeapStart ());
|
||||
CD3DX12_CPU_DESCRIPTOR_HANDLE (GetCPUDescriptorHandleForHeapStart
|
||||
(rtv_heap));
|
||||
|
||||
for (guint i = 0; i < priv->num_subresources; i++) {
|
||||
rtv_desc.Format = priv->resource_formats[i];
|
||||
|
@ -830,7 +830,7 @@ gst_d3d12_allocator_alloc_wrapped (GstD3D12Allocator * allocator,
|
|||
}
|
||||
|
||||
auto device_handle = gst_d3d12_device_get_device_handle (device);
|
||||
auto desc = resource->GetDesc ();
|
||||
auto desc = GetDesc (resource);
|
||||
guint8 num_subresources =
|
||||
D3D12GetFormatPlaneCount (device_handle, desc.Format);
|
||||
|
||||
|
|
|
@ -347,7 +347,7 @@ gst_d3d12_overlay_rect_new (GstD3D12OverlayCompositor * self,
|
|||
srv_desc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||
|
||||
device->CreateShaderResourceView (texture.Get (), &srv_desc,
|
||||
srv_heap_handle->GetCPUDescriptorHandleForHeapStart ());
|
||||
GetCPUDescriptorHandleForHeapStart (srv_heap_handle));
|
||||
|
||||
auto rect = new GstD3D12OverlayRect ();
|
||||
gst_mini_object_init (rect, 0, gst_d3d12_overlay_rect_get_type (),
|
||||
|
@ -758,7 +758,7 @@ gst_d3d12_overlay_compositor_execute (GstD3D12OverlayCompositor * self,
|
|||
cl->RSSetViewports (1, &priv->viewport);
|
||||
cl->RSSetScissorRects (1, &priv->scissor_rect);
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE rtv_heaps[] = {
|
||||
rtv_heap->GetCPUDescriptorHandleForHeapStart ()
|
||||
GetCPUDescriptorHandleForHeapStart (rtv_heap)
|
||||
};
|
||||
cl->OMSetRenderTargets (1, rtv_heaps, FALSE, nullptr);
|
||||
} else if (pso != prev_pso) {
|
||||
|
@ -770,7 +770,7 @@ gst_d3d12_overlay_compositor_execute (GstD3D12OverlayCompositor * self,
|
|||
ID3D12DescriptorHeap *heaps[] = { srv_heap.Get () };
|
||||
cl->SetDescriptorHeaps (1, heaps);
|
||||
cl->SetGraphicsRootDescriptorTable (0,
|
||||
srv_heap->GetGPUDescriptorHandleForHeapStart ());
|
||||
GetGPUDescriptorHandleForHeapStart (srv_heap));
|
||||
cl->IASetVertexBuffers (0, 1, &rect->vbv);
|
||||
|
||||
cl->DrawIndexedInstanced (6, 1, 0, 0, 0);
|
||||
|
@ -808,7 +808,7 @@ gst_d3d12_overlay_compositor_draw (GstD3D12OverlayCompositor * compositor,
|
|||
|
||||
auto mem = (GstD3D12Memory *) gst_buffer_peek_memory (buf, 0);
|
||||
auto resource = gst_d3d12_memory_get_resource_handle (mem);
|
||||
auto desc = resource->GetDesc ();
|
||||
auto desc = GetDesc (resource);
|
||||
if (desc.SampleDesc.Count != priv->sample_desc.Count ||
|
||||
desc.SampleDesc.Quality != priv->sample_desc.Quality) {
|
||||
auto device = gst_d3d12_device_get_device_handle (compositor->device);
|
||||
|
|
|
@ -29,6 +29,8 @@ G_BEGIN_DECLS
|
|||
G_DECLARE_FINAL_TYPE (GstD3D12OverlayCompositor, gst_d3d12_overlay_compositor,
|
||||
GST, D3D12_OVERLAY_COMPOSITOR, GstObject)
|
||||
|
||||
GType gst_d3d12_overlay_rect_get_type (void);
|
||||
|
||||
GstD3D12OverlayCompositor * gst_d3d12_overlay_compositor_new (GstD3D12Device * device,
|
||||
const GstVideoInfo * info);
|
||||
|
||||
|
|
|
@ -211,7 +211,7 @@ gst_d3d12_buffer_copy_into (GstBuffer * dst, GstBuffer * src,
|
|||
std::vector < GstD3D12CopyTextureRegionArgs > copy_args;
|
||||
D3D12_BOX src_box[4];
|
||||
guint resource_idx = 0;
|
||||
GstD3D12Device *device;
|
||||
GstD3D12Device *device = nullptr;
|
||||
|
||||
for (guint i = 0; i < num_mem; i++) {
|
||||
auto dst_mem = gst_buffer_peek_memory (dst, i);
|
||||
|
@ -276,6 +276,8 @@ gst_d3d12_buffer_copy_into (GstBuffer * dst, GstBuffer * src,
|
|||
}
|
||||
}
|
||||
|
||||
g_assert (device);
|
||||
|
||||
guint64 fence_val;
|
||||
if (!gst_d3d12_device_copy_texture_region (device, copy_args.size (),
|
||||
copy_args.data (), D3D12_COMMAND_LIST_TYPE_DIRECT, &fence_val)) {
|
||||
|
|
|
@ -2062,20 +2062,18 @@ gst_d3d12_test_src_draw_pattern (GstD3D12TestSrc * self, GstClockTime pts,
|
|||
|
||||
if (ctx->static_color[0].is_valid) {
|
||||
if (ctx->static_color[1].is_valid && (priv->n_frames % 2) == 1) {
|
||||
cl->ClearRenderTargetView (ctx->
|
||||
rtv_heap->GetCPUDescriptorHandleForHeapStart (),
|
||||
ctx->static_color[1].value.color, 0, nullptr);
|
||||
cl->ClearRenderTargetView (GetCPUDescriptorHandleForHeapStart
|
||||
(ctx->rtv_heap), ctx->static_color[1].value.color, 0, nullptr);
|
||||
} else {
|
||||
cl->ClearRenderTargetView (ctx->
|
||||
rtv_heap->GetCPUDescriptorHandleForHeapStart (),
|
||||
ctx->static_color[0].value.color, 0, nullptr);
|
||||
cl->ClearRenderTargetView (GetCPUDescriptorHandleForHeapStart
|
||||
(ctx->rtv_heap), ctx->static_color[0].value.color, 0, nullptr);
|
||||
}
|
||||
} else {
|
||||
cl->IASetPrimitiveTopology (D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||
cl->RSSetViewports (1, &ctx->viewport);
|
||||
cl->RSSetScissorRects (1, &ctx->scissor_rect);
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE rtv_heaps[] = {
|
||||
priv->ctx->rtv_heap->GetCPUDescriptorHandleForHeapStart ()
|
||||
GetCPUDescriptorHandleForHeapStart (priv->ctx->rtv_heap)
|
||||
};
|
||||
cl->OMSetRenderTargets (1, rtv_heaps, FALSE, nullptr);
|
||||
|
||||
|
|
|
@ -1103,7 +1103,7 @@ gst_d3d12_window_on_resize (GstD3D12Window * self)
|
|||
}
|
||||
|
||||
if (i == 0)
|
||||
priv->ctx->buffer_desc = backbuf->GetDesc ();
|
||||
priv->ctx->buffer_desc = GetDesc (backbuf);
|
||||
|
||||
auto mem = gst_d3d12_allocator_alloc_wrapped (nullptr, self->device,
|
||||
backbuf.Get (), 0, nullptr, nullptr);
|
||||
|
|
|
@ -47,10 +47,22 @@ d3d12_sources = [
|
|||
|
||||
extra_args = [
|
||||
'-DGST_USE_UNSTABLE_API',
|
||||
# Disable this warning error. Otherwise d3dx12.h will break build
|
||||
'/wd4062',
|
||||
]
|
||||
|
||||
# Disable this warning error. Otherwise d3dx12.h will break build
|
||||
if cc.get_argument_syntax() == 'msvc'
|
||||
extra_args += cc.get_supported_arguments([
|
||||
'/wd4062', # 'identifier' : unreferenced local variable
|
||||
])
|
||||
else
|
||||
extra_args += cc.get_supported_arguments([
|
||||
'-Wno-misleading-indentation',
|
||||
# MinGW 32bits compiler seems to be complaining about redundant-decls
|
||||
# when ComPtr is in use. Let's just disable the warning
|
||||
'-Wno-redundant-decls',
|
||||
])
|
||||
endif
|
||||
|
||||
extra_deps = []
|
||||
|
||||
d3d12_option = get_option('d3d12')
|
||||
|
@ -59,13 +71,6 @@ if host_system != 'windows' or d3d12_option.disabled()
|
|||
subdir_done()
|
||||
endif
|
||||
|
||||
if cc.get_id() != 'msvc'
|
||||
if d3d12_option.enabled()
|
||||
error('d3d12 plugin supports only MSVC build')
|
||||
endif
|
||||
subdir_done()
|
||||
endif
|
||||
|
||||
d3d12_lib = cc.find_library('d3d12', required : d3d12_option)
|
||||
d3d11_lib = cc.find_library('d3d11', required : d3d12_option)
|
||||
d2d_dep = cc.find_library('d2d1', required: d3d12_option)
|
||||
|
@ -110,12 +115,35 @@ if not d3d12_wgc_option.disabled()
|
|||
endif
|
||||
endif
|
||||
|
||||
have_dx_math = cxx.compiles('''
|
||||
#include <windows.h>
|
||||
#include <DirectXMath.h>
|
||||
using namespace DirectX;
|
||||
int main(int argc, char ** argv) {
|
||||
XMMATRIX matrix;
|
||||
XMFLOAT4X4 dump;
|
||||
matrix = XMMatrixIdentity ();
|
||||
XMStoreFloat4x4 (&dump, matrix);
|
||||
return 0;
|
||||
}
|
||||
''',
|
||||
name: 'DirectXMath support in Windows SDK')
|
||||
|
||||
if not have_dx_math
|
||||
directxmath_dep = dependency('directxmath',
|
||||
allow_fallback: true,
|
||||
required: d3d12_option)
|
||||
if not directxmath_dep.found()
|
||||
subdir_done()
|
||||
endif
|
||||
extra_deps += [directxmath_dep]
|
||||
endif
|
||||
|
||||
d3d12_headers = [
|
||||
'dxgi1_6.h',
|
||||
'd3d11.h',
|
||||
'd3d11on12.h',
|
||||
'd2d1.h',
|
||||
'DirectXMath.h',
|
||||
]
|
||||
|
||||
have_d3d12_headers = true
|
||||
|
|
Loading…
Reference in a new issue