Skip to content
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

Examples: Win32: Let the CPU and GPU chill when minimized #3907

Closed
wants to merge 5 commits into from

Conversation

CovERUshKA
Copy link

When the window is minimized, in the task manager i see 100% GPU usage and 10% CPU usage
When the window is restored, i see 7% GPU usage and 0,5% CPU usage

So i added SIZE_MINIMIZED handling, to prevent CPU and GPU usage when the window is minimized

When the window is minimized, in the task manager i see 100% GPU usage and 10% CPU usage
@CovERUshKA CovERUshKA changed the title [Win32] Let the CPU and GPU chill Example: DX11: Let the CPU and GPU chill Mar 13, 2021
@CovERUshKA CovERUshKA changed the title Example: DX11: Let the CPU and GPU chill Examples: Win32: DX11: Let the CPU and GPU chill Mar 13, 2021
@CovERUshKA CovERUshKA changed the title Examples: Win32: DX11: Let the CPU and GPU chill Examples: Win32: DX11: DX10: Let the CPU and GPU chill Mar 24, 2021
@kayws426
Copy link

kayws426 commented Mar 26, 2021

I have tested with your code-changes, but I found another problem.

Reproduce the problem (my machine runs Window 10 Pro 19042.867):

  1. Maximize the window.
  2. Minimize the window. (You can see low-usage for GPU and CPU. This is good, but...)
  3. Restore the window. (The Problem: Window content does not update.)

Caused by:

  • g_wndMinimized still have true value even though window have restored(maximized).
  • The Window receives a WM_SIZE event with wParam = SIZE_MAXIMIZED, not SIZE_RESTORED in this case.

Maybe a simple solution is:

-        if (wParam == SIZE_MINIMIZED)
-        {
-            g_wndMinimized = true;
-        }
-        else if (wParam == SIZE_RESTORED)
-        {
-            g_wndMinimized = false;
-        }
+        g_wndMinimized = (wParam == SIZE_MINIMIZED);

@CovERUshKA CovERUshKA changed the title Examples: Win32: DX11: DX10: Let the CPU and GPU chill Examples: Win32: Let the CPU and GPU chill Mar 27, 2021
@ocornut ocornut force-pushed the master branch 2 times, most recently from 0c1e5bd to bb6a60b Compare August 27, 2021 19:10
@ocornut ocornut force-pushed the master branch 2 times, most recently from 8b83e0a to d735066 Compare December 13, 2021 11:31
@ocornut ocornut force-pushed the master branch 2 times, most recently from b3b85d8 to 0755767 Compare January 17, 2022 14:21
@ocornut ocornut force-pushed the master branch 3 times, most recently from c817acb to 8d39063 Compare February 15, 2022 16:25
@ocornut ocornut removed the demo label May 23, 2024
@ocornut ocornut changed the title Examples: Win32: Let the CPU and GPU chill Examples: Win32: Let the CPU and GPU chill when minimized May 23, 2024
ocornut added a commit that referenced this pull request May 23, 2024
@ocornut
Copy link
Owner

ocornut commented May 23, 2024

Thank you for the PR and sorry for my late reaction.
As mentioned in #7615, I think this PR would indeed fix things for minimization, but not fix the issue for screen locking.

I have pushed ec1d2be which seemingly solves it for both cases. 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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants