-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Don't render when not necessary #189
Comments
Or should at least have an optional FPS limiter, like 30 or 15. 15% of i7-7700HQ CPU and 28-30% of GTX1050 GPU load is enormous for an idling editor. My laptop is gonna hate me soon. |
Added a few fixes for this issue with the latest commit. |
Sorry for late answer. When developing mobile applications the gain was really huge between slowing down the refresh rate and only rendering when the graphical scene changed. Generally there is only a flag to put at true when an processed input trigger something that require a redraw like a button hover event,... I don't know if Dear ImGUI provide a flag to notify if the scene changed (Qt-QML do this with his scenegraph). In all cases, I'll take a try with the next release. I really appreciate the latest improvements. Thx EDIT: On my laptop I have 2 GPUs (with Nvidia Optimus), so if you use OpenGL it is by default on the low energy one (CPU integrated), but I know that with Vulkan you have to pick one manually In which case looking for the integrated one is certainly the best choice for ImHex. |
Indeed, it seems completely stupid for an UI to render on the same principles of a 3D game. |
This has been fixed a while ago though |
Not really? Both my cpu and gpu have a quite significant load when the program is open. |
@WerWolv The way you use IMHO, ImHex still uses too much CPU than it should for rendering. To reduce that even more, you could prevent rendering a new frame in the lack of input events, as you do when the app is minimized. The only drawback is that it also prevents event-less animations to play. One middle ground is to use a small FPS in the absence of events, and keep using a high FPS for events so that the app is still responsive. Something like that: diff --git a/source/window.cpp b/source/window.cpp
index ef41139..c839abc 100644
--- a/source/window.cpp
+++ b/source/window.cpp
@@ -186,9 +186,11 @@ namespace hex {
this->m_lastFrameTime = glfwGetTime();
while (!glfwWindowShouldClose(this->m_window)) {
if (!glfwGetWindowAttrib(this->m_window, GLFW_VISIBLE) || glfwGetWindowAttrib(this->m_window, GLFW_ICONIFIED))
+ // Only render when new events are received
glfwWaitEvents();
-
- glfwPollEvents();
+ else
+ // Render at 5 FPS when no new events are received
+ glfwWaitEventsTimeout(this->m_lastFrameTime - glfwGetTime() + 1 / 5.0);
this->frameBegin();
this->frame(); I haven't seen any animations in ImHex that requires more than 1 FPS to run, so maybe this should be the minimum FPS goal instead of 5. Or even better, let the users select the value they want through a parameter (making it possible to be less than 1 FPS maybe). With latest source code from the master branch, ImHex uses around 6% of my CPU when idle. When using a minimum of 5 FPS, it uses around 1% of CPU, and this goes down to 0.1% with 1 FPS, so that might be significant for battery powered devices. On a side note, |
The application should avoid to draw when not needed to reduce power consumption.
I think that it is critical to be able to work correctly on a laptop.
PS: I reported some other issues, it's because I find ImHex pretty cool and useful. Thank you.
The text was updated successfully, but these errors were encountered: