57.5 fps

Technical discussion for those interested in Supermodel development and Model 3 reverse engineering. Prospective contributors welcome.
Forum rules
Keep it classy!

  • No ROM requests or links.
  • Do not ask to be a play tester.
  • Do not ask about release dates.
  • No drama!

57.5 fps

Postby Ian » Thu Dec 15, 2022 7:06 am

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? :)
Attachments
58hz.png
58hz.png (11.76 KiB) Viewed 595 times
Ian
 
Posts: 2044
Joined: Tue Feb 23, 2016 9:23 am

Re: 57.5 fps

Postby Bart » Thu Dec 15, 2022 5:27 pm

Interesting! But it cannot do a non-integral refresh rate?
User avatar
Bart
Site Admin
 
Posts: 3086
Joined: Thu Sep 01, 2011 2:13 pm
Location: Reno, Nevada

Re: 57.5 fps

Postby Ian » Fri Dec 16, 2022 3:11 am

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
Ian
 
Posts: 2044
Joined: Tue Feb 23, 2016 9:23 am

Re: 57.5 fps

Postby Gabbyjay » Sat Jul 15, 2023 11:18 am

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.
Gabbyjay
 
Posts: 5
Joined: Mon Sep 26, 2022 2:33 am


Return to The Dark Room

Who is online

Users browsing this forum: No registered users and 0 guests