d3d11vp9dec: Fix critical warning

Don't query GPU vendor using null device.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5353>
This commit is contained in:
Seungha Yang 2023-09-19 21:40:22 +09:00 committed by GStreamer Marge Bot
parent 4b891639da
commit 39aca8a096
3 changed files with 28 additions and 16 deletions

View file

@ -127,24 +127,11 @@ gst_d3d11_is_windows_8_or_greater (void)
} }
GstD3D11DeviceVendor GstD3D11DeviceVendor
gst_d3d11_get_device_vendor (GstD3D11Device * device) gst_d3d11_get_device_vendor_from_id (guint vendor_id)
{ {
guint device_id = 0;
guint vendor_id = 0;
gchar *desc = NULL;
GstD3D11DeviceVendor vendor = GST_D3D11_DEVICE_VENDOR_UNKNOWN; GstD3D11DeviceVendor vendor = GST_D3D11_DEVICE_VENDOR_UNKNOWN;
g_return_val_if_fail (GST_IS_D3D11_DEVICE (device),
GST_D3D11_DEVICE_VENDOR_UNKNOWN);
g_object_get (device, "device-id", &device_id, "vendor-id", &vendor_id,
"description", &desc, NULL);
switch (vendor_id) { switch (vendor_id) {
case 0:
if (device_id == 0 && desc && g_strrstr (desc, "SraKmd"))
vendor = GST_D3D11_DEVICE_VENDOR_XBOX;
break;
case 0x1002: case 0x1002:
case 0x1022: case 0x1022:
vendor = GST_D3D11_DEVICE_VENDOR_AMD; vendor = GST_D3D11_DEVICE_VENDOR_AMD;
@ -162,9 +149,32 @@ gst_d3d11_get_device_vendor (GstD3D11Device * device)
break; break;
} }
return vendor;
}
GstD3D11DeviceVendor
gst_d3d11_get_device_vendor (GstD3D11Device * device)
{
guint device_id = 0;
guint vendor_id = 0;
gchar *desc = nullptr;
GstD3D11DeviceVendor vendor = GST_D3D11_DEVICE_VENDOR_UNKNOWN;
g_return_val_if_fail (GST_IS_D3D11_DEVICE (device),
GST_D3D11_DEVICE_VENDOR_UNKNOWN);
g_object_get (device, "device-id", &device_id, "vendor-id", &vendor_id,
"description", &desc, nullptr);
if (device_id == 0 && desc && g_strrstr (desc, "SraKmd"))
vendor = GST_D3D11_DEVICE_VENDOR_XBOX;
g_free (desc); g_free (desc);
return vendor; if (vendor != GST_D3D11_DEVICE_VENDOR_UNKNOWN)
return vendor;
return gst_d3d11_get_device_vendor_from_id (vendor_id);
} }
gboolean gboolean

View file

@ -57,6 +57,8 @@ gboolean gst_d3d11_is_windows_8_or_greater (void);
GstD3D11DeviceVendor gst_d3d11_get_device_vendor (GstD3D11Device * device); GstD3D11DeviceVendor gst_d3d11_get_device_vendor (GstD3D11Device * device);
GstD3D11DeviceVendor gst_d3d11_get_device_vendor_from_id (guint vendor_id);
gboolean gst_d3d11_hdr_meta_data_to_dxgi (GstVideoMasteringDisplayInfo * minfo, gboolean gst_d3d11_hdr_meta_data_to_dxgi (GstVideoMasteringDisplayInfo * minfo,
GstVideoContentLightLevel * cll, GstVideoContentLightLevel * cll,
DXGI_HDR_METADATA_HDR10 * dxgi_hdr10); DXGI_HDR_METADATA_HDR10 * dxgi_hdr10);

View file

@ -137,7 +137,7 @@ gst_d3d11_vp9_dec_open (GstVideoDecoder * decoder)
* reliable, since 1b means that it's supported and 0b indicates it may not be * reliable, since 1b means that it's supported and 0b indicates it may not be
* supported. Because some GPUs can support it even if the bit 12 is not * supported. Because some GPUs can support it even if the bit 12 is not
* set, do filtering by vendor for now (AMD and Intel looks fine) */ * set, do filtering by vendor for now (AMD and Intel looks fine) */
if (gst_d3d11_get_device_vendor (self->device) == if (gst_d3d11_get_device_vendor_from_id (cdata->vendor_id) ==
GST_D3D11_DEVICE_VENDOR_NVIDIA) { GST_D3D11_DEVICE_VENDOR_NVIDIA) {
gst_vp9_decoder_set_non_keyframe_format_change_support (vp9dec, FALSE); gst_vp9_decoder_set_non_keyframe_format_change_support (vp9dec, FALSE);
} }