Per-Pixel Linked Lists

Per-Pixel Linked Lists

A way to implement Transparency on a Graphics Pipeline .

Overview #

  1. Don’t render into a color-render target. (Discard the fragment)
  2. Write fragments in FS into a huge separate buffer to store all rendered fragments
  3. At the end: Build a linked list structure of fragments that fall into the same pixel
  4. After that render a full-screen quad -> FS does the alpha blending using the linked lists

Used data structures #

  1. Start Offset Buffer:

    • same size as viewport
    • initializes to -1
    • stores the index into the fragment in the Fragment and Link Buffer that was rendered last for every pixe
  2. Fragment and Link Buffer:

    • Stores the output of all fragment shaders
    • Stores an “next” index per entry
  3. Counter

    • atomic integer that counts how many fragments are in Fragment and Link Buffer

Process of handling fragments #

  1. Write the fresh fragment into the next free slot (reading the atomic counter an incrementing it) in the Fragment and Link Buffer
  2. Set it’s “next” index to the one, that is stored in the Start Offset Buffer
  3. Overwrite the index in Start Offset Buffer with the counter (that was incremented in 1)
  4. Discard the fragement in the FS so it does not go through the Output Merger (all necessary information is in the Fragment and Link Buffer)

Second render pass #

  1. With the two buffers from the first render pass, render a full screen quad (2 tris) and in the FS handle the color blending.
  2. If this fragment has still -1 in the Start Offset Buffer, discard it (as in the first render pass, it was also not hit)
  3. Else: first sort the fragments from the linked list that correspond to the current fragment, then do the alpha blending

Evaluation #

Con:

  • The Fragment and Link Buffer must be large enough to store all rendered fragments. It can become huge.
Calendar October 22, 2023