Stack Overflow Asked by David Wohlferd on November 28, 2020

This is a followon to this question about using the DX11VideoRenderer sample (a replacement for EVR that uses DirectX11 instead of EVR’s DirectX9).

I’ve been trying to track down why it uses so much more CPU than the EVR. Task Manager shows me that most of that time is kernel mode.

Using profiling tools, I see that a LOT of time is being spent in numerous calls to NtDelayExecution (aka Sleep). How many calls? ~100,000 over the course of ~12 seconds. Ok, yeah, I’m sending a lot of frames in those 12 seconds, but that’s still a lot of calls, every one of which requires a kernel mode transition.

The callstack shows the last call in "my" code is to IDXGISwapChain1::Present(0, 0). The actual call seems be Sleep(0) and comes from nvwgf2umx.dll (which is why this question is tagged NVidia: hopefully someone there can call up the code and see what the logic is behind such frequent calls).

I couldn’t quite figure out why it would need to do /any/ Sleeping during Present. It’s not like we wait for vertical retrace anymore, is it? But the other reason to use Sleep has to do with yielding to other threads. Which led me to a serious clue:

If I use D3D11_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS, the CPU utilization drops. Along with some other fixes, the DX11 version is now faster and uses less CPU time than the DX9 version (which is what I would hope/expect). Profiling shows that Sleep has dropped from >30% to <1%.

Unfortunately, this page tells me:

This flag is not recommended for general use.


So, any ideas on how to get decent performance without using debug flags?

Add your own answers!

Related Questions

Get all tables where there is no booking on this time or date

2  Asked on November 24, 2021 by tierno


How to remove first view pager item in kotlin?

1  Asked on November 24, 2021 by marlen-schreiner


Pandas update values using loc with repeated indices

2  Asked on November 24, 2021 by tyler-klein


ORDER BY with priority

2  Asked on November 22, 2021 by ush_63100


Get frequency of tokens by group in pandas

1  Asked on November 22, 2021 by ravanelli


Repeat vector elements according to values in matrix

2  Asked on November 22, 2021 by maksim-tarasenko


Ask a Question

Get help from others!

© 2022 All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir