d3d11window: Fix for broken dirty rect drawing on Windows 7
authorSeungha Yang <seungha.yang@navercorp.com>
Wed, 12 Feb 2020 13:29:31 +0000 (22:29 +0900)
committerSeungha Yang <seungha.yang@navercorp.com>
Wed, 12 Feb 2020 13:38:53 +0000 (22:38 +0900)
DXGI_SWAP_EFFECT_DISCARD cannot be used with dirty rect drawing feature
of IDXGISwapChain1::Present().
Note that IDXGISwapChain1 interface is available on Platform Update for Windows 7
and DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL is also the case.

sys/d3d11/gstd3d11window_win32.cpp

index 9e1dcc6225ed557d9fe0f7db38594f56ece80665..01557b5942a82de93efbcb64f8a3ef8c07932d49 100644 (file)
@@ -717,13 +717,9 @@ gst_d3d11_window_win32_create_swap_chain (GstD3D11Window * window,
 {
   GstD3D11WindowWin32 *self = GST_D3D11_WINDOW_WIN32 (window);
   DXGI_SWAP_CHAIN_DESC desc = { 0, };
-  DXGI_SWAP_EFFECT swap_effect = DXGI_SWAP_EFFECT_DISCARD;
   IDXGISwapChain *new_swapchain = NULL;
   GstD3D11Device *device = window->device;
 
-  if (gst_d3d11_is_windows_8_or_greater ())
-    swap_effect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
-
   self->have_swapchain1 = FALSE;
 
 #if (DXGI_HEADER_VERSION >= 2)
@@ -744,7 +740,7 @@ gst_d3d11_window_win32_create_swap_chain (GstD3D11Window * window,
      * but Windows7 does not support this method */
     if (gst_d3d11_is_windows_8_or_greater ())
       desc1.Scaling = DXGI_SCALING_NONE;
-    desc1.SwapEffect = swap_effect;
+    desc1.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
     desc1.AlphaMode = DXGI_ALPHA_MODE_UNSPECIFIED;
     desc1.Flags = swapchain_flags;
 
@@ -761,6 +757,11 @@ gst_d3d11_window_win32_create_swap_chain (GstD3D11Window * window,
 #endif
 
   if (!new_swapchain) {
+    DXGI_SWAP_EFFECT swap_effect = DXGI_SWAP_EFFECT_DISCARD;
+
+    if (gst_d3d11_is_windows_8_or_greater ())
+      swap_effect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
+
     /* we will get client area at on_resize */
     desc.BufferDesc.Width = 0;
     desc.BufferDesc.Height = 0;