我有 DirectX11 UWP 应用程序。IDXGIFactory2::CreateSwapChainForCoreWindow
我使用常用参数创建交换链。
::DXGI_SWAP_CHAIN_DESC1 desc{};
desc.Width = back_buffer_width;
desc.Height = back_buffer_height;
desc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
desc.SampleDesc.Count = 1;
desc.SampleDesc.Quality = 0;
desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
desc.BufferCount = 2;
desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
desc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH | DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT;
desc.Scaling = DXGI_SCALING_NONE;
desc.AlphaMode = DXGI_ALPHA_MODE_IGNORE;
::Microsoft::WRL::ComPtr< ::IDXGISwapChain1 > p_swap_chain;
Validate_OkResult
(
p_dxgi_factory->CreateSwapChainForCoreWindow
(
p_d3d_device.Get()
, reinterpret_cast< ::IUnknown * >(h_window) // passing ::Windows::UI::Core::CoreWindow ^
, ::std::addressof(desc)
, nullptr
, &p_swap_chain
)
);
Validate_OkResult(p_swap_chain->SetMaximumFrameLatency(1)); // 1 is minimum allowed value
当我尝试通过调用::IDXGISwapChain::SetFullscreenState
它来将其更改为全屏模式时失败,DXGI_ERROR_NOT_CURRENTLY_AVAILABLE
并且我得到以下诊断:
DXGI 错误:IDXGISwapChain::SetFullscreenState:核心窗口交换链无法转换为全屏,因为它们被认为是永久窗口化的。[杂项错误#163:]
DXGI 错误:IDXGISwapChain::SetFullscreenState:对于现代应用程序,全屏不可用。所有交换链都必须是窗口化的。[杂项错误#206:]
我发现我可以使用以下方法切换全屏模式ApplicationView
:
::Windows::UI::ViewManagement::ApplicationView ^ h_view(::Windows::UI::ViewManagement::ApplicationView::GetForCurrentView());
if(h_view->IsFullScreenMode)
{
h_view->ExitFullScreenMode();
}
else
{
h_view->TryEnterFullScreenMode();
}
但是这种方法只隐藏任务栏,隐藏窗口框架和最大化窗口。我认为在这种情况下通过翻转模型演示应该可以获得通常全屏交换链的低延迟优势,但这似乎不是两个工作并且交换链继续组合。复合翻转仍用于演示,演示延迟与窗口模式下保持相同约 30 毫秒。我需要完全禁用合成还是有其他方法可以避免合成应用额外的延迟?