r/GraphicsProgramming • u/[deleted] • Aug 22 '20
Why directxtk11 sample runs faster than imgui dx11 sample on empty scene?
I removed all the rendering and only called the ClearRenderTargetView. I even tried checking it in renderdoc but even though directxtk renders those models, it is still faster than imgui dx11 sample. I tried both imgui's sdl and win32 samples both slower than directxtk.
I've been figuring this for over 2 days now but I can't figure out what's happening.
Directxtk11: https://github.com/walbourn/directxtk-samples/blob/master/SimpleSampleWin32/Game.cppImgui + Win32: https://github.com/ocornut/imgui/blob/master/examples/example_win32_directx11/main.cpp
Imgui + SDL2: https://github.com/ocornut/imgui/blob/master/examples/example_sdl_directx11/main.cpp
I also tried bgfx example0 in dx11 build and it runs constantly at 60fps.
Btw, I ran all of these in my windows 10 vmware.
EDIT: I looked at bgfx renderer_d3d11.h ( https://github.com/bkaradzic/bgfx/blob/master/src/renderer_d3d11.h ) and it seems like directxtk11 and bgfx uses directx 11.1? and on the imgui sample is only directx11. Is that reason why? I guess I have to try out and see. lol
EDIT2: I converted my project to use <d3d11_1.h> and <d3d11_6.h> headers and it's running like in dxtk11 samples now inside my windows vm (60fps). Amazing. My opengl 3.3 project as expected runs really slow at 20-25fps. Sad drivers. :(


1
u/ocornut Aug 25 '20
The value if `SwapEffect` in the SwapChain creation also may have a large effect on performance on Windows 10. On Windows 10 you are supposed to use e.g. DXGI_SWAP_EFFECT_FLIP_DISCARD instead of DXGI_SWAP_EFFECT_DISCARD, but it needs a Windows 10 SDK to compile and some mumbo-jumbo Windows version testing to selectively use the other one on Windows 7/8.
2
u/Gamertron Aug 22 '20
I haven't looked at the code (it may also depend on swap creation parameters), but based on these incomplete snippets, DXTK11 is discarding the existing view, then creating a new view (which doesn't have any outstanding work), which means the Clear* calls are asynchronous against views which have no outstanding work waiting to complete.
vs the Imgui sample which is Clearing an existing view, and this has to wait for any existing work to complete