d3d12: Use d3dx12.h helper library

... and remove manually implemented helper methods

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5807>
This commit is contained in:
Seungha Yang 2023-12-14 00:50:01 +09:00
parent 38c04a5f34
commit fab1c5f953
8 changed files with 40 additions and 193 deletions

View file

@ -24,6 +24,7 @@
#include "gstd3d12device.h" #include "gstd3d12device.h"
#include "gstd3d12bufferpool.h" #include "gstd3d12bufferpool.h"
#include "gstd3d12utils.h" #include "gstd3d12utils.h"
#include <directx/d3dx12.h>
GST_DEBUG_CATEGORY_STATIC (gst_d3d12_buffer_pool_debug); GST_DEBUG_CATEGORY_STATIC (gst_d3d12_buffer_pool_debug);
#define GST_CAT_DEFAULT gst_d3d12_buffer_pool_debug #define GST_CAT_DEFAULT gst_d3d12_buffer_pool_debug
@ -125,7 +126,7 @@ gst_d3d12_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
guint align = 0; guint align = 0;
D3D12_RESOURCE_DESC *desc; D3D12_RESOURCE_DESC *desc;
D3D12_HEAP_PROPERTIES heap_props = D3D12_HEAP_PROPERTIES heap_props =
CD3D12_HEAP_PROPERTIES (D3D12_HEAP_TYPE_DEFAULT); CD3DX12_HEAP_PROPERTIES (D3D12_HEAP_TYPE_DEFAULT);
guint plane_index = 0; guint plane_index = 0;
gsize mem_size = 0; gsize mem_size = 0;

View file

