Page 1 of 1

57.5 fps

PostPosted: Thu Dec 15, 2022 7:06 am
by Ian
I haven't done any serious research into this .. (at least from a coding POV).
Thanks to gm_mathew's suggestion, I tried just making a custom a custom refresh rate for my screen of 57.5 fps, and running supermodel with that .. and well it works flawlessly. Actually I didn't even know this was possible, since I have a nothing special 1080p panel. So we can set the screen refresh rate, turn off throttle, and just let v-sync do it's thing.

I was wondering whether this was possible to just automatically set in supermodel itself, and it turns out yes we can do this.

The windows API itself kind of assumes integer refresh rates, 50, 60 etc. But if you create a custom one and set say 57.54 etc it does actually work at that speed. I think windows just rounds the refresh rate to the nearest whole number, at least with regards to what it displays in the API.

Anyway messing around with this code .. for windowed mode. This will automatically say 57.5 fps upon start up, and then revert to 60 or whatever the refresh rate was when the app ends.

Code: Select all
void EnumDisplayDevicesSuper()
{
    DEVMODE currentSettings = { 0 };
    EnumDisplaySettings(nullptr, ENUM_CURRENT_SETTINGS, &currentSettings);

    for (int i = 0; ; i++) {

        DEVMODE settings = { 0 };
        BOOL success = EnumDisplaySettings(nullptr, i, &settings);

        if (!success) {
            break;
        }

        if (settings.dmPelsWidth == currentSettings.dmPelsWidth &&
            settings.dmPelsHeight == currentSettings.dmPelsHeight &&
            settings.dmDisplayFrequency == 58) {

            settings.dmFields = DM_DISPLAYFREQUENCY;

            auto retVal = ChangeDisplaySettings(&settings, 0);

            int debug = 0;
        }


        printf("settings %i %i %i\n", settings.dmPelsWidth, settings.dmPelsHeight, settings.dmDisplayFrequency);
    }
}


We can do this in SDL too. But .. I think only in fullscreen mode. SDL is setting up an opengl window using something called exclusive mode, in short it creates a window then sets the monitors resolution refresh rate etc. I personally prefer fullscreen borderless .. but I am not sure that works with setting custom refresh rates in SDL.

Code is something like this

Code: Select all
int Test()
{
    static int display_in_use = 0; /* Only using first display */

    int i, display_mode_count;
    SDL_DisplayMode mode;
    Uint32 f;

    printf("SDL_GetNumVideoDisplays(): %i\n", SDL_GetNumVideoDisplays());

    display_mode_count = SDL_GetNumDisplayModes(display_in_use);
    if (display_mode_count < 1) {
        printf("SDL_GetNumDisplayModes failed: %s\n", SDL_GetError());
        return 1;
    }
    printf("SDL_GetNumDisplayModes: %i", display_mode_count);

    for (i = 0; i < display_mode_count; ++i) {
        if (SDL_GetDisplayMode(display_in_use, i, &mode) != 0) {
            printf("SDL_GetDisplayMode failed: %s\n", SDL_GetError());
            return 1;
        }
        f = mode.format;

        printf("Mode %i\tbpp %i\t%s\t%i x %i %i\n",
            i, SDL_BITSPERPIXEL(f),
            SDL_GetPixelFormatName(f),
            mode.w, mode.h, mode.refresh_rate);

        if (mode.refresh_rate == 58) {
            auto result = SDL_SetWindowDisplayMode(s_window, &mode);
            int debug = 0;
        }
    }

    //SDL_SetWindowDisplayMode
}


Any thoughts? :)

Re: 57.5 fps

PostPosted: Thu Dec 15, 2022 5:27 pm
by Bart
Interesting! But it cannot do a non-integral refresh rate?

Re: 57.5 fps

PostPosted: Fri Dec 16, 2022 3:11 am
by Ian
Yes it can do non integer frame rates. The apis return a list of refresh rates and supported resolutions. The refresh rate part is rounded to the nearest integer since the windows api only has an integer value to represent it in the api. But if you select it in my case 58 it'll work at the correct custom rate if 57.54 fps

Re: 57.5 fps

PostPosted: Sat Jul 15, 2023 11:18 am
by Gabbyjay
Perhaps it might also help to use the old trick and limit the fps to 57.5 while setting the custom refresh rate of the display to 59.5 fps to avoid input-lag while using v-sync on a non-vrr display.