Skip to content
  • Rob Clark's avatar
    freedreno: support growable cmdstream buffers · 419a154d
    Rob Clark authored
    
    
    The issue that userspace needed to solve is that there is ~two orders of
    magnitude size difference in cmdstream buffers (both for gmem commands
    and for draw commands), and that the previous practice of allocating
    worst-case sizes is quite wasteful.  Previously a submit would be
    constructed (for example) like:
    
      CMD  TARGET  DESCRIPTION
       g0    N     gmem/tiling commands
       b0    Y     binning commands
       d0    Y     draw commands
    
    Which, after the one non-IB-target cmd buffer is inserted into the
    kernel controlled ringbuffer, looks like (not to scale):
    
             b0:           d0:
            +-----+       +-----+
       IB1  | ... |       | ... |
            +-----+       +-----+
             ^             ^
             |             |
             +-----+       +-+---------+
             g0:   |         |         |
            +----+----+----+----+----+----+----
       IB0  | .. | IB | .. | IB | .. | IB | ...
            +----+----+----+----+----+----+----
             ^              tile0     tile1
             |
             +-----------+
      userspace          |
      ~~~~~~~~~~~~~~~~~~~|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      kernel             |
                   ----+----+----
       ringbuffer  ... | IB | ...
                   ----+----+----
    
    Now, multiple physical cmdstream buffers per fd_ringbuffer are supported,
    so this becomes:
    
      CMD  TARGET  DESCRIPTION
       g0    N
       ...   N     gmem/tiling commands
       gN    N
       b0    Y
       ...   Y     binning commands
       bN    Y
       d0    Y
       ...   Y     draw commands
       dN    Y
    
    Which, after the non-IB-target cmd buffers (g0..gN) are inserted into
    the kernel controlled ringbuffer, looks like:
    
                 b0:      b1            d0:      d1
                +-----+  +-----+        +-----+  +-----+
           IB1  | ... |  | ... | ...    | ... |  | ... | ...
                +-----+  +-----+        +-----+  +-----+
                 ^        ^              ^        ^
                 |        |              |        |
                 |        +-+            |  +-----+------+
                 +-----+    |            |  |            |
                       |    |         +--+----------+    |
                 g0:   |    |         |     |       |    |
                +----+----+----+----+----+----+---+----+----+----
           IB0  | .. | IB | IB | .. | IB | IB |.. | IB | IB |...
                +----+----+----+----+----+----+---+----+----+----
                 ^                   tile0         tile1
                 | to b0  to b1
                 |   |      |          to|d0    to|d1
                 |   |      +----+       |      +-+-----------+
                 |   |           |       |      |             |
                 |   +------+    |       +-+-------------+    |
                 |    g1:   |    |         |    |        |    |
                 |   +----+----+----+----+----+----+---+----+----+----
           IB0   |   | .. | IB | IB | .. | IB | IB |.. | IB | IB |...
                 |   +----+----+----+----+----+----+---+----+----+----
                 |    ^                   tileX         tileY
                 |    |
                 |    +-----------+
                 +-----------+    |
          userspace          |    |
          ~~~~~~~~~~~~~~~~~~~|~~~~|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          kernel             |    |
                       ----+----+----+----
           ringbuffer  ... | IB | IB | ...
                       ----+----+----+----
    
    Signed-off-by: default avatarRob Clark <robclark@freedesktop.org>
    419a154d