@ -21,6 +21,7 @@
#include <config.h> #include <config.h>
#endif #endif
#include <directx/d3dx12.h>
#include "gstd3d12decoder.h" #include "gstd3d12decoder.h"
#include "gstd3d12device.h" #include "gstd3d12device.h"
#include "gstd3d12utils.h" #include "gstd3d12utils.h"
@ -784,8 +785,8 @@ gst_d3d12_decoder_upload_bitstream (GstD3D12Decoder * self, gpointer data,
size_t alloc_size = GST_ROUND_UP_128 (size) + 1024; size_t alloc_size = GST_ROUND_UP_128 (size) + 1024;
D3D12_HEAP_PROPERTIES heap_prop = D3D12_HEAP_PROPERTIES heap_prop =
CD3D12_HEAP_PROPERTIES (D3D12_HEAP_TYPE_UPLOAD); CD3DX12_HEAP_PROPERTIES (D3D12_HEAP_TYPE_UPLOAD);
D3D12_RESOURCE_DESC desc = CD3D12_RESOURCE_DESC::Buffer (alloc_size); D3D12_RESOURCE_DESC desc = CD3DX12_RESOURCE_DESC::Buffer (alloc_size);
hr = device_handle->CreateCommittedResource (&heap_prop, hr = device_handle->CreateCommittedResource (&heap_prop,
D3D12_HEAP_FLAG_NONE, &desc, D3D12_HEAP_FLAG_NONE, &desc,
D3D12_RESOURCE_STATE_COMMON, nullptr, IID_PPV_ARGS (&bitstream)); D3D12_RESOURCE_STATE_COMMON, nullptr, IID_PPV_ARGS (&bitstream));
@ -892,17 +893,17 @@ gst_d3d12_decoder_end_picture (GstD3D12Decoder * decoder,
gst_d3d12_memory_get_subresource_index (dmem, 0, &subresource[0]); gst_d3d12_memory_get_subresource_index (dmem, 0, &subresource[0]);
gst_d3d12_memory_get_subresource_index (dmem, 1, &subresource[1]); gst_d3d12_memory_get_subresource_index (dmem, 1, &subresource[1]);
pre_barriers.push_back (CD3D12_RESOURCE_BARRIER::Transition (resource, pre_barriers.push_back (CD3DX12_RESOURCE_BARRIER::Transition (resource,
D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_STATE_VIDEO_DECODE_READ, D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_STATE_VIDEO_DECODE_READ,
subresource[0])); subresource[0]));
pre_barriers.push_back (CD3D12_RESOURCE_BARRIER::Transition (resource, pre_barriers.push_back (CD3DX12_RESOURCE_BARRIER::Transition (resource,
D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_STATE_VIDEO_DECODE_READ, D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_STATE_VIDEO_DECODE_READ,
subresource[1])); subresource[1]));
post_barriers.push_back (CD3D12_RESOURCE_BARRIER::Transition (resource, post_barriers.push_back (CD3DX12_RESOURCE_BARRIER::Transition (resource,
D3D12_RESOURCE_STATE_VIDEO_DECODE_READ, D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_STATE_VIDEO_DECODE_READ, D3D12_RESOURCE_STATE_COMMON,
subresource[0])); subresource[0]));
post_barriers.push_back (CD3D12_RESOURCE_BARRIER::Transition (resource, post_barriers.push_back (CD3DX12_RESOURCE_BARRIER::Transition (resource,
D3D12_RESOURCE_STATE_VIDEO_DECODE_READ, D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_STATE_VIDEO_DECODE_READ, D3D12_RESOURCE_STATE_COMMON,
subresource[1])); subresource[1]));
} }
@ -912,10 +913,10 @@ gst_d3d12_decoder_end_picture (GstD3D12Decoder * decoder,
gst_buffer_peek_memory (decoder_pic->output_buffer, 0); gst_buffer_peek_memory (decoder_pic->output_buffer, 0);
out_resource = gst_d3d12_memory_get_resource_handle (dmem); out_resource = gst_d3d12_memory_get_resource_handle (dmem);
pre_barriers.push_back (CD3D12_RESOURCE_BARRIER::Transition (out_resource, pre_barriers.push_back (CD3DX12_RESOURCE_BARRIER::Transition (out_resource,
D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_STATE_COMMON,
D3D12_RESOURCE_STATE_VIDEO_DECODE_WRITE)); D3D12_RESOURCE_STATE_VIDEO_DECODE_WRITE));
post_barriers.push_back (CD3D12_RESOURCE_BARRIER::Transition (out_resource, post_barriers.push_back (CD3DX12_RESOURCE_BARRIER::Transition (out_resource,
D3D12_RESOURCE_STATE_VIDEO_DECODE_WRITE, D3D12_RESOURCE_STATE_VIDEO_DECODE_WRITE,
D3D12_RESOURCE_STATE_COMMON)); D3D12_RESOURCE_STATE_COMMON));
} }
@ -927,17 +928,17 @@ gst_d3d12_decoder_end_picture (GstD3D12Decoder * decoder,
gst_d3d12_memory_get_subresource_index (GST_D3D12_MEMORY_CAST (dmem), 1, gst_d3d12_memory_get_subresource_index (GST_D3D12_MEMORY_CAST (dmem), 1,
&subresource[1]); &subresource[1]);
pre_barriers.push_back (CD3D12_RESOURCE_BARRIER::Transition (resource, pre_barriers.push_back (CD3DX12_RESOURCE_BARRIER::Transition (resource,
D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_STATE_VIDEO_DECODE_WRITE, D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_STATE_VIDEO_DECODE_WRITE,
subresource[0])); subresource[0]));
pre_barriers.push_back (CD3D12_RESOURCE_BARRIER::Transition (resource, pre_barriers.push_back (CD3DX12_RESOURCE_BARRIER::Transition (resource,
D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_STATE_VIDEO_DECODE_WRITE, D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_STATE_VIDEO_DECODE_WRITE,
subresource[1])); subresource[1]));
post_barriers.push_back (CD3D12_RESOURCE_BARRIER::Transition (resource, post_barriers.push_back (CD3DX12_RESOURCE_BARRIER::Transition (resource,
D3D12_RESOURCE_STATE_VIDEO_DECODE_WRITE, D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_STATE_VIDEO_DECODE_WRITE, D3D12_RESOURCE_STATE_COMMON,
subresource[0])); subresource[0]));
post_barriers.push_back (CD3D12_RESOURCE_BARRIER::Transition (resource, post_barriers.push_back (CD3DX12_RESOURCE_BARRIER::Transition (resource,
D3D12_RESOURCE_STATE_VIDEO_DECODE_WRITE, D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_STATE_VIDEO_DECODE_WRITE, D3D12_RESOURCE_STATE_COMMON,
subresource[1])); subresource[1]));
@ -1034,15 +1035,15 @@ gst_d3d12_decoder_ensure_staging_texture (GstD3D12Decoder * self)
UINT64 size; UINT64 size;
ID3D12Device *device = gst_d3d12_device_get_device_handle (self->device); ID3D12Device *device = gst_d3d12_device_get_device_handle (self->device);
D3D12_RESOURCE_DESC tex_desc = D3D12_RESOURCE_DESC tex_desc =
CD3D12_RESOURCE_DESC::Tex2D (priv->decoder_format, CD3DX12_RESOURCE_DESC::Tex2D (priv->decoder_format,
priv->aligned_width, priv->aligned_height); priv->aligned_width, priv->aligned_height, 1, 1);
device->GetCopyableFootprints (&tex_desc, 0, 2, 0, priv->layout, nullptr, device->GetCopyableFootprints (&tex_desc, 0, 2, 0, priv->layout, nullptr,
nullptr, &size); nullptr, &size);
D3D12_HEAP_PROPERTIES heap_prop = CD3D12_HEAP_PROPERTIES D3D12_HEAP_PROPERTIES heap_prop = CD3DX12_HEAP_PROPERTIES
(D3D12_HEAP_TYPE_READBACK); (D3D12_HEAP_TYPE_READBACK);
D3D12_RESOURCE_DESC desc = CD3D12_RESOURCE_DESC::Buffer (size); D3D12_RESOURCE_DESC desc = CD3DX12_RESOURCE_DESC::Buffer (size);
hr = device->CreateCommittedResource (&heap_prop, D3D12_HEAP_FLAG_NONE, hr = device->CreateCommittedResource (&heap_prop, D3D12_HEAP_FLAG_NONE,
&desc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr, IID_PPV_ARGS (&staging)); &desc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr, IID_PPV_ARGS (&staging));
@ -1271,15 +1272,15 @@ gst_d3d12_decoder_output_picture (GstD3D12Decoder * decoder,
/* simultaneous access must be enabled already, so,barrier is not needed */ /* simultaneous access must be enabled already, so,barrier is not needed */
for (guint i = 0; i < 2; i++) { for (guint i = 0; i < 2; i++) {
D3D12_TEXTURE_COPY_LOCATION src = D3D12_TEXTURE_COPY_LOCATION src =
CD3D12_TEXTURE_COPY_LOCATION (resource, subresource[i]); CD3DX12_TEXTURE_COPY_LOCATION (resource, subresource[i]);
D3D12_TEXTURE_COPY_LOCATION dst; D3D12_TEXTURE_COPY_LOCATION dst;
D3D12_BOX src_box = { 0, }; D3D12_BOX src_box = { 0, };
if (out_resource) { if (out_resource) {
dst = CD3D12_TEXTURE_COPY_LOCATION (out_resource, out_subresource[i]); dst = CD3DX12_TEXTURE_COPY_LOCATION (out_resource, out_subresource[i]);
} else { } else {
dst = dst =
CD3D12_TEXTURE_COPY_LOCATION (priv->staging.Get (), CD3DX12_TEXTURE_COPY_LOCATION (priv->staging.Get (),
priv->layout[i]); priv->layout[i]);
} }

View file

@ -29,24 +29,6 @@
GST_DEBUG_CATEGORY_EXTERN (gst_d3d12_format_debug); GST_DEBUG_CATEGORY_EXTERN (gst_d3d12_format_debug);
#define GST_CAT_DEFAULT gst_d3d12_format_debug #define GST_CAT_DEFAULT gst_d3d12_format_debug
guint
gst_d3d12_get_format_plane_count (GstD3D12Device * device, DXGI_FORMAT format)
{
ID3D12Device *device_handle;
HRESULT hr;
D3D12_FEATURE_DATA_FORMAT_INFO format_info = { format, 0 };
g_return_val_if_fail (GST_IS_D3D12_DEVICE (device), 0);
device_handle = gst_d3d12_device_get_device_handle (device);
hr = device_handle->CheckFeatureSupport (D3D12_FEATURE_FORMAT_INFO,
&format_info, sizeof (D3D12_FEATURE_DATA_FORMAT_INFO));
if (!gst_d3d12_result (hr, device))
return 0;
return format_info.PlaneCount;
}
GstVideoFormat GstVideoFormat
gst_d3d12_dxgi_format_to_gst (DXGI_FORMAT format) gst_d3d12_dxgi_format_to_gst (DXGI_FORMAT format)
{ {

View file

@ -60,9 +60,6 @@ struct _GstD3D12Format
guint padding[GST_PADDING_LARGE]; guint padding[GST_PADDING_LARGE];
}; };
guint gst_d3d12_get_format_plane_count (GstD3D12Device * device,
DXGI_FORMAT format);
GstVideoFormat gst_d3d12_dxgi_format_to_gst (DXGI_FORMAT format); GstVideoFormat gst_d3d12_dxgi_format_to_gst (DXGI_FORMAT format);
gboolean gst_d3d12_dxgi_format_to_resource_formats (DXGI_FORMAT format, gboolean gst_d3d12_dxgi_format_to_resource_formats (DXGI_FORMAT format,

View file

@ -21,6 +21,7 @@
#include "config.h" #include "config.h"
#endif #endif
#include <directx/d3dx12.h>
#include "gstd3d12memory.h" #include "gstd3d12memory.h"
#include "gstd3d12device.h" #include "gstd3d12device.h"
#include "gstd3d12utils.h" #include "gstd3d12utils.h"
@ -102,13 +103,13 @@ gst_d3d12_allocation_params_new (GstD3D12Device * device,
g_assert (d3d12_format.resource_format[i] != DXGI_FORMAT_UNKNOWN); g_assert (d3d12_format.resource_format[i] != DXGI_FORMAT_UNKNOWN);
ret->desc[i] = ret->desc[i] =
CD3D12_RESOURCE_DESC::Tex2D (d3d12_format.resource_format[i], CD3DX12_RESOURCE_DESC::Tex2D (d3d12_format.resource_format[i],
GST_VIDEO_INFO_COMP_WIDTH (info, i), GST_VIDEO_INFO_COMP_WIDTH (info, i),
GST_VIDEO_INFO_COMP_HEIGHT (info, i), resource_flags); GST_VIDEO_INFO_COMP_HEIGHT (info, i), 1, 1, 1, 0, resource_flags);
} }
} else { } else {
ret->desc[0] = CD3D12_RESOURCE_DESC::Tex2D (d3d12_format.dxgi_format, ret->desc[0] = CD3DX12_RESOURCE_DESC::Tex2D (d3d12_format.dxgi_format,
info->width, info->height, resource_flags); info->width, info->height, 1, 1, 1, 0, resource_flags);
} }
ret->flags = flags; ret->flags = flags;
@ -221,8 +222,8 @@ gst_d3d12_memory_ensure_staging_resource (GstD3D12Memory * dmem)
HRESULT hr; HRESULT hr;
ID3D12Device *device = gst_d3d12_device_get_device_handle (dmem->device); ID3D12Device *device = gst_d3d12_device_get_device_handle (dmem->device);
D3D12_HEAP_PROPERTIES prop = D3D12_HEAP_PROPERTIES prop =
CD3D12_HEAP_PROPERTIES (D3D12_HEAP_TYPE_READBACK); CD3DX12_HEAP_PROPERTIES (D3D12_HEAP_TYPE_READBACK);
D3D12_RESOURCE_DESC desc = CD3D12_RESOURCE_DESC::Buffer (priv->size); D3D12_RESOURCE_DESC desc = CD3DX12_RESOURCE_DESC::Buffer (priv->size);
ComPtr < ID3D12Resource > staging; ComPtr < ID3D12Resource > staging;
hr = device->CreateCommittedResource (&prop, D3D12_HEAP_FLAG_NONE, hr = device->CreateCommittedResource (&prop, D3D12_HEAP_FLAG_NONE,
@ -293,10 +294,10 @@ gst_d3d12_memory_download (GstD3D12Memory * dmem)
for (guint i = 0; i < priv->num_subresources; i++) { for (guint i = 0; i < priv->num_subresources; i++) {
D3D12_TEXTURE_COPY_LOCATION src = D3D12_TEXTURE_COPY_LOCATION src =
CD3D12_TEXTURE_COPY_LOCATION (priv->resource.Get (), CD3DX12_TEXTURE_COPY_LOCATION (priv->resource.Get (),
priv->subresource_index[i]); priv->subresource_index[i]);
D3D12_TEXTURE_COPY_LOCATION dst = D3D12_TEXTURE_COPY_LOCATION dst =
CD3D12_TEXTURE_COPY_LOCATION (priv->staging.Get (), priv->layout[i]); CD3DX12_TEXTURE_COPY_LOCATION (priv->staging.Get (), priv->layout[i]);
priv->copy_cl->CopyTextureRegion (&dst, 0, 0, 0, &src, nullptr); priv->copy_cl->CopyTextureRegion (&dst, 0, 0, 0, &src, nullptr);
} }
@ -347,9 +348,9 @@ gst_d3d12_memory_upload (GstD3D12Memory * dmem)
for (guint i = 0; i < priv->num_subresources; i++) { for (guint i = 0; i < priv->num_subresources; i++) {
D3D12_TEXTURE_COPY_LOCATION src = D3D12_TEXTURE_COPY_LOCATION src =
CD3D12_TEXTURE_COPY_LOCATION (priv->staging.Get (), priv->layout[i]); CD3DX12_TEXTURE_COPY_LOCATION (priv->staging.Get (), priv->layout[i]);
D3D12_TEXTURE_COPY_LOCATION dst = D3D12_TEXTURE_COPY_LOCATION dst =
CD3D12_TEXTURE_COPY_LOCATION (priv->resource.Get (), CD3DX12_TEXTURE_COPY_LOCATION (priv->resource.Get (),
priv->subresource_index[i]); priv->subresource_index[i]);
priv->copy_cl->CopyTextureRegion (&dst, 0, 0, 0, &src, nullptr); priv->copy_cl->CopyTextureRegion (&dst, 0, 0, 0, &src, nullptr);
@ -876,7 +877,7 @@ gst_d3d12_allocator_alloc_wrapped (GstD3D12Allocator * self,
GstD3D12MemoryPrivate *priv; GstD3D12MemoryPrivate *priv;
ID3D12Device *device_handle = gst_d3d12_device_get_device_handle (device); ID3D12Device *device_handle = gst_d3d12_device_get_device_handle (device);
guint8 num_subresources = guint8 num_subresources =
gst_d3d12_get_format_plane_count (device, desc->Format); D3D12GetFormatPlaneCount (device_handle, desc->Format);
if (num_subresources == 0) { if (num_subresources == 0) {
GST_ERROR_OBJECT (self, "Couldn't get format info"); GST_ERROR_OBJECT (self, "Couldn't get format info");
@ -912,7 +913,7 @@ gst_d3d12_allocator_alloc_wrapped (GstD3D12Allocator * self,
* | UV plane: 3 | UV plane: 4 | UV plane: 5 | * | UV plane: 3 | UV plane: 4 | UV plane: 5 |
* +-------------+-------------+-------------+ * +-------------+-------------+-------------+
*/ */
mem->priv->subresource_index[i] = gst_d3d12_calculate_subresource (0, mem->priv->subresource_index[i] = D3D12CalcSubresource (0,
array_slice, i, 1, desc->DepthOrArraySize); array_slice, i, 1, desc->DepthOrArraySize);
device_handle->GetCopyableFootprints (&priv->desc, device_handle->GetCopyableFootprints (&priv->desc,

View file

@ -432,11 +432,3 @@ _gst_d3d12_result (HRESULT hr, GstD3D12Device * device, GstDebugCategory * cat,
return SUCCEEDED (hr); return SUCCEEDED (hr);
#endif #endif
} }
guint
gst_d3d12_calculate_subresource (guint mip_slice, guint array_slice,
guint plane_slice, guint mip_level, guint array_size)
{
return mip_slice + array_slice * mip_level +
plane_slice * mip_level * array_size;
}

View file

@ -74,12 +74,6 @@ gboolean _gst_d3d12_result (HRESULT hr,
_gst_d3d12_result (result, device, NULL, __FILE__, GST_FUNCTION, __LINE__, GST_LEVEL_ERROR) _gst_d3d12_result (result, device, NULL, __FILE__, GST_FUNCTION, __LINE__, GST_LEVEL_ERROR)
#endif #endif
guint gst_d3d12_calculate_subresource (guint mip_slice,
guint array_slice,
guint plane_slice,
guint mip_level,
guint array_size);
#define GST_D3D12_CLEAR_COM(obj) G_STMT_START { \ #define GST_D3D12_CLEAR_COM(obj) G_STMT_START { \
if (obj) { \ if (obj) { \
(obj)->Release (); \ (obj)->Release (); \
@ -89,130 +83,6 @@ guint gst_d3d12_calculate_subresource (guint mip_slice,
G_END_DECLS G_END_DECLS
struct CD3D12_HEAP_PROPERTIES : public D3D12_HEAP_PROPERTIES
{
CD3D12_HEAP_PROPERTIES (
D3D12_HEAP_TYPE type,
D3D12_CPU_PAGE_PROPERTY cpu_page_property = D3D12_CPU_PAGE_PROPERTY_UNKNOWN,
D3D12_MEMORY_POOL memory_pool_preference = D3D12_MEMORY_POOL_UNKNOWN,
UINT creation_node_mask = 1,
UINT visible_node_mask = 1)
{
Type = type;
CPUPageProperty = cpu_page_property;
MemoryPoolPreference = memory_pool_preference;
CreationNodeMask = creation_node_mask;
VisibleNodeMask = visible_node_mask;
}
};
struct CD3D12_RESOURCE_DESC : public D3D12_RESOURCE_DESC
{
CD3D12_RESOURCE_DESC(
D3D12_RESOURCE_DIMENSION dimension,
UINT64 alignment,
UINT64 width,
UINT height,
UINT16 depth_or_array_size,
UINT16 mip_levels,
DXGI_FORMAT format,
UINT sample_count,
UINT sample_quality,
D3D12_TEXTURE_LAYOUT layout,
D3D12_RESOURCE_FLAGS flags)
{
Dimension = dimension;
Alignment = alignment;
Width = width;
Height = height;
DepthOrArraySize = depth_or_array_size;
MipLevels = mip_levels;
Format = format;
SampleDesc.Count = sample_count;
SampleDesc.Quality = sample_quality;
Layout = layout;
Flags = flags;
}
static inline CD3D12_RESOURCE_DESC Buffer (
UINT64 width,
D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE,
UINT64 alignment = 0)
{
return CD3D12_RESOURCE_DESC (D3D12_RESOURCE_DIMENSION_BUFFER, alignment,
width, 1, 1, 1, DXGI_FORMAT_UNKNOWN, 1, 0,
D3D12_TEXTURE_LAYOUT_ROW_MAJOR, flags);
}
static inline CD3D12_RESOURCE_DESC Tex2D (
DXGI_FORMAT format,
UINT64 width,
UINT height,
D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE,
UINT16 array_size = 1,
UINT16 mip_levels = 1,
UINT sample_count = 1,
UINT sample_quality = 0,
D3D12_TEXTURE_LAYOUT layout = D3D12_TEXTURE_LAYOUT_UNKNOWN,
UINT64 alignment = 0)
{
return CD3D12_RESOURCE_DESC(D3D12_RESOURCE_DIMENSION_TEXTURE2D, alignment,
width, height, array_size, mip_levels, format, sample_count,
sample_quality, layout, flags);
}
};
struct CD3D12_RESOURCE_BARRIER : public D3D12_RESOURCE_BARRIER
{
static inline CD3D12_RESOURCE_BARRIER Transition (
ID3D12Resource * resource,
D3D12_RESOURCE_STATES before,
D3D12_RESOURCE_STATES after,
UINT subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES,
D3D12_RESOURCE_BARRIER_FLAGS flags = D3D12_RESOURCE_BARRIER_FLAG_NONE)
{
CD3D12_RESOURCE_BARRIER result;
D3D12_RESOURCE_BARRIER &barrier = result;
result.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
result.Flags = flags;
barrier.Transition.pResource = resource;
barrier.Transition.StateBefore = before;
barrier.Transition.StateAfter = after;
barrier.Transition.Subresource = subresource;
return result;
}
};
struct CD3D12_TEXTURE_COPY_LOCATION : public D3D12_TEXTURE_COPY_LOCATION
{
CD3D12_TEXTURE_COPY_LOCATION (ID3D12Resource * resource)
{
pResource = resource;
Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
PlacedFootprint = {};
}
CD3D12_TEXTURE_COPY_LOCATION (
ID3D12Resource * resource,
D3D12_PLACED_SUBRESOURCE_FOOTPRINT const & foot_print)
{
pResource = resource;
Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
PlacedFootprint = foot_print;
}
CD3D12_TEXTURE_COPY_LOCATION (
ID3D12Resource * resource,
UINT subresource)
{
pResource = resource;
Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
PlacedFootprint = {};
SubresourceIndex = subresource;
}
};
#include <mutex> #include <mutex>
class GstD3D12CSLockGuard class GstD3D12CSLockGuard

View file

@ -15,8 +15,11 @@ d3d12_sources = [
'plugin.cpp', 'plugin.cpp',
] ]
extra_args = ['-DGST_USE_UNSTABLE_API'] extra_args = [
extra_dep = [] '-DGST_USE_UNSTABLE_API',
# Disable this warning error. Otherwise d3dx12.h will break build
'/wd4062',
]
d3d12_option = get_option('d3d12') d3d12_option = get_option('d3d12')
if host_system != 'windows' or d3d12_option.disabled() if host_system != 'windows' or d3d12_option.disabled()