giladreich / QtDirect3D

QDirect3DWidget implementation similar to the built-in QOpenGLWidget
MIT License
139 stars 26 forks source link

DXGI WARNING: IDXGIFactory::CreateSwapChain: Blt-model swap effects are legacy swap effects. #8

Open ghost opened 3 years ago

ghost commented 3 years ago

Blt-model swap effects are legacy swap effects that are predominantly superseded by their flip-model counterparts. Adjustment to the resize event is required to avoid flickering with the flip model. http://aka.ms/dxgiflipmodel

Component QDirect3D10Widget QDirect3D11Widget

diff --git a/source/QDirect3D10Widget/ImGui/QDirect3D10Widget.cpp b/source/QDirect3D10Widget/ImGui/QDirect3D10Widget.cpp
index 253b3c7..47de9f7 100644
--- a/source/QDirect3D10Widget/ImGui/QDirect3D10Widget.cpp
+++ b/source/QDirect3D10Widget/ImGui/QDirect3D10Widget.cpp
@@ -110,7 +110,7 @@ bool QDirect3D10Widget::init()
     sd.SampleDesc.Count                   = 1;
     sd.SampleDesc.Quality                 = 0;
     sd.Windowed                           = TRUE;
-    sd.SwapEffect                         = DXGI_SWAP_EFFECT_DISCARD;
+    sd.SwapEffect                         = DXGI_SWAP_EFFECT_FLIP_DISCARD;

     UINT iCreateFlags = 0;
 #if defined(DEBUG) || defined(_DEBUG)
diff --git a/source/QDirect3D10Widget/QDirect3D10Widget.cpp b/source/QDirect3D10Widget/QDirect3D10Widget.cpp
index 0d3ecea..c9b4512 100644
--- a/source/QDirect3D10Widget/QDirect3D10Widget.cpp
+++ b/source/QDirect3D10Widget/QDirect3D10Widget.cpp
@@ -102,7 +102,7 @@ bool QDirect3D10Widget::init()
     sd.SampleDesc.Count                   = 1;
     sd.SampleDesc.Quality                 = 0;
     sd.Windowed                           = TRUE;
-    sd.SwapEffect                         = DXGI_SWAP_EFFECT_DISCARD;
+    sd.SwapEffect                         = DXGI_SWAP_EFFECT_FLIP_DISCARD;

     UINT iCreateFlags = 0;
 #if defined(DEBUG) || defined(_DEBUG)
diff --git a/source/QDirect3D11Widget/ImGui/QDirect3D11Widget.cpp b/source/QDirect3D11Widget/ImGui/QDirect3D11Widget.cpp
index 1b8c705..a462fd4 100644
--- a/source/QDirect3D11Widget/ImGui/QDirect3D11Widget.cpp
+++ b/source/QDirect3D11Widget/ImGui/QDirect3D11Widget.cpp
@@ -112,7 +112,7 @@ bool QDirect3D11Widget::init()
     sd.SampleDesc.Count                   = 1;
     sd.SampleDesc.Quality                 = 0;
     sd.Windowed                           = TRUE;
-    sd.SwapEffect                         = DXGI_SWAP_EFFECT_DISCARD;
+    sd.SwapEffect                         = DXGI_SWAP_EFFECT_FLIP_DISCARD;

     UINT iCreateFlags = 0;
 #if defined(DEBUG) || defined(_DEBUG)
diff --git a/source/QDirect3D11Widget/QDirect3D11Widget.cpp b/source/QDirect3D11Widget/QDirect3D11Widget.cpp
index e901039..4c966a6 100644
--- a/source/QDirect3D11Widget/QDirect3D11Widget.cpp
+++ b/source/QDirect3D11Widget/QDirect3D11Widget.cpp
@@ -104,7 +104,7 @@ bool QDirect3D11Widget::init()
     sd.SampleDesc.Count                   = 1;
     sd.SampleDesc.Quality                 = 0;
     sd.Windowed                           = TRUE;
-    sd.SwapEffect                         = DXGI_SWAP_EFFECT_DISCARD;
+    sd.SwapEffect                         = DXGI_SWAP_EFFECT_FLIP_DISCARD;

     UINT iCreateFlags = 0;
 #if defined(DEBUG) || defined(_DEBUG)
giladreich commented 3 years ago

Hi @wroy-ca,

Good catch and this indeed sounds reasonable to me. I think the main reason it was set like this was in order to stick to the official examples as in ImGui. I will be very happy to receive a PR from you for that. :)

Thanks a lot and appreciate your contributions! 🍻

ghost commented 3 years ago

Hi @wroy-ca,

Good catch and this indeed sounds reasonable to me. I think the main reason it was set like this was in order to stick to the official examples as in ImGui. I will be very happy to receive a PR from you for that. :)

Thanks a lot and appreciate your contributions! 🍻

It appears that DXGI_SWAP_EFFECT_FLIP_DISCARD is affected by #10 and will in fact makes it worst. Perhaps the three issues should be merged in one?