d3d12decoder: Remove ID3D12Device4 interface requirement

Old OS may not support the interface. And allow 11_0 feature level
hardware.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5870>
This commit is contained in:
Seungha Yang 2023-12-26 20:41:33 +09:00 committed by GStreamer Marge Bot
parent 4e5d4a45a3
commit 1c5bba4b6b
3 changed files with 13 additions and 30 deletions

View file

@ -241,7 +241,7 @@ struct DecoderCmdData
CloseHandle (event_handle);
}
ComPtr<ID3D12Device4> device;
ComPtr<ID3D12Device> device;
ComPtr<ID3D12VideoDevice> video_device;
ComPtr<ID3D12VideoDecodeCommandList> cl;
@ -443,13 +443,9 @@ gst_d3d12_decoder_open (GstD3D12Decoder * decoder, GstElement * element)
auto priv = decoder->priv;
auto cmd = std::make_unique < DecoderCmdData > ();
auto device_handle = gst_d3d12_device_get_device_handle (decoder->device);
HRESULT hr;
auto hr = device_handle->QueryInterface (IID_PPV_ARGS (&cmd->device));
if (!gst_d3d12_result (hr, decoder->device)) {
GST_ERROR_OBJECT (element, "ID3D12Device4 interface is unavailable");
return FALSE;
}
cmd->device = gst_d3d12_device_get_device_handle (decoder->device);
hr = cmd->device.As (&cmd->video_device);
if (!gst_d3d12_result (hr, decoder->device)) {
@ -457,13 +453,6 @@ gst_d3d12_decoder_open (GstD3D12Decoder * decoder, GstElement * element)
return FALSE;
}
hr = cmd->device->CreateCommandList1 (0, D3D12_COMMAND_LIST_TYPE_VIDEO_DECODE,
D3D12_COMMAND_LIST_FLAG_NONE, IID_PPV_ARGS (&cmd->cl));
if (!gst_d3d12_result (hr, decoder->device)) {
GST_ERROR_OBJECT (element, "Couldn't create command list");
return FALSE;
}
D3D12_COMMAND_QUEUE_DESC desc = { };
desc.Type = D3D12_COMMAND_LIST_TYPE_VIDEO_DECODE;
desc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE;
@ -1166,9 +1155,16 @@ gst_d3d12_decoder_end_picture (GstD3D12Decoder * decoder,
return GST_FLOW_ERROR;
}
hr = priv->cmd->cl->Reset (task_data->ca.Get ());
if (!priv->cmd->cl) {
hr = priv->cmd->device->CreateCommandList (0,
D3D12_COMMAND_LIST_TYPE_VIDEO_DECODE,
task_data->ca.Get (), nullptr, IID_PPV_ARGS (&priv->cmd->cl));
} else {
hr = priv->cmd->cl->Reset (task_data->ca.Get ());
}
if (!gst_d3d12_result (hr, decoder->device)) {
GST_ERROR_OBJECT (decoder, "Couldn't reset command list");
GST_ERROR_OBJECT (decoder, "Couldn't configure command list");
return GST_FLOW_ERROR;
}

View file

@ -593,20 +593,13 @@ gst_d3d12_device_new_internal (const GstD3D12DeviceConstructData * data)
return nullptr;
}
hr = D3D12CreateDevice (adapter.Get (), D3D_FEATURE_LEVEL_12_0,
hr = D3D12CreateDevice (adapter.Get (), D3D_FEATURE_LEVEL_11_0,
IID_PPV_ARGS (&device));
if (FAILED (hr)) {
GST_WARNING ("Could not create device, hr: 0x%x", (guint) hr);
return nullptr;
}
ComPtr < ID3D12Device4 > device4;
hr = device.As (&device4);
if (FAILED (hr)) {
GST_WARNING ("ID3D12Device4 interface unavailable");
return nullptr;
}
ComPtr < ID3D12Fence > copy_fence;
hr = device->CreateFence (0,
D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS (&copy_fence));

View file

@ -68,7 +68,6 @@ plugin_init (GstPlugin * plugin)
for (guint i = 0; i < 12; i++) {
GstD3D12Device *device = nullptr;
ID3D12Device *device_handle;
ComPtr < ID3D12Device4 > device4;
ComPtr < ID3D12VideoDevice > video_device;
HRESULT hr;
@ -77,11 +76,6 @@ plugin_init (GstPlugin * plugin)
break;
device_handle = gst_d3d12_device_get_device_handle (device);
hr = device_handle->QueryInterface (IID_PPV_ARGS (&device4));
if (FAILED (hr)) {
gst_object_unref (device);
continue;
}
hr = device_handle->QueryInterface (IID_PPV_ARGS (&video_device));
if (FAILED (hr)) {