Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Is the Linux Player locked at 60fps regardless of VSync?

Discussion in 'Linux' started by FuzzyQuills, Jan 25, 2017.

  1. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Hey all, is there a possibility that the Linux Player is locked at 60 regardless?

    Reason I'm asking; I have a special use-case for rendering faster than the screen; I'm attempting motion blur by rendering "subframes" between each displayed frame.

    To do so, I have the following setup:
    - Physics at 30fps
    - Actual target framerate set to 120Hz of which is quadruple the desired framerate (30fps)
    - The effect itself counts the frames, and every 4 frames blits a motion-blurred one to the screen.

    Now, as expected, this works on Windows and the Linux Editor
    HOWEVER:
    It isn't working inside a Linux build; no matter what I do, it likes to cap itself at 60fps for seemingly no reason. I've already tried turning off all kinds of VSync in Linux itself (some compositors actually force it on for games) and I have it off in the quality settings. Yet on a build, it actually appears to run at 15fps, making it look very jerky, and making it unplayable.

    So is this a bug, a feature, or is there a way to render a frame between vblanks? The desired effect is this (Captured during a test run):
    20170122193828_1.jpg
    20170122193840_1.jpg
    20170122193859_1.jpg
    Amy help is appreciated, and I am happy to finally come back to making games. :)
     
  2. Tak

    Tak

    Joined:
    Mar 8, 2010
    Posts:
    1,001
    No, we don't force sync to vblank.
    As you mentioned, some WMs/compositors/graphics settings can cause this to occur globally.
    What version of Unity are you using? Can you send your project (or a subset)?
     
  3. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    I am using 5.4.3f1 (or 5.4.3xLinux as it calls itself on the Linux editor)
    I'll upload both a build and the project in a bit.

    EDIT: Would a tar.gz or a normal zip be good? I'm on Linux at the moment.
    EDIT2: nvm, figured out how to zip. Expect a link soon. :)
     
    Last edited: Jan 25, 2017
  4. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    More information:

    Machine: DELL Latitude E6220
    GPU: Intel HD Graphics 3000
    CPU: Intel Core i3 2.1GHz
    RAM: 6GB
    OS: Debian Testing (originally Debian Jessie)

    Mesa: 13.0.2
    OpenGL version: 3.3

    DE: a custom one I built with compton, xfwm4, pcmanfm, plank and tint2

    I have already tried disabling compositing.
     
  5. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Here's the link: https://drive.google.com/file/d/0B2tqYgzg1_lWRk5tRmE4dW5SR1U/view?usp=sharing
    Inside the project folder is a builds folder, where both Windows and Linux builds of the files reside.

    EDIT: OH DANG! Forgot the game controls... not much to test when the car can't be moved. :D
    Right-handed:
    Steering: WASD
    Acceleration: J
    Brake: I

    Left-handed:
    Steering: Arrow keys
    Acceleration: Z
    Brake: X
     
    Last edited: Jan 25, 2017
  6. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Ok, debugged a little myself and... found this in the first two seconds; that bloody pesky GFX.WaitForPresent bug AGAIN:
    FOUND IT.png
    No VSync on whatsoever, yet here it is. I vaguely remember having similar trouble ages back when working on Android. (different platform, but nonetheless similar problem)

    If this is occurring in the built player (i definitely selected the linux player IP) then there's a bug in unity somewhere...
    Please let me know @Tak if you find something similar!
     
    Last edited: Jan 25, 2017
  7. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    @Tak
    New development: it appears Linux Builds made in the Windows Editor don't exhibit the bug. Only Linux Builds made in the Linux Editor actually do it. Evidence was from a test build I just ran that I compiled on Windows before transferring via SD card to test.

    In the meantime, I also found a workaround for getting my effect to work at 60fps instead of 120fps, so if the bug does pop up again, it shouldn't affect the game performance anymore (or at least it's "performance" :D)

    One detail I missed; Even though the Gfx.WaitForPresent was there, the game itself had tearing, indicating no VSync
     
  8. Tak

    Tak

    Joined:
    Mar 8, 2010
    Posts:
    1,001
    I added a little fps counter locally - it runs 120fps with no (other) modifications here.
    I think this indicates that the issue is probably with your environment.
    (If the OS/driver is blocking present, this can cause spikes in Gfx.WaitForPresent...)
     

    Attached Files:

  9. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Being that the issue seemed to vanish last night, I'll double-check again. Chances are, I did something stupid in my linux environment. :D

    That still doesn't explain why the editor ran fine though...

    EDIT: You can mark this solved, it's behaving properly now. Not sure why it didn't before.
    In the meantime, I was also able to find another way to smooth out the sampling so it can operate at 60fps, so thank you for your support. :)
     
    Last edited: Jan 27, 2017