summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeungha Yang <seungha@centricular.com>2024-09-26 02:03:19 +0900
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>2024-09-26 12:48:55 +0000
commit2d91521dfcb374ff19d0f5cbaa8ba84bc518deab (patch)
treec45b6ec09d5976c4c1b62413c58883b98e7600d6
parentdf23724b96745aaee8e2b9eba9f32462b99aee03 (diff)
d3d12: Fix resource allocation on old Windows version
D3D12_HEAP_FLAG_CREATE_NOT_ZEROED flag was introduced as of Windows 10 May 2020 Update, and older versions don't understand the heap flag. Checks the feature support and enables the D3D12_HEAP_FLAG_CREATE_NOT_ZEROED only if it's supported by OS Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7573>
-rw-r--r--subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12converter.cpp22
-rw-r--r--subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12device-private.h3
-rw-r--r--subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12device.cpp19
-rw-r--r--subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12memory.cpp7
-rw-r--r--subprojects/gst-plugins-bad/sys/d3d12/gstd3d12compositor.cpp8
-rw-r--r--subprojects/gst-plugins-bad/sys/d3d12/gstd3d12decoder.cpp17
-rw-r--r--subprojects/gst-plugins-bad/sys/d3d12/gstd3d12decodercpbpool.cpp16
-rw-r--r--subprojects/gst-plugins-bad/sys/d3d12/gstd3d12decodercpbpool.h2
-rw-r--r--subprojects/gst-plugins-bad/sys/d3d12/gstd3d12overlaycompositor.cpp20
-rw-r--r--subprojects/gst-plugins-bad/sys/d3d12/gstd3d12testsrc.cpp35
10 files changed, 103 insertions, 46 deletions
diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12converter.cpp b/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12converter.cpp
index 1df84c6696..59eff1d358 100644
--- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12converter.cpp
+++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12converter.cpp
@@ -897,6 +897,10 @@ gst_d3d12_converter_setup_resource (GstD3D12Converter * self,
D3D12_RESOURCE_DESC resource_desc;
CD3DX12_RANGE range (0, 0);
guint8 *data;
+ D3D12_HEAP_FLAGS heap_flags = D3D12_HEAP_FLAG_NONE;
+ if (gst_d3d12_device_non_zeroed_supported (self->device))
+ heap_flags = D3D12_HEAP_FLAG_CREATE_NOT_ZEROED;
+
{
guint vertex_index_size = g_vertex_buf_size + g_index_buf_size;
vertex_index_size = GST_ROUND_UP_N (vertex_index_size,
@@ -907,8 +911,7 @@ gst_d3d12_converter_setup_resource (GstD3D12Converter * self,
heap_prop = CD3DX12_HEAP_PROPERTIES (D3D12_HEAP_TYPE_DEFAULT);
resource_desc =
CD3DX12_RESOURCE_DESC::Buffer (vertex_index_size + const_size);
- hr = device->CreateCommittedResource (&heap_prop,
- D3D12_HEAP_FLAG_CREATE_NOT_ZEROED,
+ hr = device->CreateCommittedResource (&heap_prop, heap_flags,
&resource_desc, D3D12_RESOURCE_STATE_COMMON, nullptr,
IID_PPV_ARGS (&priv->shader_buf));
if (!gst_d3d12_result (hr, self->device)) {
@@ -928,8 +931,7 @@ gst_d3d12_converter_setup_resource (GstD3D12Converter * self,
heap_prop = CD3DX12_HEAP_PROPERTIES (D3D12_HEAP_TYPE_UPLOAD);
hr = device->CreateCommittedResource (&heap_prop,
- D3D12_HEAP_FLAG_CREATE_NOT_ZEROED,
- &resource_desc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr,
+ heap_flags, &resource_desc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr,
IID_PPV_ARGS (&upload_buf));
if (!gst_d3d12_result (hr, self->device)) {
GST_ERROR_OBJECT (self, "Couldn't create vertex buffer upload");
@@ -954,8 +956,7 @@ gst_d3d12_converter_setup_resource (GstD3D12Converter * self,
GAMMA_LUT_SIZE, 1, 1);
hr = device->CreateCommittedResource (&heap_prop,
- D3D12_HEAP_FLAG_CREATE_NOT_ZEROED,
- &resource_desc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr,
+ heap_flags, &resource_desc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr,
IID_PPV_ARGS (&priv->gamma_dec_lut));
if (!gst_d3d12_result (hr, self->device)) {
GST_ERROR_OBJECT (self, "Couldn't create gamma decoding LUT");
@@ -963,8 +964,7 @@ gst_d3d12_converter_setup_resource (GstD3D12Converter * self,
}
hr = device->CreateCommittedResource (&heap_prop,
- D3D12_HEAP_FLAG_CREATE_NOT_ZEROED,
- &resource_desc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr,
+ heap_flags, &resource_desc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr,
IID_PPV_ARGS (&priv->gamma_enc_lut));
if (!gst_d3d12_result (hr, self->device)) {
GST_ERROR_OBJECT (self, "Couldn't create gamma encoding LUT");
@@ -979,8 +979,7 @@ gst_d3d12_converter_setup_resource (GstD3D12Converter * self,
resource_desc = CD3DX12_RESOURCE_DESC::Buffer (gamma_lut_size);
hr = device->CreateCommittedResource (&heap_prop,
- D3D12_HEAP_FLAG_CREATE_NOT_ZEROED,
- &resource_desc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr,
+ heap_flags, &resource_desc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr,
IID_PPV_ARGS (&gamma_dec_lut_upload));
if (!gst_d3d12_result (hr, self->device)) {
GST_ERROR_OBJECT (self, "Couldn't create gamma decoding LUT upload");
@@ -988,8 +987,7 @@ gst_d3d12_converter_setup_resource (GstD3D12Converter * self,
}
hr = device->CreateCommittedResource (&heap_prop,
- D3D12_HEAP_FLAG_CREATE_NOT_ZEROED,
- &resource_desc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr,
+ heap_flags, &resource_desc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr,
IID_PPV_ARGS (&gamma_enc_lut_upload));
if (!gst_d3d12_result (hr, self->device)) {
GST_ERROR_OBJECT (self, "Couldn't create gamma encoding LUT upload");
diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12device-private.h b/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12device-private.h
index 70661158ef..ca6948f0a6 100644
--- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12device-private.h
+++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12device-private.h
@@ -97,5 +97,8 @@ HRESULT gst_d3d12_device_get_sampler_state (GstD3D12Device * device,
D3D12_FILTER filter,
ID3D12DescriptorHeap ** heap);
+GST_D3D12_API
+gboolean gst_d3d12_device_non_zeroed_supported (GstD3D12Device * device);
+
G_END_DECLS
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 29bbcc4ee9..7d1d8cd6bf 100644
--- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12device.cpp
+++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12device.cpp
@@ -271,6 +271,7 @@ struct DeviceInner
guint vendor_id = 0;
std::string description;
gint64 adapter_luid = 0;
+ gboolean non_zeroed_supported = FALSE;
HANDLE dev_removed_monitor_handle = nullptr;
HANDLE dev_removed_event;
@@ -1407,6 +1408,16 @@ gst_d3d12_device_new_internal (const GstD3D12DeviceConstructData * data)
priv->dev_removed_event, on_device_removed, priv.get (), INFINITE,
WT_EXECUTEONLYONCE);
+ /* D3D12_HEAP_FLAG_CREATE_NOT_ZEROED was introduced as of Windows 10 May 2020
+ * update, and supported if D3D12_FEATURE_D3D12_OPTIONS7 check is succeeded */
+ {
+ D3D12_FEATURE_DATA_D3D12_OPTIONS7 options7 = { };
+ hr = device->CheckFeatureSupport (D3D12_FEATURE_D3D12_OPTIONS7, &options7,
+ sizeof (options7));
+ if (SUCCEEDED (hr))
+ priv->non_zeroed_supported = TRUE;
+ }
+
return self;
error:
@@ -2229,3 +2240,11 @@ gst_d3d12_device_get_sampler_state (GstD3D12Device * device,
return S_OK;
}
+
+gboolean
+gst_d3d12_device_non_zeroed_supported (GstD3D12Device * device)
+{
+ g_return_val_if_fail (GST_IS_D3D12_DEVICE (device), FALSE);
+
+ return device->priv->inner->non_zeroed_supported;
+}
diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12memory.cpp b/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12memory.cpp
index 1160b1bc43..59cbffcd6b 100644
--- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12memory.cpp
+++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d12/gstd3d12memory.cpp
@@ -413,9 +413,12 @@ gst_d3d12_memory_ensure_staging_resource (GstD3D12Memory * dmem)
CD3DX12_HEAP_PROPERTIES (D3D12_CPU_PAGE_PROPERTY_WRITE_BACK,
D3D12_MEMORY_POOL_L0);
D3D12_RESOURCE_DESC desc = CD3DX12_RESOURCE_DESC::Buffer (priv->size);
+ D3D12_HEAP_FLAGS heap_flags = D3D12_HEAP_FLAG_NONE;
+ if (gst_d3d12_device_non_zeroed_supported (dmem->device))
+ heap_flags = D3D12_HEAP_FLAG_CREATE_NOT_ZEROED;
+
ComPtr < ID3D12Resource > staging;
- hr = device->CreateCommittedResource (&prop,
- D3D12_HEAP_FLAG_CREATE_NOT_ZEROED,
+ hr = device->CreateCommittedResource (&prop, heap_flags,
&desc, D3D12_RESOURCE_STATE_COMMON, nullptr, IID_PPV_ARGS (&staging));
if (!gst_d3d12_result (hr, dmem->device)) {
GST_ERROR_OBJECT (dmem->device, "Couldn't create staging resource");
diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12compositor.cpp b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12compositor.cpp
index 4ea8060dc2..0117a8b9c3 100644
--- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12compositor.cpp
+++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12compositor.cpp
@@ -447,10 +447,12 @@ struct BackgroundRender
D3D12_RESOURCE_DESC buffer_desc =
CD3DX12_RESOURCE_DESC::Buffer (sizeof (VertexData) * 4 +
sizeof (indices));
+ D3D12_HEAP_FLAGS heap_flags = D3D12_HEAP_FLAG_NONE;
+ if (gst_d3d12_device_non_zeroed_supported (device))
+ heap_flags = D3D12_HEAP_FLAG_CREATE_NOT_ZEROED;
hr = device_handle->CreateCommittedResource (&heap_prop,
- D3D12_HEAP_FLAG_CREATE_NOT_ZEROED, &buffer_desc,
- D3D12_RESOURCE_STATE_GENERIC_READ,
+ heap_flags, &buffer_desc, D3D12_RESOURCE_STATE_GENERIC_READ,
nullptr, IID_PPV_ARGS (&vertex_index_upload));
if (!gst_d3d12_result (hr, device)) {
GST_ERROR_OBJECT (device, "Couldn't create vertex upload buf");
@@ -471,7 +473,7 @@ struct BackgroundRender
heap_prop = CD3DX12_HEAP_PROPERTIES (D3D12_HEAP_TYPE_DEFAULT);
hr = device_handle->CreateCommittedResource (&heap_prop,
- D3D12_HEAP_FLAG_CREATE_NOT_ZEROED, &buffer_desc,
+ heap_flags, &buffer_desc,
D3D12_RESOURCE_STATE_COMMON, nullptr, IID_PPV_ARGS (&vertex_index_buf));
if (!gst_d3d12_result (hr, device)) {
GST_ERROR_OBJECT (device, "Couldn't create index buffer");
diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12decoder.cpp b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12decoder.cpp
index 593e73c77e..72ad8053a5 100644
--- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12decoder.cpp
+++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12decoder.cpp
@@ -741,7 +741,10 @@ gst_d3d12_decoder_configure (GstD3D12Decoder * decoder,
align.padding_right = session->aligned_width - info->width;
align.padding_bottom = session->aligned_height - info->height;
- D3D12_HEAP_FLAGS heap_flags = D3D12_HEAP_FLAG_CREATE_NOT_ZEROED;
+ D3D12_HEAP_FLAGS heap_flags = D3D12_HEAP_FLAG_NONE;
+ if (gst_d3d12_device_non_zeroed_supported (decoder->device))
+ heap_flags = D3D12_HEAP_FLAG_CREATE_NOT_ZEROED;
+
if (!session->reference_only)
heap_flags |= D3D12_HEAP_FLAG_SHARED;
@@ -775,11 +778,15 @@ gst_d3d12_decoder_configure (GstD3D12Decoder * decoder,
session->output_pool = gst_d3d12_buffer_pool_new (decoder->device);
config = gst_buffer_pool_get_config (session->output_pool);
+ heap_flags = D3D12_HEAP_FLAG_NONE;
+ if (gst_d3d12_device_non_zeroed_supported (decoder->device))
+ heap_flags = D3D12_HEAP_FLAG_CREATE_NOT_ZEROED;
+
params = gst_d3d12_allocation_params_new (decoder->device, info,
GST_D3D12_ALLOCATION_FLAG_DEFAULT,
D3D12_RESOURCE_FLAG_ALLOW_SIMULTANEOUS_ACCESS |
D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET,
- D3D12_HEAP_FLAG_CREATE_NOT_ZEROED | D3D12_HEAP_FLAG_SHARED);
+ heap_flags | D3D12_HEAP_FLAG_SHARED);
gst_d3d12_allocation_params_alignment (params, &align);
gst_buffer_pool_config_set_d3d12_allocation_params (config, params);
gst_d3d12_allocation_params_free (params);
@@ -1285,9 +1292,11 @@ gst_d3d12_decoder_ensure_staging_texture (GstD3D12Decoder * self)
D3D12_HEAP_PROPERTIES heap_prop = CD3DX12_HEAP_PROPERTIES
(D3D12_HEAP_TYPE_READBACK);
D3D12_RESOURCE_DESC desc = CD3DX12_RESOURCE_DESC::Buffer (size);
+ D3D12_HEAP_FLAGS heap_flags = D3D12_HEAP_FLAG_NONE;
+ if (gst_d3d12_device_non_zeroed_supported (self->device))
+ heap_flags = D3D12_HEAP_FLAG_CREATE_NOT_ZEROED;
- hr = device->CreateCommittedResource (&heap_prop,
- D3D12_HEAP_FLAG_CREATE_NOT_ZEROED,
+ hr = device->CreateCommittedResource (&heap_prop, heap_flags,
&desc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr, IID_PPV_ARGS (&staging));
if (!gst_d3d12_result (hr, self->device))
return FALSE;
diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12decodercpbpool.cpp b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12decodercpbpool.cpp
index d8b17ce88d..598cdef1fb 100644
--- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12decodercpbpool.cpp
+++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12decodercpbpool.cpp
@@ -138,6 +138,7 @@ struct GstD3D12DecoderCpbPoolPrivate
UINT64 buffer_id = 0;
UINT64 max_alloc_size = 0;
guint allocated_ca_size = 0;
+ bool supports_non_zeroed = false;
std::mutex lock;
};
@@ -145,7 +146,6 @@ struct GstD3D12DecoderCpbPoolPrivate
struct _GstD3D12DecoderCpbPool
{
GstObject parent;
- GstD3D12Device *device;
GstD3D12DecoderCpbPoolPrivate *priv;
};
/* *INDENT-ON* */
@@ -181,7 +181,6 @@ gst_d3d12_decoder_cpb_pool_finalize (GObject * object)
auto self = GST_D3D12_DECODER_CPB_POOL (object);
delete self->priv;
- gst_clear_object (&self->device);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@@ -198,6 +197,13 @@ gst_d3d12_decoder_cpb_pool_new (ID3D12Device * device)
auto priv = self->priv;
priv->device = device;
+ D3D12_FEATURE_DATA_D3D12_OPTIONS7 options7 = { };
+ auto hr =
+ device->CheckFeatureSupport (D3D12_FEATURE_D3D12_OPTIONS7, &options7,
+ sizeof (options7));
+ if (SUCCEEDED (hr))
+ priv->supports_non_zeroed = true;
+
return self;
}
@@ -286,13 +292,17 @@ gst_d3d12_decoder_cpb_pool_acquire (GstD3D12DecoderCpbPool * pool,
D3D12_HEAP_PROPERTIES heap_prop =
CD3DX12_HEAP_PROPERTIES (D3D12_HEAP_TYPE_UPLOAD);
D3D12_RESOURCE_DESC desc = CD3DX12_RESOURCE_DESC::Buffer (alloc_size);
+ D3D12_HEAP_FLAGS heap_flags = D3D12_HEAP_FLAG_NONE;
+ if (priv->supports_non_zeroed)
+ heap_flags = D3D12_HEAP_FLAG_CREATE_NOT_ZEROED;
+
ComPtr < ID3D12Resource > resource;
GST_DEBUG_OBJECT (pool, "Allocating new buffer, size %" G_GUINT64_FORMAT,
alloc_size);
auto hr = priv->device->CreateCommittedResource (&heap_prop,
- D3D12_HEAP_FLAG_CREATE_NOT_ZEROED, &desc,
+ heap_flags, &desc,
D3D12_RESOURCE_STATE_GENERIC_READ, nullptr, IID_PPV_ARGS (&resource));
if (FAILED (hr)) {
GST_ERROR_OBJECT (pool, "Couldn't allocate upload resource");
diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12decodercpbpool.h b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12decodercpbpool.h
index 36017f636c..987becbfe7 100644
--- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12decodercpbpool.h
+++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12decodercpbpool.h
@@ -37,7 +37,7 @@ GstD3D12DecoderCpbPool * gst_d3d12_decoder_cpb_pool_new (ID3D12Device * device);
HRESULT gst_d3d12_decoder_cpb_pool_acquire (GstD3D12DecoderCpbPool * pool,
gpointer data,
gsize size,
- GstD3D12DecoderCpb ** cpb);
+ GstD3D12DecoderCpb ** cpb);
GstD3D12DecoderCpb * gst_d3d12_decoder_cpb_ref (GstD3D12DecoderCpb * cpb);
diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12overlaycompositor.cpp b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12overlaycompositor.cpp
index 5bb33f927b..e69860f2c0 100644
--- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12overlaycompositor.cpp
+++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12overlaycompositor.cpp
@@ -215,6 +215,10 @@ gst_d3d12_overlay_rect_new (GstD3D12OverlayCompositor * self,
ComPtr < ID3D12Resource > staging;
D3D12_PLACED_SUBRESOURCE_FOOTPRINT layout;
+ D3D12_HEAP_FLAGS heap_flags = D3D12_HEAP_FLAG_NONE;
+ if (gst_d3d12_device_non_zeroed_supported (self->device))
+ heap_flags = D3D12_HEAP_FLAG_CREATE_NOT_ZEROED;
+
if (!is_d3d12) {
auto vmeta = gst_buffer_get_video_meta (buf);
@@ -229,8 +233,7 @@ gst_d3d12_overlay_rect_new (GstD3D12OverlayCompositor * self,
CD3DX12_RESOURCE_DESC::Tex2D (DXGI_FORMAT_B8G8R8A8_UNORM, vmeta->width,
vmeta->height, 1, 1);
- auto hr = device->CreateCommittedResource (&heap_prop,
- D3D12_HEAP_FLAG_CREATE_NOT_ZEROED,
+ auto hr = device->CreateCommittedResource (&heap_prop, heap_flags,
&desc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr,
IID_PPV_ARGS (&texture));
if (!gst_d3d12_result (hr, self->device)) {
@@ -244,8 +247,7 @@ gst_d3d12_overlay_rect_new (GstD3D12OverlayCompositor * self,
heap_prop = CD3DX12_HEAP_PROPERTIES (D3D12_HEAP_TYPE_UPLOAD);
desc = CD3DX12_RESOURCE_DESC::Buffer (size);
- hr = device->CreateCommittedResource (&heap_prop,
- D3D12_HEAP_FLAG_CREATE_NOT_ZEROED,
+ hr = device->CreateCommittedResource (&heap_prop, heap_flags,
&desc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr,
IID_PPV_ARGS (&staging));
if (!gst_d3d12_result (hr, self->device)) {
@@ -333,8 +335,7 @@ gst_d3d12_overlay_rect_new (GstD3D12OverlayCompositor * self,
CD3DX12_HEAP_PROPERTIES (D3D12_HEAP_TYPE_UPLOAD);
D3D12_RESOURCE_DESC desc =
CD3DX12_RESOURCE_DESC::Buffer (sizeof (VertexData) * 4);
- auto hr = device->CreateCommittedResource (&heap_prop,
- D3D12_HEAP_FLAG_CREATE_NOT_ZEROED,
+ auto hr = device->CreateCommittedResource (&heap_prop, heap_flags,
&desc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr,
IID_PPV_ARGS (&vertex_buf));
if (!gst_d3d12_result (hr, self->device)) {
@@ -547,9 +548,12 @@ gst_d3d12_overlay_compositor_setup_shader (GstD3D12OverlayCompositor * self)
CD3DX12_HEAP_PROPERTIES (D3D12_HEAP_TYPE_UPLOAD);
D3D12_RESOURCE_DESC buffer_desc =
CD3DX12_RESOURCE_DESC::Buffer (sizeof (indices));
+ D3D12_HEAP_FLAGS heap_flags = D3D12_HEAP_FLAG_NONE;
+ if (gst_d3d12_device_non_zeroed_supported (self->device))
+ heap_flags = D3D12_HEAP_FLAG_CREATE_NOT_ZEROED;
+
ComPtr < ID3D12Resource > index_buf;
- hr = device->CreateCommittedResource (&heap_prop,
- D3D12_HEAP_FLAG_CREATE_NOT_ZEROED,
+ hr = device->CreateCommittedResource (&heap_prop, heap_flags,
&buffer_desc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr,
IID_PPV_ARGS (&index_buf));
if (!gst_d3d12_result (hr, self->device)) {
diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12testsrc.cpp b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12testsrc.cpp
index 9f7801d5bd..05faa04404 100644
--- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12testsrc.cpp
+++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12testsrc.cpp
@@ -547,9 +547,12 @@ setup_snow_render (GstD3D12TestSrc * self, RenderContext * ctx,
D3D12_RESOURCE_DESC buffer_desc =
CD3DX12_RESOURCE_DESC::Buffer (sizeof (UvVertexData) * 4
+ sizeof (indices));
+ D3D12_HEAP_FLAGS heap_flags = D3D12_HEAP_FLAG_NONE;
+ if (gst_d3d12_device_non_zeroed_supported (self->device))
+ heap_flags = D3D12_HEAP_FLAG_CREATE_NOT_ZEROED;
+
ComPtr < ID3D12Resource > vertex_index_upload;
- hr = device->CreateCommittedResource (&heap_prop,
- D3D12_HEAP_FLAG_CREATE_NOT_ZEROED,
+ hr = device->CreateCommittedResource (&heap_prop, heap_flags,
&buffer_desc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr,
IID_PPV_ARGS (&vertex_index_upload));
if (!gst_d3d12_result (hr, self->device)) {
@@ -571,8 +574,7 @@ setup_snow_render (GstD3D12TestSrc * self, RenderContext * ctx,
heap_prop = CD3DX12_HEAP_PROPERTIES (D3D12_HEAP_TYPE_DEFAULT);
ComPtr < ID3D12Resource > vertex_index_buf;
- hr = device->CreateCommittedResource (&heap_prop,
- D3D12_HEAP_FLAG_CREATE_NOT_ZEROED,
+ hr = device->CreateCommittedResource (&heap_prop, heap_flags,
&buffer_desc, D3D12_RESOURCE_STATE_COMMON, nullptr,
IID_PPV_ARGS (&vertex_index_buf));
if (!gst_d3d12_result (hr, self->device)) {
@@ -938,9 +940,12 @@ setup_smpte_render (GstD3D12TestSrc * self, RenderContext * ctx)
D3D12_RESOURCE_DESC buffer_desc =
CD3DX12_RESOURCE_DESC::Buffer (sizeof (ColorVertexData) * 4 * 20
+ sizeof (WORD) * 6 * 20);
+ D3D12_HEAP_FLAGS heap_flags = D3D12_HEAP_FLAG_NONE;
+ if (gst_d3d12_device_non_zeroed_supported (self->device))
+ heap_flags = D3D12_HEAP_FLAG_CREATE_NOT_ZEROED;
+
ComPtr < ID3D12Resource > vertex_index_upload;
- hr = device->CreateCommittedResource (&heap_prop,
- D3D12_HEAP_FLAG_CREATE_NOT_ZEROED,
+ hr = device->CreateCommittedResource (&heap_prop, heap_flags,
&buffer_desc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr,
IID_PPV_ARGS (&vertex_index_upload));
if (!gst_d3d12_result (hr, self->device)) {
@@ -963,8 +968,7 @@ setup_smpte_render (GstD3D12TestSrc * self, RenderContext * ctx)
heap_prop = CD3DX12_HEAP_PROPERTIES (D3D12_HEAP_TYPE_DEFAULT);
ComPtr < ID3D12Resource > vertex_index_buf;
- hr = device->CreateCommittedResource (&heap_prop,
- D3D12_HEAP_FLAG_CREATE_NOT_ZEROED,
+ hr = device->CreateCommittedResource (&heap_prop, heap_flags,
&buffer_desc, D3D12_RESOURCE_STATE_COMMON, nullptr,
IID_PPV_ARGS (&vertex_index_buf));
if (!gst_d3d12_result (hr, self->device)) {
@@ -1119,9 +1123,12 @@ setup_checker_render (GstD3D12TestSrc * self, RenderContext * ctx,
D3D12_RESOURCE_DESC buffer_desc =
CD3DX12_RESOURCE_DESC::Buffer (sizeof (UvVertexData) * 4
+ sizeof (indices));
+ D3D12_HEAP_FLAGS heap_flags = D3D12_HEAP_FLAG_NONE;
+ if (gst_d3d12_device_non_zeroed_supported (self->device))
+ heap_flags = D3D12_HEAP_FLAG_CREATE_NOT_ZEROED;
+
ComPtr < ID3D12Resource > vertex_index_upload;
- hr = device->CreateCommittedResource (&heap_prop,
- D3D12_HEAP_FLAG_CREATE_NOT_ZEROED,
+ hr = device->CreateCommittedResource (&heap_prop, heap_flags,
&buffer_desc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr,
IID_PPV_ARGS (&vertex_index_upload));
if (!gst_d3d12_result (hr, self->device)) {
@@ -1143,8 +1150,7 @@ setup_checker_render (GstD3D12TestSrc * self, RenderContext * ctx,
heap_prop = CD3DX12_HEAP_PROPERTIES (D3D12_HEAP_TYPE_DEFAULT);
ComPtr < ID3D12Resource > vertex_index_buf;
- hr = device->CreateCommittedResource (&heap_prop,
- D3D12_HEAP_FLAG_CREATE_NOT_ZEROED,
+ hr = device->CreateCommittedResource (&heap_prop, heap_flags,
&buffer_desc, D3D12_RESOURCE_STATE_COMMON, nullptr,
IID_PPV_ARGS (&vertex_index_buf));
if (!gst_d3d12_result (hr, self->device)) {
@@ -1611,7 +1617,10 @@ gst_d3d12_test_src_setup_context (GstD3D12TestSrc * self, GstCaps * caps)
D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET |
D3D12_RESOURCE_FLAG_ALLOW_SIMULTANEOUS_ACCESS);
D3D12_CLEAR_VALUE clear_value = { };
- D3D12_HEAP_FLAGS heap_flags = D3D12_HEAP_FLAG_CREATE_NOT_ZEROED;
+ D3D12_HEAP_FLAGS heap_flags = D3D12_HEAP_FLAG_NONE;
+ if (gst_d3d12_device_non_zeroed_supported (self->device))
+ heap_flags = D3D12_HEAP_FLAG_CREATE_NOT_ZEROED;
+
clear_value.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
clear_value.Color[0] = 0.0f;
clear_value.Color[1] = 0.0f;