freedreno: Put an upper limit on VSC size
authorRob Clark <robdclark@chromium.org>
Tue, 2 Feb 2021 20:32:22 +0000 (12:32 -0800)
committerMarge Bot <eric+marge@anholt.net>
Wed, 3 Feb 2021 18:35:38 +0000 (18:35 +0000)
Left unchecked, an app that just did an endless series of draws could
result in VSC buffer sizes >4GB, which doesn't work out well.

This limit is semi-arbitrary (ie. it is lower than hw limit, but 32*8MB
seems a bit excessive and not a limit that you'd hit in the real world).

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8842>

src/gallium/drivers/freedreno/freedreno_batch.c

index 425a490..b2b5871 100644 (file)
@@ -525,6 +525,13 @@ fd_batch_check_size(struct fd_batch *batch)
                return;
        }
 
+       /* Place a reasonable upper bound on prim/draw stream buffer size: */
+       const unsigned limit_bits = 8 * 8 * 1024 * 1024;
+       if ((batch->prim_strm_bits > limit_bits) || (batch->draw_strm_bits > limit_bits)) {
+               fd_batch_flush(batch);
+               return;
+       }
+
        if (fd_device_version(batch->ctx->screen->dev) >= FD_VERSION_UNLIMITED_CMDS)
                return;