D3D10 (DirectX10) 全屏性能問題 (D3D10 (DirectX10) fullscreen performance issue)


問題描述

D3D10 (DirectX10) 全屏性能問題 (D3D10 (DirectX10) fullscreen performance issue)

I have a bit of a problem setting up my DirectX10 (Win32/c++) application for fullscreen mode. The problem is that I want to have my app running in fullscreen right from the start. This can be done by taking the DXGISwapChain::SetFullScreenState function. This works, but i get a small notice in my Visualc++ 2008 debugger which states: 

"DXGI Warning: IDXGISwapChain::Present: Fullscreen presentation inefficiencies incurred due to application not using IDXGISwapChain::ResizeBuffers appropriately, specifying a DXGI_MODE_DESC not available in IDXGIOutput::GetDisplayModeList, or not using DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH."

What this means is that DirectX will not take full ownership of the graphicscard and flip the images from front to backbuffer but instead blit them which is much slower.

Now, i do have the DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH enabled and i did try to resize my buffers but i have absolutely no idea what would be the best way to go into fullscreen mode. I have looked on MSDN but there they mostly assume you will only go into Fullscreen by pressing Alt+Enter which lest DXGI do all the work. If someone please could post a bit of code which takes DirectX10 into fullscreen mode and takes full advantage of the "flipping" it would be greatly appriciated! 

For anybody interested in the code used on resize:

ReleaseCOM(m_pD3DRenderTargetView);
ReleaseCOM(m_pD3DDepthStencilView);
ReleaseCOM(m_pD3DDepthStencilBuffer);

DXGI_MODE_DESC* mod = new DXGI_MODE_DESC;
mod->Format = DXGI_FORMAT_R8G8B8A8_UNORM;
mod->Height = m_ScreenHeight;
mod->Width = m_ScreenWidth;
mod->RefreshRate.Denominator = 0;
mod->RefreshRate.Numerator = 0;
mod->ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
mod->Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
delete mod; mod = 0;

m_pSwapChain->ResizeTarget(mod);

HR(m_pSwapChain->ResizeBuffers(1, m_ScreenWidth, m_ScreenHeight, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH))
    throw(Exception(GET_BUFFER_FAIL, AT));

//problem area
m_pSwapChain->SetFullscreenState(TRUE, NULL);

ID3D10Texture2D* pBackBuffer;
HR( m_pSwapChain->GetBuffer(0, __uuidof(ID3D10Texture2D), (LPVOID*)&pBackBuffer))
    throw(Exception(GET_BUFFER_FAIL, AT)); //continues as usual

參考解法

方法 1:

Is there any reason you delete your mode desc?

Have you also tried putting your mode desc through "FindClosestMatchingMode"?

Check out http://msdn.microsoft.com/en-us/library/cc627095(VS.85).aspx The "Full-Screen issues" section contains a lot of useful information.

方法 2:

There are some prerequisites for enabling flipping in DXGI (which is the most efficient fullscreen presentation mode):

1) You should go into fullscreen state specifying a mode that exists in the system (you could do that either by using mode from IDXGIOutput::GetDisplayModeList or finding it using IDXGIOutput::FindClosestMatchingMode). Your code just specifies screen resolution, so most likely mode is set correctly.

2) After SetFullscreenState, you should call ResizeBuffers with the right buffer size matching mode, this is where DXGI would setup flipping mode. Typically, it should happen naturally as reaction to WM_SIZE message send by SetFullscreenState transition, so if your app doesn't call ResizeBuffers on WM_SIZE, it probably should. You can call ResizeBuffers manually after SetFullscreenState and that should work as well.

And yeah, MSDN has a good article about DXGI practices, including fullscreen transition: http://msdn.microsoft.com/en-us/library/cc627095(VS.85).aspx#Full_Screen_Issues

(by Rik NautaGozSimon Kozlov)

參考文件

  1. D3D10 (DirectX10) fullscreen performance issue (CC BY-SA 3.0/4.0)

#directx-10 #performance #fullscreen #directx






相關問題

D3D10 (DirectX10) 全屏性能問題 (D3D10 (DirectX10) fullscreen performance issue)

directx10 中的精靈和紋理過濾 (Sprites in directx10 and texture filtering)

Firemonkey 中的 DirectX10 支持(非 10.1) (DirectX10 support in Firemonkey (not 10.1))

錯誤 LNK2019 Directx10 VC++2010 (Error LNK2019 Directx10 VC++2010)

管理 HLSL 效果 (Managing HLSL effects)

D3DX10CreateTextureFromFile 返回未知錯誤 (D3DX10CreateTextureFromFile returns unknown error)

使用 HLSL 變量分配 struct C++ (Assign struct C++ with HLSL variable)

ID3DX10Mesh::CloneMesh (ID3DX10Mesh::CloneMesh)

在 DirectX 10 中清除單個視口 (Clear single viewport in DirectX 10)

Visual c++ DirectX 編譯錯誤 (Visual c++ DirectX compilation error)

將 ID3D11Texture2D 轉換為內存緩衝區 (Convert ID3D11Texture2D into a memory buffer)

DirectX 10.1 / C++:如何通過 ID3D10Resource* 紋理在精靈上渲染文本? (DirectX 10.1 / C++: How to render text on sprite over ID3D10Resource* textures?)







留言討論