From ed70de55cf70cd6b2a586b6b013d285b0c09f04d Mon Sep 17 00:00:00 2001 From: jpark37 Date: Mon, 7 Mar 2022 21:01:20 -0800 Subject: [PATCH] libobs-d3d11: Relax minimum Windows for flip model We'll need flip model swap chains in the future for HDR, and we don't want to limit HDR to WIndows 11. The new test is the existence of IDXGIFactory5, which was introduced in Windows 10 1607. This should be enough for HDR, for which we use APIs in Windows 10 1703. Hopefully having SetMaximumFrameLatency(40) this time will make enough of a difference to not bring back reports of degraded performance when using flip model on Windows 10. --- libobs-d3d11/d3d11-subsystem.cpp | 37 +++++++++----------------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/libobs-d3d11/d3d11-subsystem.cpp b/libobs-d3d11/d3d11-subsystem.cpp index 088676f28..76f05a708 100644 --- a/libobs-d3d11/d3d11-subsystem.cpp +++ b/libobs-d3d11/d3d11-subsystem.cpp @@ -184,40 +184,24 @@ gs_swap_chain::gs_swap_chain(gs_device *device, const gs_init_data *data) hwnd((HWND)data->window.hwnd), initData(*data) { - struct win_version_info ver; - get_win_ver(&ver); - - constexpr win_version_info minimum = [] { - win_version_info ver{}; - ver.major = 10; - ver.minor = 0; - ver.build = 22000; - ver.revis = 0; - return ver; - }(); - DXGI_SWAP_EFFECT effect = DXGI_SWAP_EFFECT_DISCARD; UINT flags = 0; - if (win_version_compare(&ver, &minimum) >= 0) { + ComQIPtr factory5 = device->factory; + if (factory5) { initData.num_backbuffers = max(data->num_backbuffers, 2); effect = DXGI_SWAP_EFFECT_FLIP_DISCARD; flags |= DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT; - ComPtr factory5; - factory5 = ComQIPtr(device->factory); - if (factory5) { - BOOL featureSupportData = FALSE; - const HRESULT hr = factory5->CheckFeatureSupport( - DXGI_FEATURE_PRESENT_ALLOW_TEARING, - &featureSupportData, - sizeof(featureSupportData)); - if (SUCCEEDED(hr) && featureSupportData) { - presentFlags |= DXGI_PRESENT_ALLOW_TEARING; + BOOL featureSupportData = FALSE; + const HRESULT hr = factory5->CheckFeatureSupport( + DXGI_FEATURE_PRESENT_ALLOW_TEARING, &featureSupportData, + sizeof(featureSupportData)); + if (SUCCEEDED(hr) && featureSupportData) { + presentFlags |= DXGI_PRESENT_ALLOW_TEARING; - flags |= DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING; - } + flags |= DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING; } } @@ -1378,8 +1362,7 @@ void device_resize(gs_device_t *device, uint32_t cx, uint32_t cy) } try { - ID3D11RenderTargetView *renderView = NULL; - device->context->OMSetRenderTargets(1, &renderView, NULL); + device->context->OMSetRenderTargets(0, NULL, NULL); device->curSwapChain->Resize(cx, cy); device->curFramebufferInvalidate = true; } catch (const HRError &error) {