OSDN Git Service

freedreno: support growable cmdstream buffers
authorRob Clark <robclark@freedesktop.org>
Mon, 20 Jun 2016 18:06:24 +0000 (14:06 -0400)
committerRob Clark <robclark@freedesktop.org>
Wed, 20 Jul 2016 23:42:21 +0000 (19:42 -0400)
commit419a154dbef839b920689bea72aa9af41b2b114f
treeba0c9c5869dae77d3dc13e5019c6314e61ca624d
parentd93d697deb4a808890bc9c64ec453b2d2f2ebb7f
freedreno: support growable cmdstream buffers

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: Rob Clark <robclark@freedesktop.org>
freedreno/freedreno_priv.h
freedreno/freedreno_ringbuffer.c
freedreno/freedreno_ringbuffer.h
freedreno/kgsl/kgsl_ringbuffer.c
freedreno/msm/msm_ringbuffer.c