-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
High cpu/gpu usage when window is minimized for example_win32_directx11 #2496
Comments
… out when display size is zero (minimized). (#2496)
I looks like when the surface is minimized, It doesn't seem to happen with the DX12 example possibly because In our case in the DX11 example, Present() returns HRESULT (*) there was actually a missing early out in the DX10/11/12 render code, which I just pushed. When added my mainloop runs went from 3500 FPS to 7500 FPS here. That's not solving your problem at all but it is more correct to early out there. |
I have no experience with this stuff but looking at the documentation I found this:
Hope it helps. |
I've searched alot and I believe the application has to do the sleeping and keep testing using the DXGI_PRESENT_TEST flag until it works again, something like this ...
As for why it works with DX12 I have absolutly no idea :( |
While there are several ways to fix it easily for master, I have pushed a small fix for secondary viewport to avoid rendering/swapping minimized windows, but we are left with the problem that if you minimize the main viewport (the one handled by main.cpp) but have secondary viewports showing, there will be nothing left to throttle the application. Secondary viewports are currently programmed to present without vsync, assuming the main app with vsync. Currently imgui_impl_win32.cpp in Docking branch defaults to creating a parent<>child relationship between viewports so minimizing the main window also minimize others, so this issue is not noticeable. However if you set This also related to the feature discussed in #2471. If we support zero or more than one main viewport we may need to have a better standard or mechanism to describe how the main loop should handle timing and vsyncing. |
I experienced this issue with my application too. I think that it could be beneficial if the code that evga posted will be integrated in the example (even if it's commented out), or a more sophisticated solution based on the messages passed to the app. I know that it's used for performance testing, but I think that many beginners copy-paste the examples and replace the imgui calls with their own (I know I did!). What do you think about it, @ocornut ? Let me know if it's appropriate and I'll create a PR. |
#3907 ? |
I have pushed ec1d2be which seemingly solves it for both cases of minimization and screen locking. Implemented this for the DX9, DX10, DX11 and DX12 examples. Both DX9 and DX12 weren't burning as much CPU when looping with no visible swap chain, as Present() would still honor vsync, but it's still best to not loop when locked. Note this issue for multi-viewports #7615 (comment) Thanks for the help! |
Version/Branch of Dear ImGui:
Version: 1.69
Branch: master
Back-end/Renderer/Compiler/OS
Back-ends: imgui_impl_directx11.cpp + imgui_impl_win32.cpp
Compiler: Visual Studio Community 2019
Operating System: Windows10
My Issue/Question:
Open the Directx11 example application and minimize the window.
CPU goes from 8% to 50%
GPU goes from 30% to 70%
This doesn't happen with the opengl/vulkan/dx9 examples.
The text was updated successfully, but these errors were encountered: