Aquatic-Games/Pie

SDL limit FPS in Fullscreen mode

MrScautHD opened this issue · 35 comments

Hello, by setting the game into fullscreen, the fps get limit to 60 FPS.

Info:
With SDL D3D11 and OpenGL get limited!

Make sure vertical sync is disabled (set swap interval to 0) and is not forced on by your driver. Apart from that, this will most likely be driver & implementation specific for which I can do nothing about.

grafik

By disabling it does work but it should possible to override this variable and set it to false.

I'm assuming your global setting is to have vertical sync enabled? It is not possible to override this value, as a global value is forced by the driver, regardless of the application's settings. You should select "use application setting".

"use application setting" does not exist, and what use other games to fix this issue?

There should be a setting similar to it. I haven't used the nvidia control panel in a long time so I don't remember the exact name. This sounds to me like a driver setting.

grafik

Oh, sry it is wrong translaited if i set it to it and it does not work.

I will have to test on a windows machine. However I don't think there is any solution to this problem.

And SDL does not have any method to disable VSync or any other method to disable it...

SDL does itself not handle vertical sync at all. SDL just interfaces with the underlying window system.

SDL does itself not handle vertical sync at all. SDL just interfaces with the underlying window system.

But what is that? https://wiki.libsdl.org/SDL2/SDL_GL_SetSwapInterval

SDL_GL_SetSwapInterval will interface with the various underlying OpenGL systems. For windows, it will call wglSwapIntervalEXT, for X11 it will call glxSetSwapInterval etc.

SDL_GL_SetSwapInterval will interface with the various underlying OpenGL systems. For windows, it will call wglSwapIntervalEXT, for X11 it will call glxSetSwapInterval etc.

well but GL has the same problem

As I've said, I have no control over what SDL does when setting the swap interval. However since all the function does is call the window manager functions, I have even less control as those functions are directly handled by the window manager and display driver.

Did you googled it already if any user has the same issue?

Sorry?

Sorry?

No i mean maybe there solutions, i tried already to look. (but i just know Stackoverflow)

That is what i found:

DirectX11

// Create a Device object for DirectX
Device device = new Device(DriverType.Hardware, DeviceCreationFlags.None);

// Get the DXGI device associated with the DirectX device
using (var dxgiDevice = device.QueryInterface<SharpDX.DXGI.Device>())
{
    // Get the DXGI output associated with the primary display
    using (var output = dxgiDevice.Adapter.GetOutput(0))
    {
        // Get the DXGI factory associated with the DXGI output
        using (var dxgiFactory = output.GetParent<SharpDX.DXGI.Factory>())
        {
            // Disable VSync for the DXGI factory
            dxgiFactory.MakeWindowAssociation(System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle, WindowAssociationFlags.None);
        }
    }
}

OpenGL:

// Disable VSync for OpenGL
private void DisableVSync()
{
    // Get the current OpenGL context
    var context = new OpenTK.Platform.Utilities.GraphicsContextHandle(OpenTK.Graphics.GraphicsContext.CurrentContext.Context.Handle);
    
    // Disable VSync
    if (context != OpenTK.Platform.Utilities.GraphicsContextHandle.Zero)
    {
        if (context.IsCurrent)
        {
            // Set the swap interval to 0 (disable VSync)
            GL.GetDelegateForExtension<GL.Arb>().SwapInterval(0);
        }
        else
        {
            MessageBox.Show("Failed to disable VSync. The OpenGL context is not current.");
        }
    }
    else
    {
        MessageBox.Show("Failed to disable VSync. No valid OpenGL context found.");
    }
}

Assuming that the swap interval is actually 0, for OpenGL there is no solution at all. It is driver specific. For Direct3D, you can force it to disable vertical sync by setting a swapchain parameter. However this is beyond the scope of what Pie will implement, as it is not in any way compatible with OpenGL, and Pie does not implement anything that is not compatible with a backend.

However this swapchain parameter also forces exclusive fullscreen which is mostly recommended that you avoid.

oh :/

I see you working on Vulkan, would that has the same issue?

A driver or window manager may prevent a vulkan swapchain from using anything but a FIFO presentation mode (vertical sync). However Pie itself will, assuming vertical sync is disabled, attempt to request a mailbox (triple buffering), relaxed fifo (adaptive sync), or immediate (no vertical sync at all) presentation mode depending on the swap interval chosen. However it is down to the driver to actually provide this, and if it does not allow the user to use a certain option, Pie will pick the next best available option, ultimately resorting to vertical sync if no other option is available.

so it is not fixable for Pie?

No, as this sounds like a driver related issue, especially since you are getting the same issue with OpenGL (this is however a known "feature" of Direct3D, with the only solution being to set a swapchain parameter, which is beyond the scope of Pie).

I would suggest however making sure your swap interval is indeed 0 as if it is >1 then vertical sync will be enabled.

how can i check this?

Check the value that is being passed into GraphicsDevice.Present.

If you want to go a step further, you can also check the value that is being passed into IDXGISwapchain.Present for the Direct3D device, and SDL_GL_SetSwapInterval for the OpenGL device.

I will check on Windows now to see if there is anything I have missed however I have tried to fix this issue with Direct3D and have been unable to. However I did last check with the old windowing system so there is a chance things may have changed since I implemented SDL, and there is a chance that things that did not work before will now start working.

I've added a couple of swapchain parameters in f00802c that should allow for vertical sync to be disabled in borderless fullscreen windows, if the driver allows it. I've done extensive tests and OpenGL and Direct3D behave the same for both windowed, borderless, and exclusive fullscreen windows.

Nice! but i can just try it if Pie get updated in Easel.

has been done.

nice thx!

I've added a couple of swapchain parameters in f00802c that should allow for vertical sync to be disabled in borderless fullscreen windows, if the driver allows it. I've done extensive tests and OpenGL and Direct3D behave the same for both windowed, borderless, and exclusive fullscreen windows.

need i to set something or should it work automaticlly?

It will work automatically.

well then it does not work :/

Have you checked to make sure that the swap interval is actually 0?

Try cloning Pie.Tests and running it to see if the issue persists. It prints the current FPS to the console every second. You can experiment with setting the swap interval in Present, and also try changing the fullscreen mode when F11 is pressed.

grafik

It is 0, yes