d3d11videosink: Fix tearing in case of fullscreen mode
authorSeungha Yang <seungha@centricular.com>
Wed, 15 Mar 2023 13:05:33 +0000 (22:05 +0900)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 16 Mar 2023 15:33:37 +0000 (15:33 +0000)
DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING and DXGI_PRESENT_ALLOW_TEARING should
be used only if required, when user wants Vsync off for example.

Fixes: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/2376
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4188>

subprojects/gst-plugins-bad/sys/d3d11/gstd3d11window.cpp
subprojects/gst-plugins-bad/sys/d3d11/gstd3d11window.h

index 85be423..52835e0 100644 (file)
@@ -560,9 +560,6 @@ gst_d3d11_window_prepare_default (GstD3D11Window * window, guint display_width,
       DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709;
   gboolean hdr10_aware = FALSE;
   gboolean have_hdr10_meta = FALSE;
-  ComPtr < IDXGIFactory5 > factory5;
-  IDXGIFactory1 *factory_handle;
-  BOOL allow_tearing = FALSE;
   GstVideoMasteringDisplayInfo mdcv;
   GstVideoContentLightLevel cll;
   ComPtr < IDXGISwapChain3 > swapchain3;
@@ -663,23 +660,6 @@ gst_d3d11_window_prepare_default (GstD3D11Window * window, guint display_width,
 
   /* Step 3: Create swapchain
    * (or reuse old swapchain if the format is not changed) */
-  window->allow_tearing = FALSE;
-
-  factory_handle = gst_d3d11_device_get_dxgi_factory_handle (device);
-  hr = factory_handle->QueryInterface (IID_PPV_ARGS (&factory5));
-  if (SUCCEEDED (hr)) {
-    hr = factory5->CheckFeatureSupport (DXGI_FEATURE_PRESENT_ALLOW_TEARING,
-        (void *) &allow_tearing, sizeof (allow_tearing));
-  }
-
-  if (SUCCEEDED (hr) && allow_tearing)
-    window->allow_tearing = allow_tearing;
-
-  if (window->allow_tearing) {
-    GST_DEBUG_OBJECT (window, "device supports tearing");
-    swapchain_flags |= DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING;
-  }
-
   GstD3D11DeviceLockGuard lk (device);
   window->dxgi_format = chosen_format->dxgi_format;
 
@@ -860,7 +840,6 @@ gst_d3d111_window_present (GstD3D11Window * self, GstBuffer * buffer,
 {
   GstD3D11WindowClass *klass = GST_D3D11_WINDOW_GET_CLASS (self);
   GstFlowReturn ret = GST_FLOW_OK;
-  guint present_flags = 0;
   GstVideoCropMeta *crop_meta;
   RECT input_rect = self->input_rect;
   RECT *prev_rect = &self->prev_input_rect;
@@ -948,15 +927,12 @@ gst_d3d111_window_present (GstD3D11Window * self, GstBuffer * buffer,
   gst_d3d11_overlay_compositor_upload (self->compositor, buffer);
   gst_d3d11_overlay_compositor_draw_unlocked (self->compositor, &rtv);
 
-  if (self->allow_tearing && self->fullscreen)
-    present_flags |= DXGI_PRESENT_ALLOW_TEARING;
-
   if (klass->present) {
     if (self->emit_present) {
       g_signal_emit (self, d3d11_window_signals[SIGNAL_PRESENT], 0,
           self->device, rtv, nullptr);
     }
-    ret = klass->present (self, present_flags);
+    ret = klass->present (self, 0);
   }
 
   self->first_present = FALSE;
index 5a836ec..74dde52 100644 (file)
@@ -112,7 +112,6 @@ struct _GstD3D11Window
 
   GstBuffer *cached_buffer;
   gboolean first_present;
-  gboolean allow_tearing;
 
   GstVideoOrientationMethod method;
 };