4
4
5
5
#include " ../util/util_misc.h"
6
6
7
+ #include < d3d12.h>
8
+
7
9
namespace dxvk {
8
10
9
11
DxgiSwapChain::DxgiSwapChain (
10
12
DxgiFactory* pFactory,
11
13
IDXGIVkSwapChain* pPresenter,
12
14
HWND hWnd,
13
15
const DXGI_SWAP_CHAIN_DESC1* pDesc,
14
- const DXGI_SWAP_CHAIN_FULLSCREEN_DESC* pFullscreenDesc)
16
+ const DXGI_SWAP_CHAIN_FULLSCREEN_DESC* pFullscreenDesc,
17
+ IUnknown* pDevice)
15
18
: m_factory (pFactory),
16
19
m_window (hWnd),
17
20
m_desc (*pDesc),
18
21
m_descFs (*pFullscreenDesc),
19
22
m_presentId (0u ),
20
23
m_presenter (pPresenter),
21
- m_monitor (wsi::getWindowMonitor(m_window)) {
24
+ m_monitor (wsi::getWindowMonitor(m_window)),
25
+ m_is_d3d12(SUCCEEDED(pDevice->QueryInterface (__uuidof(ID3D12CommandQueue), reinterpret_cast<void**>(&Com<ID3D12CommandQueue>())))) {
26
+
22
27
if (FAILED (m_presenter->GetAdapter (__uuidof (IDXGIAdapter), reinterpret_cast <void **>(&m_adapter))))
23
28
throw DxvkError (" DXGI: Failed to get adapter for present device" );
24
29
@@ -243,7 +248,9 @@ namespace dxvk {
243
248
BOOL* pFullscreen,
244
249
IDXGIOutput** ppTarget) {
245
250
HRESULT hr = S_OK;
246
-
251
+
252
+ if (!m_is_d3d12 && !m_descFs.Windowed && wsi::isOccluded (m_window))
253
+ SetFullscreenState (FALSE , nullptr );
247
254
if (pFullscreen != nullptr )
248
255
*pFullscreen = !m_descFs.Windowed ;
249
256
@@ -325,6 +332,10 @@ namespace dxvk {
325
332
if (SyncInterval > 4 )
326
333
return DXGI_ERROR_INVALID_CALL;
327
334
335
+ if ((m_desc.SwapEffect == DXGI_SWAP_EFFECT_DISCARD || m_desc.SwapEffect == DXGI_SWAP_EFFECT_SEQUENTIAL) && wsi::isMinimized (m_window))
336
+ return DXGI_STATUS_OCCLUDED;
337
+ bool occluded = !m_descFs.Windowed && wsi::isOccluded (m_window) && !wsi::isMinimized (m_window);
338
+
328
339
auto options = m_factory->GetOptions ();
329
340
330
341
if (options->syncInterval >= 0 )
@@ -342,7 +353,7 @@ namespace dxvk {
342
353
}
343
354
344
355
if (PresentFlags & DXGI_PRESENT_TEST)
345
- return hr;
356
+ return hr == S_OK && occluded ? DXGI_STATUS_OCCLUDED : hr ;
346
357
347
358
if (hr == S_OK) {
348
359
@@ -365,6 +376,11 @@ namespace dxvk {
365
376
monitorData->FrameStats .PresentRefreshCount = monitorData->FrameStats .SyncRefreshCount + computeRefreshCount (t0, t1, refreshPeriod);
366
377
ReleaseMonitorData ();
367
378
}
379
+ if (occluded) {
380
+ if (!(PresentFlags & DXGI_PRESENT_TEST))
381
+ SetFullscreenState (FALSE , nullptr );
382
+ hr = DXGI_STATUS_OCCLUDED;
383
+ }
368
384
}
369
385
370
386
return hr;
0 commit comments