3

我有 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 毫秒。我需要完全禁用合成还是有其他方法可以避免合成应用额外的延迟?

4

1 回答 1

1

经过一些试验,我设法找到了一个解决方案:除了指针可视化反馈之外,禁用系统覆盖将禁用全屏模式下的合成,并且演示将作为独立翻转执行。以下代码应添加到::Windows::ApplicationModel::Core::IFrameworkView::SetWindow方法实现中:

::Windows::UI::Input::PointerVisualizationSettings ^ h_visualization_settings{::Windows::UI::Input::PointerVisualizationSettings::GetForCurrentView()};
h_visualization_settings->IsContactFeedbackEnabled = false;
h_visualization_settings->IsBarrelButtonFeedbackEnabled = false;
::Windows::UI::ViewManagement::ApplicationView ^ h_view{::Windows::UI::ViewManagement::ApplicationView::GetForCurrentView()};
h_view->FullScreenSystemOverlayMode = ::Windows::UI::ViewManagement::FullScreenSystemOverlayMode::Minimal;

请注意,它并没有完全禁用覆盖,它只是首先显示一个小栏,用户需要单击以显示相应的覆盖项,例如任务栏。

于 2017-05-10T09:21:26.003 回答