High CPU usage when window is on fullscreen

I’m concerned about a high CPU usage when the window is set to fullscreen via glfwCreateWindow(mode->width, mode->height, “ex”, glfwGetPrimaryMonitor(), nullptr);

Windowed performance is much more lower (as expected) via
glfwCreateWindow(mode->width, mode->height, “ex”, nullptr, nullptr);

In both swap interval was set to 1.

It seems to be some external code according to CPU usage viewer

I’d like to know if this is an expected behaviour of glfw, a bug, or something else.

High single core CPU usage in a graphics application is often due to low GPU load (so the application is not constrained by the GPU performance) and a swap interval set to 0 (also known as no vertical sync/vsync) resulting in the main loop spinning.

The difference between windowed and fullscreen is potentially due to vsync being on by default for the windowed state.

To check this, try monitoring your frame rate and setting the glfwSwapInterval to 1 or 0 to see the difference. You can also control your frame rate using a sleep (different APIs on Posix/Windows) or using glfwPollEvents rather than glfwWaitEvents when you don’t need continuos updates but only need changes when the user performs an action.

Hi Doug, thanks for your reply.
Even though glfwSwapInterval() is set to 1, I keep getting the same behaviour, framerate is as expected (60fps), but cpu usage is still high.
I also tried the following:
Checking the WGL_EXT_swap_control extension (is supported).
Forcing the vSync through nvidia control panel (no changes on cpu usage).

I also noticed that setting glfwSwapInterval() to a higher value works as expected reducing framerate , however the cpu usage is still high.
I’m already using glfwPollEvents.

Correction to earlier post: I meant you can use glfwWaitEvents which waits for input instead of glfwPollEvents.

If your framerate is 60fps, then your frame is taking ~16ms. You then need to check how much of that time is spent in your application and how much in the glfwSwapBuffers function, the majority of which will likely be spent in the graphics driver, over which you have no control.

The difference between windowed mode and fullscreen CPU usage is potentially down to the Windows implementation of glfwSwapBuffers using DwmFlush when in windowed mode & when desktop composition is enabled. Since DwmFlush blocks the thread until the flush is performed the thread is idle during this time. However the fullscreen implementation might spin or do work, depending on the driver implementation.