Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-119654

RHI Metal - Ignores QSurfaceFormat::setSwapInterval(>=2)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.7
    • Qt RHI
    • None
    • iOS/tvOS/watchOS, macOS

    Description

      I have an application that I want to prevent frame stutter. Frame stutter is where the frame rate speeds up and slows down due to poor frame timing. For example, if my application is rendering at ~24ms, I'll constantly miss the vsync (on a 60Hz display, ~16ms). Sometimes I'll miss 2 vsync, other times 3 vsync. One way around frame stutter is to make a frame longer, between vertical retraces. For the 24ms example, I would really like to have 2 vsync before swapping (~33ms).

      The Qt API has a function for this called QSurfaceFormat::setSwapInterval(2). Unfortunately, on RHI metal, this doesn't do anything. Only swap interval 1 and swap interval 0 (no vsync) do something.

      The documentation says it should be supported:

      Setting an interval value of 0 will turn the vertical refresh syncing off, any value higher than 0 will turn the vertical syncing on. Setting interval to a higher value, for example 10, results in having 10 vertical retraces between every buffer swap.

      Here's a good video for debugging poor frame timing:

      https://developer.apple.com/videos/play/wwdc2018/612/

      I've uploaded a patchset that fixes this in metal. I'm not sure if this is the best way to do it, but it does work.

      Before the patch, you can see the inconsistency, between when frames are scheduled to swap vs when the buffer is swapped, this ranges from 16ms up to 83ms. The first blocks are when the buffer is swapped, red lines are the vsync, and blue is when I receive the QQuickWindow::frameSwapped(). Swap interval of 1

      After the patch, consistent frame rate ~33ms, swap interval of 2. 

      Attachments

        For Gerrit Dashboard: QTBUG-119654
        # Subject Branch Project Status CR V

        Activity

          People

            lagocs Laszlo Agocs
            vpicaver Philip Schuchardt
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There is 1 open Gerrit change