Skip to content
  • Benjamin Otte's avatar
    gl: Add buffer implementation using persistent mapping · 96b800fa
    Benjamin Otte authored
    If glBufferStorage() is available, we can replace our usage of
    glBufferSubData() with persistently mapped storage via
    glMappedBufferRange().
    
    This has 1 disadvantage:
    
    1. It's not supported everywhere, it requires GL 4.4 or
       GL_EXT_buffer_storage. But every GPU of the last 10 years should
       implement it. So we check for it and keep the old code.
       The old code can also be forced via GDK_GL_DISABLE=buffer-storage.
    
    But it has 2 advantages:
    
    1. It is what Vulkan does, so it unifies the two renderers' buffer
       handling.
    
    2. It is a significant performance boost in use cases with large vertex
       buffers. Those are pretty rare, but do happen with lots of text at a
       small font size. An example would be a small font in a maximized VTE
       terminal or the overview in gnome-text-editor.
    
    A custom benchmark tailored for this problem can be created with:
    
      tests/rendernode-create-tests 1000000 text.node
    
    This creates a node file called "text.node" that draws 1 million text
    nodes.
    (Creating that test takes a minute or so. A smaller number may be useful
    on less powerful hardware than my Intel Tigerlake laptop.)
    The difference can then be compared via:
    
      tools/gtk4-rendernode-tool benchmark --runs=20 text.node
    and
      GDK_GL_DISABLE=buffer-storage tools/gtk4-rendernode-tool benchmark --runs=20 text.node
    
    For my laptop, the difference is:
    before: 1.1s
    after:  0.8s
    
    Related: !7021
    96b800fa