d3d11window: Use ID3D11VideoProcessor only if device supports corresponding conversion

... and drop support for ID3D11VideoProcessor if device doesn't
support ID3D11VideoContext1 interface and therefore we cannot
query conversion supportability.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1743>
This commit is contained in:
Seungha Yang 2020-10-31 03:28:55 +09:00
parent 337cb883fa
commit a3a7e21f87

View file

@ -665,115 +665,65 @@ gst_d3d11_window_prepare (GstD3D11Window * window, guint display_width,
window->render_info.colorimetry.range = GST_VIDEO_COLOR_RANGE_0_255; window->render_info.colorimetry.range = GST_VIDEO_COLOR_RANGE_0_255;
} }
/* FIXME: need to verify video processor on Xbox #if (DXGI_HEADER_VERSION >= 4)
* https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/issues/1312 if (chosen_colorspace) {
*/ const GstDxgiColorSpace *in_color_space =
gst_d3d11_video_info_to_dxgi_color_space (&window->info);
const GstD3D11Format *in_format =
gst_d3d11_device_format_from_gst (window->device,
GST_VIDEO_INFO_FORMAT (&window->info));
gboolean hardware = FALSE;
GstD3D11VideoProcessor *processor = NULL;
/* XXX: Depending on driver/vendor, d3d11 video processor might not support if (in_color_space && in_format &&
* HDR10 metadata. Even worse thing here is, in_format->dxgi_format != DXGI_FORMAT_UNKNOWN) {
* although the d3d11 video processor's capability flag indicated that g_object_get (window->device, "hardware", &hardware, NULL);
* HDR10 metadata is supported, it would result to black screen when HDR10 }
* metadata is passed to d3d11 video processor. (without any error message).
* Let's disable d3d11 video processor. if (hardware) {
*/ processor =
if (!have_hdr10 && gst_d3d11_get_device_vendor (window->device) !=
GST_D3D11_DEVICE_VENDOR_XBOX) {
window->processor =
gst_d3d11_video_processor_new (window->device, gst_d3d11_video_processor_new (window->device,
GST_VIDEO_INFO_WIDTH (&window->info), GST_VIDEO_INFO_WIDTH (&window->info),
GST_VIDEO_INFO_HEIGHT (&window->info), GST_VIDEO_INFO_HEIGHT (&window->info),
display_width, display_height); display_width, display_height);
}
if (window->processor) {
const GstD3D11Format *in_format;
const GstD3D11Format *out_format;
gboolean input_support = FALSE;
gboolean out_support = FALSE;
in_format = gst_d3d11_device_format_from_gst (window->device,
GST_VIDEO_INFO_FORMAT (&window->info));
out_format = gst_d3d11_device_format_from_gst (window->device,
GST_VIDEO_INFO_FORMAT (&window->render_info));
if (gst_d3d11_video_processor_supports_input_format (window->processor,
in_format->dxgi_format)) {
input_support = TRUE;
} else {
GST_DEBUG_OBJECT (window,
"IVideoProcessor cannot support input dxgi format %d",
in_format->dxgi_format);
} }
if (gst_d3d11_video_processor_supports_output_format (window->processor, if (processor) {
out_format->dxgi_format)) { DXGI_FORMAT in_dxgi_format = in_format->dxgi_format;
out_support = TRUE; DXGI_FORMAT out_dxgi_format = chosen_format->dxgi_format;
} else { DXGI_COLOR_SPACE_TYPE in_dxgi_color_space =
GST_DEBUG_OBJECT (window, (DXGI_COLOR_SPACE_TYPE) in_color_space->dxgi_color_space_type;
"IVideoProcessor cannot support output dxgi format %d", DXGI_COLOR_SPACE_TYPE out_dxgi_color_space = native_colorspace_type;
out_format->dxgi_format);
}
if (!input_support || !out_support) { if (!gst_d3d11_video_processor_check_format_conversion (processor,
gst_d3d11_video_processor_free (window->processor); in_dxgi_format, in_dxgi_color_space, out_dxgi_format,
window->processor = NULL; out_dxgi_color_space)) {
} else { GST_DEBUG_OBJECT (window, "Conversion is not supported by device");
gboolean processor_input_configured = FALSE; gst_d3d11_video_processor_free (processor);
gboolean processor_output_configured = FALSE; processor = NULL;
} else {
GST_DEBUG_OBJECT (window, "video processor supports conversion");
gst_d3d11_video_processor_set_input_dxgi_color_space (processor,
in_dxgi_color_space);
gst_d3d11_video_processor_set_output_dxgi_color_space (processor,
out_dxgi_color_space);
GST_DEBUG_OBJECT (window, "IVideoProcessor interface available");
*video_processor_available = TRUE;
#if (DXGI_HEADER_VERSION >= 5) #if (DXGI_HEADER_VERSION >= 5)
if (have_hdr10) { if (have_hdr10) {
GST_DEBUG_OBJECT (window, "Set HDR metadata on video processor"); GST_DEBUG_OBJECT (window, "Set HDR metadata on video processor");
gst_d3d11_video_processor_set_input_hdr10_metadata (window->processor, gst_d3d11_video_processor_set_input_hdr10_metadata (processor,
&hdr10_metadata); &hdr10_metadata);
gst_d3d11_video_processor_set_output_hdr10_metadata (window->processor, gst_d3d11_video_processor_set_output_hdr10_metadata (processor,
&hdr10_metadata); &hdr10_metadata);
}
#endif
#if (DXGI_HEADER_VERSION >= 4)
{
DXGI_COLOR_SPACE_TYPE in_native_cs =
DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709;
const GstDxgiColorSpace *in_cs =
gst_d3d11_video_info_to_dxgi_color_space (&window->info);
if (in_cs) {
in_native_cs = (DXGI_COLOR_SPACE_TYPE) in_cs->dxgi_color_space_type;
} else {
GST_WARNING_OBJECT (window,
"Cannot figure out input dxgi color space");
if (GST_VIDEO_INFO_IS_RGB (&window->info)) {
in_native_cs = DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709;
} else {
in_native_cs = DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709;
}
} }
GST_DEBUG_OBJECT (window,
"Set color space on video processor, in %d, out %d",
in_native_cs, native_colorspace_type);
processor_input_configured =
gst_d3d11_video_processor_set_input_dxgi_color_space
(window->processor, in_native_cs);
processor_output_configured =
gst_d3d11_video_processor_set_output_dxgi_color_space
(window->processor, native_colorspace_type);
}
#endif #endif
if (!processor_input_configured) {
gst_d3d11_video_processor_set_input_color_space (window->processor,
&window->info.colorimetry);
} }
if (!processor_output_configured) { window->processor = processor;
gst_d3d11_video_processor_set_output_color_space (window->processor,
&window->render_info.colorimetry);
}
} }
} }
#endif
*video_processor_available = !!window->processor;
/* configure shader even if video processor is available for fallback */ /* configure shader even if video processor is available for fallback */
window->converter = window->converter =