Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AtlasEngine: Remove support for Windows 7 #13608

Merged
1 commit merged into from
Jul 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 4 additions & 23 deletions src/renderer/atlas/AtlasEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,17 +423,10 @@ void AtlasEngine::WaitUntilCanRender() noexcept
{
if constexpr (!debugGeneralPerformance)
{
if (_r.frameLatencyWaitableObject)
{
WaitForSingleObjectEx(_r.frameLatencyWaitableObject.get(), 100, true);
WaitForSingleObjectEx(_r.frameLatencyWaitableObject.get(), 100, true);
#ifndef NDEBUG
_r.frameLatencyWaitableObjectUsed = true;
_r.frameLatencyWaitableObjectUsed = true;
#endif
}
else
{
Sleep(8);
}
}
}

Expand Down Expand Up @@ -798,8 +791,6 @@ void AtlasEngine::_createSwapChain()

// D3D swap chain setup (the thing that allows us to present frames on the screen)
{
const auto supportsFrameLatencyWaitableObject = !debugGeneralPerformance && IsWindows8Point1OrGreater();

// With C++20 we'll finally have designated initializers.
DXGI_SWAP_CHAIN_DESC1 desc{};
desc.Width = _api.sizeInPixel.x;
Expand All @@ -814,25 +805,17 @@ void AtlasEngine::_createSwapChain()
// * If our background is opaque we can enable "independent" flips by setting DXGI_SWAP_EFFECT_FLIP_DISCARD and DXGI_ALPHA_MODE_IGNORE.
// As our swap chain won't have to compose with DWM anymore it reduces the display latency dramatically.
desc.AlphaMode = _api.hwnd || _api.backgroundOpaqueMixin ? DXGI_ALPHA_MODE_IGNORE : DXGI_ALPHA_MODE_PREMULTIPLIED;
desc.Flags = supportsFrameLatencyWaitableObject ? DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT : 0;
desc.Flags = DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT;

wil::com_ptr<IDXGIFactory2> dxgiFactory;
THROW_IF_FAILED(CreateDXGIFactory1(IID_PPV_ARGS(dxgiFactory.addressof())));

if (_api.hwnd)
{
if (FAILED(dxgiFactory->CreateSwapChainForHwnd(_r.device.get(), _api.hwnd, &desc, nullptr, nullptr, _r.swapChain.put())))
{
// Platform Update for Windows 7:
// DXGI_SCALING_NONE is not supported on Windows 7 or Windows Server 2008 R2 with the Platform Update for
// Windows 7 installed and causes CreateSwapChainForHwnd to return DXGI_ERROR_INVALID_CALL when called.
desc.Scaling = DXGI_SCALING_STRETCH;
THROW_IF_FAILED(dxgiFactory->CreateSwapChainForHwnd(_r.device.get(), _api.hwnd, &desc, nullptr, nullptr, _r.swapChain.put()));
}
THROW_IF_FAILED(dxgiFactory->CreateSwapChainForHwnd(_r.device.get(), _api.hwnd, &desc, nullptr, nullptr, _r.swapChain.put()));
}
else
{
// We can't link with dcomp.lib as dcomp.dll doesn't exist on Windows 7.
const wil::unique_hmodule module{ LoadLibraryExW(L"dcomp.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32) };
THROW_LAST_ERROR_IF(!module);
const auto DCompositionCreateSurfaceHandle = GetProcAddressByFunctionDeclaration(module.get(), DCompositionCreateSurfaceHandle);
Expand All @@ -844,10 +827,8 @@ void AtlasEngine::_createSwapChain()
THROW_IF_FAILED(dxgiFactory.query<IDXGIFactoryMedia>()->CreateSwapChainForCompositionSurfaceHandle(_r.device.get(), _api.swapChainHandle.get(), &desc, nullptr, _r.swapChain.put()));
}

if (supportsFrameLatencyWaitableObject)
{
const auto swapChain2 = _r.swapChain.query<IDXGISwapChain2>();
THROW_IF_FAILED(swapChain2->SetMaximumFrameLatency(1)); // TODO: 2?
_r.frameLatencyWaitableObject.reset(swapChain2->GetFrameLatencyWaitableObject());
THROW_LAST_ERROR_IF(!_r.frameLatencyWaitableObject);
}
Expand Down