freedreno: a2xx: fix HW binning for batches with >256K vertices
authorJonathan Marek <jonathan@marek.ca>
Thu, 1 Aug 2019 19:22:47 +0000 (15:22 -0400)
committerJonathan Marek <jonathan@marek.ca>
Fri, 2 Aug 2019 15:58:22 +0000 (15:58 +0000)
Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Reviewed-by: Rob Clark <robdclark@chromium.org>
src/gallium/drivers/freedreno/a2xx/fd2_gmem.c

index 0edc5e940c11dc163748c4b59e5638ee9c02d8bb..47cbb54d611882ecacfd101f9becf9765992297c 100644 (file)
@@ -590,14 +590,14 @@ fd2_emit_tile_init(struct fd_batch *batch)
                for (int i = 0; i < gmem->num_vsc_pipes; i++) {
                        struct fd_vsc_pipe *pipe = &ctx->vsc_pipe[i];
 
-                       /* XXX we know how large this needs to be..
-                        * should do some sort of realloc
-                        * it should be ctx->batch->num_vertices bytes large
-                        * with this size it will break with more than 256k vertices..
-                        */
-                       if (!pipe->bo) {
-                               pipe->bo = fd_bo_new(ctx->dev, 0x40000,
+                       /* allocate in 64k increments to avoid reallocs */
+                       uint32_t bo_size = align(batch->num_vertices, 0x10000);
+                       if (!pipe->bo || fd_bo_size(pipe->bo) < bo_size) {
+                               if (pipe->bo)
+                                       fd_bo_del(pipe->bo);
+                               pipe->bo = fd_bo_new(ctx->dev, bo_size,
                                                DRM_FREEDRENO_GEM_TYPE_KMEM, "vsc_pipe[%u]", i);
+                               assert(pipe->bo);
                        }
 
                        /* memory export address (export32):
@@ -609,7 +609,7 @@ fd2_emit_tile_init(struct fd_batch *batch)
                        OUT_RELOCW(ring, pipe->bo, 0, 0x40000000, -2);
                        OUT_RING(ring, 0x00000000);
                        OUT_RING(ring, 0x4B00D000);
-                       OUT_RING(ring, 0x4B000000 | 0x40000);
+                       OUT_RING(ring, 0x4B000000 | bo_size);
                }
 
                OUT_PKT3(ring, CP_SET_CONSTANT, 1 + gmem->num_vsc_pipes * 8);