d3d11decoder: Disable zero-copy for blacklisted device
authorSeungha Yang <seungha@centricular.com>
Mon, 15 Jun 2020 12:10:09 +0000 (21:10 +0900)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Tue, 16 Jun 2020 10:49:02 +0000 (10:49 +0000)
Should enable it for verified devices. For now, Xbox is blacklisted

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1339>

sys/d3d11/gstd3d11decoder.c
sys/d3d11/gstd3d11decoder.h
sys/d3d11/gstd3d11h264dec.c
sys/d3d11/gstd3d11h265dec.c
sys/d3d11/gstd3d11vp8dec.c
sys/d3d11/gstd3d11vp9dec.c

index 3903557..e211f48 100644 (file)
@@ -92,6 +92,9 @@ struct _GstD3D11DecoderPrivate
 
   GUID decoder_profile;
 
+  /* For device specific workaround */
+  gboolean is_xbox_device;
+
   /* for internal shader */
   GstD3D11ColorConverter *converter;
   ID3D11Texture2D *shader_resource_texture;
@@ -673,6 +676,8 @@ gst_d3d11_decoder_open (GstD3D11Decoder * decoder, GstD3D11Codec codec,
 
   gst_d3d11_decoder_reset_unlocked (decoder);
 
+  priv->is_xbox_device = gst_d3d11_is_xbox_device (priv->device);
+
   /* NOTE: other dxva implementations (ffmpeg and vlc) do this
    * and they say the required alignment were mentioned by dxva spec.
    * See ff_dxva2_common_frame_params() in dxva.c of ffmpeg and
@@ -681,7 +686,7 @@ gst_d3d11_decoder_open (GstD3D11Decoder * decoder, GstD3D11Codec codec,
   switch (codec) {
     case GST_D3D11_CODEC_H265:
       /* See directx_va_Setup() impl. in vlc */
-      if (!gst_d3d11_is_xbox_device (priv->device))
+      if (!priv->is_xbox_device)
         alignment = 128;
       else
         alignment = 16;
@@ -1591,6 +1596,20 @@ gst_d3d11_decoder_decide_allocation (GstVideoDecoder * decoder,
   return TRUE;
 }
 
+gboolean
+gst_d3d11_decoder_supports_direct_rendering (GstD3D11Decoder * decoder)
+{
+  GstD3D11DecoderPrivate *priv;
+
+  g_return_val_if_fail (GST_IS_D3D11_DECODER (decoder), FALSE);
+
+  priv = decoder->priv;
+
+  /* FIXME: Need to figure out Xbox device's behavior
+   * https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/issues/1312
+   */
+  return !priv->is_xbox_device;
+}
 
 /* Keep sync with chromium and keep in sorted order.
  * See supported_profile_helpers.cc in chromium */
index aa59050..50dacc3 100644 (file)
@@ -152,6 +152,8 @@ gboolean          gst_d3d11_decoder_decide_allocation   (GstVideoDecoder * decod
                                                          GstD3D11Codec codec,
                                                          gboolean use_d3d11_pool);
 
+gboolean          gst_d3d11_decoder_supports_direct_rendering (GstD3D11Decoder * decoder);
+
 /* Utils for class registration */
 gboolean          gst_d3d11_decoder_util_is_legacy_device (GstD3D11Device * device);
 
index e180cfb..9bdc2ad 100644 (file)
@@ -631,6 +631,7 @@ gst_d3d11_h264_dec_output_picture (GstH264Decoder * decoder,
    * we cannot do that since baseclass will store the decoded buffer
    * up to gop size but our dpb pool cannot be increased */
   if (self->use_d3d11_output &&
+      gst_d3d11_decoder_supports_direct_rendering (self->d3d11_decoder) &&
       GST_VIDEO_DECODER (self)->input_segment.rate > 0) {
     GstMemory *mem;
 
index c3b0028..8dce255 100644 (file)
@@ -671,6 +671,7 @@ gst_d3d11_h265_dec_output_picture (GstH265Decoder * decoder,
    * we cannot do that since baseclass will store the decoded buffer
    * up to gop size but our dpb pool cannot be increased */
   if (self->use_d3d11_output &&
+      gst_d3d11_decoder_supports_direct_rendering (self->d3d11_decoder) &&
       GST_VIDEO_DECODER (self)->input_segment.rate > 0) {
     GstMemory *mem;
 
index d06f17f..9402bbb 100644 (file)
@@ -401,6 +401,7 @@ gst_d3d11_vp8_dec_output_picture (GstVp8Decoder * decoder,
    * we cannot do that since baseclass will store the decoded buffer
    * up to gop size but our dpb pool cannot be increased */
   if (self->use_d3d11_output &&
+      gst_d3d11_decoder_supports_direct_rendering (self->d3d11_decoder) &&
       GST_VIDEO_DECODER (self)->input_segment.rate > 0) {
     GstMemory *mem;
 
index c22a980..9b94d56 100644 (file)
@@ -502,6 +502,7 @@ gst_d3d11_vp9_dec_output_picture (GstVp9Decoder * decoder,
    * we cannot do that since baseclass will store the decoded buffer
    * up to gop size but our dpb pool cannot be increased */
   if (self->use_d3d11_output &&
+      gst_d3d11_decoder_supports_direct_rendering (self->d3d11_decoder) &&
       GST_VIDEO_DECODER (self)->input_segment.rate > 0 &&
       GST_VIDEO_INFO_WIDTH (&self->output_state->info) ==
       picture->frame_hdr.width