-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
100% GPU usage while minimised SDL2/OpenGL #7844
Comments
I’ll look when I get back on the computer but we pushed changes for similar issues in other examples in 1.90.6: |
I surveyed our example apps in minimized state:
The "problem" is that the Sleep() technique doesn't necessarily work in a manner as simple in multi-viewports applications if we want to allow main viewport to be minimized. As currently different backends apply a different OS-level parent<>child relationship between main viewport and secondary viewports, I'll probably go and fix things disregarding that possibility for now. |
… loop to handle minimization without burning CPU or GPU by running unthrottled code. (#7844)
I pushed a minimized+sleep test for all examples apart from the GLFW ones, because GLFW currently doesn't have a sleep function and we'd need a portable one. One that the issues linked above for Win32+DirectX variants handled both minimization and screen locking which might have differences on some setups. I realized you said this:
In my case it makes both CPU and GPU of the process essentially go to zero. Your wordings is confusing or a little bit ambiguous as you are saying "let it render at effectively 10fps" too: where I added my sleep+continue (in 8874787) there's no rendering going on at all, the only thing that will happen is polling inputs. |
Polling inputs at 10hz: Rendering at 10hz: When investigating, I was surprised that rendering at 10hz while minimised was still shooting up GPU usage to 100% when all it was doing was a basically a swapbuffer, when maximised it was near 0%, so I assumed there is/was some interaction from setting the render size to 0, as I didn't see any other obvious changes. If I was polling inputs at a high hz without passing anything to ImGui, I was aware that it wouldn't be a good solution for multiviewport (hence a hack), and sleeping for large enough values to lower GPU usage would also be way too low fps for multiviewport, so I just solved the issue for my use case ( Polling at 20Hz), but thought I'd explain my process, as behavior during minimised can be quite os/machine/driver specific. Hopefully that's a bit clearer? |
…out burning CPU or GPU by running unthrottled code. (#7844) Backends: GLFW: added ImGui_ImplGlfw_Sleep() helper.
I see, thanks for clarifying. I don't know the reason. But I also don't see a reason for us to keep rendering in this setup. I think it is ok to consider that our examples app may not have to handle minimizing main viewports while other viewports are visible. Anyhow there would a bunch more logic desirable there in term of who does vsync etc. But it's all application logic. I'm ok with current state of examples and we can always reevaluate (in particular when working on non-minimized idle schemes) I have pushed equivalent code for GLFW examples now: 71ee2ce |
Version/Branch of Dear ImGui:
Version 1.90
Back-ends:
SDL2 OpenGL3
Compiler, OS:
MSVC 2022
Full config/build information:
No response
Details:
When my application is minimised I'm getting a sudden 100% gpu jump usage on the discrete GPU, but still around 0% CPU / low integrated usage on task manager.
For now I've put a temporary/simple hack between SDL_PollEvent and ImGui_ImplOpenGL3_NewFrame() in the main loop.
Interestingly if I just did say a sleep(100) without the continue and let it render at effectively 10fps while minimised, GPU usage was still showing as 100%, I had to really crank the sleep to low single digit fps to lower the GPU usage.
Considering that all that is supposed to happen is render a 0,0 size window and swap buffers, that's pretty insane, so I'm assuming it's probably a laptop driver bug that has issue with changing/swapping buffers on a 0 size window.
Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code:
No response
The text was updated successfully, but these errors were encountered: