New issue
Advanced search Search tips

Issue 892874 link

Starred by 1 user

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug



Sign in to add a comment

Optimize presentation feedback on Windows

Project Member Reported by sunn...@chromium.org, Oct 6

Issue description

Presentation feedback on Windows uses GPUTimer which wraps command buffer queries and ultimately d3d11 fences through ANGLE.  This is suboptimal because it uses quite a bit of CPU (measured ~3% using ETW profiling).  It is also incorrect because completion of GPU work is not the same as presentation, and there's no way to determine latency after GPU work is complete.

I experimented with using DXGI_FRAME_STATISTICS from IDXGISwapChain::GetFrameStatistics(), and it looks like we can use it this way:
1) Num. of outstanding Presents = Num. of times Present() is called - stats.PresentCount (Num. of Presents() displayed on screen)
2) Present latency in DWM = stats.SyncRefreshCount - stats.PresentRefreshCount

There's some complexity because with DirectComposition the root surface switches between swap chain and IDCompositionSurface, and we can use get frame statistics only from swap chains.  Here's a prototype with support for EGLTimestampClient in DirectCompositionSurfaceWin using frame statistics with fallback when swap chain isn't used: https://chromium-review.googlesource.com/c/chromium/src/+/1266696

Making this work for non-DirectComposition path will involve more work, maybe exposing the swap chain via ANGLE?  geofflang@ jmadill@ thoughts?
 
ANGLE exposes the EGL_CHROMIUM_get_sync_values extension on D3D11 (https://chromium.googlesource.com/angle/angle/+/master/extensions/EGL_CHROMIUM_get_sync_values.txt) and we implement it with IDXGISwapChain::GetFrameStatistics() (https://cs.chromium.org/chromium/src/third_party/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp?l=1037)

Is this enough to implement the timing you need?


Thanks!

Sync values should be sufficient to calculate number of outstanding frames for presentation feedback.

Calculating DWM present latency needs PresentRefreshCount which isn't present in sync values.  That's not a high priority right now though.
Note: GetFrameStatistics only works for fullscreen (DXGI_SWAP_CHAIN_DESC::Windowed) swap chains, or flip mode swap chains both windowed and fullscreen.  So the ANGLE extension won't really work here, but that's ok since we've gone back to using direct composition whenever possible anyway.

Sign in to add a comment