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

Distance field cache spanning multiple texture exceed max texture size

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P1: Critical
    • Resolution: Done
    • Affects Version/s: 5.12.4
    • Fix Version/s: 5.12.5
    • Component/s: GUI: Text handling
    • Labels:
      None
    • Platform/s:
      All
    • Commits:
      46d72a117df642135718b38995346267312c4808, 9a53834f1e7fce2fc3b1ecc2a311faedbc371d37

      Description

      There is a logical bug in the distance field cache that spans multiple textures. The way the glyphs are allocated in the cache, it creates a big area allocator with textureSize*textureCount height, and then allocates to this. But since the (glyph heights + padding + margin) are not necessarily a factor in the texture height, some of them may end up at the edge between two textures. The result of this is that the actual texture height will be larger than the maximum size, since it will be correctly expanded to account for the remaining part of the glyph that falls outside the texture.

      In addition, the next texture will have an unused section to account for the overlap from the previous texture, but this is just a little wasteful, it is not a critical bug.

      Since the case where the caches actually exceed a single maximum sized texture is so rare, we haven't actually seen this happen in the wild. But when using the distancefieldgenerator, it is quite easy to get into this situation since the default texture size is so low.

      A proper fix for this would be to have a separate area allocator for each texture instead of one big one, but this would have some implications for the pregenerated cache format. We would still have to support the old in order to support older files.

      So a quicker fix is to set the maximum height of the textures in the allocator to be maxSize - fontPixelSize. That way we leave space for exceeding the cache by up to one glyph height. It would be good enough for a rare case.

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            • Assignee:
              esabraha Eskil Abrahamsen Blomfeldt
              Reporter:
              esabraha Eskil Abrahamsen Blomfeldt
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Gerrit Reviews

                There are no open Gerrit changes