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

Drastic decrease in performance when running full screen vs almost full screen #2557

Open
bill-connelly opened this issue May 14, 2024 · 0 comments

Comments

@bill-connelly
Copy link

bill-connelly commented May 14, 2024

GLFW 3.3.8-1
Raspberry Pi 5.
Raspberry Pi OS: Linux raspberrypi 6.6.28+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.28-1+rpt1 (2024-04-22) aarch64 GNU/Linux
Windowing: Wayland

My monitors native resolution is 1920 x 1200. If I make a window that is just not full screen (1920, 1180) and then repeatedly call glfwSwapBuffers() with no kind of rendering and time how long between buffer swaps, I get about 0.2 milliseconds, i.e. 5000 FPS

However, if I make the window full screen, and perform the same test I get a handful of frames with a 0.2 inter-frame time. Then it drops to 33.3 millisecond (which is very curiously, almost exactly 2 refreshes), i.e. 30 FPS

I appreciate I am on some atypical hardware, so I'm happy to try to look into anything.

My test code is as follows:

#include <stdio.h>
#include <GLFW/glfw3.h>
#include <sys/time.h>

struct timeval tv;
unsigned long
  frameCount = 0,
  time_in_micros,
  oldTime;

int main(void) {

    glfwInit();

    GLFWmonitor* primaryMonitor = glfwGetPrimaryMonitor();
    const GLFWvidmode* mode = glfwGetVideoMode(primaryMonitor);
 
    //glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate); //This makes no difference
    
    //Swapping between these two versions are what causes problems.
    //GLFWwindow* window = glfwCreateWindow(1920, 1180, "My Title", NULL, NULL);
    GLFWwindow* window = glfwCreateWindow(1920, 1200, "My Title", primaryMonitor, NULL);

    glfwMakeContextCurrent(window);
    glfwSwapInterval(0);

    while (!glfwWindowShouldClose(window)) {
        frameCount++;
        glfwSwapBuffers(window);
        if (frameCount % 10 == 0) {
            oldTime = time_in_micros;
            gettimeofday(&tv,NULL);
            time_in_micros = 1000000 * tv.tv_sec + tv.tv_usec;
            printf("Interframe time is %f\n", (float)(time_in_micros-oldTime)/10000);
        }
    }

    glfwTerminate();
    return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant