nouveau/nv50: fix linear buffer alignment for scan-out/cursors
authorSimon Ser <contact@emersion.fr>
Thu, 14 Jan 2021 18:12:32 +0000 (19:12 +0100)
committerSimon Ser <contact@emersion.fr>
Sun, 7 Feb 2021 17:44:42 +0000 (18:44 +0100)
The hardware can only scan-out linear buffers with a pitch
aligned to 256. It can only use packed buffers for cursors.

Signed-off-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8500>

src/gallium/drivers/nouveau/nv50/nv50_miptree.c

index 400ce6c..9578fc3 100644 (file)
@@ -342,6 +342,7 @@ nv50_miptree_create(struct pipe_screen *pscreen,
    int ret;
    union nouveau_bo_config bo_config;
    uint32_t bo_flags;
+   unsigned pitch_align;
 
    if (!mt)
       return NULL;
@@ -370,10 +371,17 @@ nv50_miptree_create(struct pipe_screen *pscreen,
    } else
    if (bo_config.nv50.memtype != 0) {
       nv50_miptree_init_layout_tiled(mt);
-   } else
-   if (!nv50_miptree_init_layout_linear(mt, 64)) {
-      FREE(mt);
-      return NULL;
+   } else {
+      if (pt->usage & PIPE_BIND_CURSOR)
+         pitch_align = 1;
+      else if (pt->usage & PIPE_BIND_SCANOUT)
+         pitch_align = 256;
+      else
+         pitch_align = 64;
+      if (!nv50_miptree_init_layout_linear(mt, pitch_align)) {
+         FREE(mt);
+         return NULL;
+      }
    }
    bo_config.nv50.tile_mode = mt->level[0].tile_mode;