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

layer.samples value not clipped in Qt6

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3: Somewhat important
    • 6.5.5, 6.6.3, 6.7.0 FF
    • 6.5.3
    • Qt RHI
    • None
    • macOS, Windows
    • bb1d9bab3 (dev), 153ca77c2 (6.6), 5db954f94 (tqtc/lts-6.5)

    Description

      Reproduction steps:

      The problem repro was created on an Apple Silicon M1 with a retina screen, but looks like it's universal (one may need to adjust the requested value of layer.samples in the Qml file on other platforms/displays in order for the bug to show up though).

      • compile both examples from the aarepro.zip file on an Apple Silicon M1 with a retina screen
      • run the Qt5 example
      • take a screenshot
      • load the screenshot into Preview app and zoom in (alternatively one can try to use some zoom utility, but some of them e.g. Digital Color Meter seem to do some "clever things" obscuring the bug)
      • see the tip of the black line perfectly antialiased (as expected)
      • now do the same with the Qt6 example
      • see the tip of the black line not antialiased at all (not as expected)
      • additionally there is an "Attempted to set unsupported sample count 8" warning printed to console (it seems the largest supported sample count is 4 on this platform).

      Also see the attached screenshots.

      Analysis:

      In Qt5 when Qml Item's layer.samples specifies a value outside of the currently supported range, this value is clipped into the supported value range. This seems to happen in

      https://github.com/qt/qtbase/blob/5.15/src/gui/opengl/qopenglframebufferobject.cpp#L494

      In Qt6 instead there is a warning "Attempted to set unsupported sample count X" printed to console and the value falls back to 1 instead of using the nearest available value. This seems to happen in pretty much all of RHI backends, e.g.

      https://github.com/qt/qtbase/blob/6.6.0/src/gui/rhi/qrhimetal.mm#L669

      https://github.com/qt/qtbase/blob/6.6.0/src/gui/rhi/qrhigles2.cpp#L1097

      https://github.com/qt/qtbase/blob/6.6.0/src/gui/rhi/qrhid3d11.cpp#L439

      https://github.com/qt/qtbase/blob/6.6.0/src/gui/rhi/qrhid3d12.cpp#L2890

      The only way around it seems to be to somehow write an own routine detecting supported sample counts and then pass the inferred value to Qml, which looks like a huge overkill and doesn't look like it's an intended way to do things.

      Effectively it doesn't seem to be practically possible to use a constant value in the Qml file for layer.samples, because if that value turns out to be unsupported on a particular system, it's gonna fall back to 1 instead of using the nearest available value.

      Attachments

        1. aarepro.zip
          4 kB
        2. Qt5.png
          Qt5.png
          16 kB
        3. Qt5-zoom.png
          Qt5-zoom.png
          44 kB
        4. Qt6.png
          Qt6.png
          15 kB
        5. Qt6-zoom.png
          Qt6-zoom.png
          43 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            lagocs Laszlo Agocs
            aqn Vadim Zavalishin
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes