Module: Mesa
Branch: master
Commit: 21082b452924fbacdce6e7b0218c658136ae93e7
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=21082b452924fbacdce6e7b0218c658136ae93e7

Author: Mike Blumenkrantz <[email protected]>
Date:   Mon Sep 28 10:51:57 2020 -0400

zink: force batch flush if batches are using more than 1/10 total system memory

this is only tracking memory used by resources referenced in the batch, but it
can be adjusted a bit if we see that we're flushing too often

fixes spec@!opengl 1.1@streaming-texture-leak hogging all system memory and 
ooming

Reviewed-by: Erik Faye-Lund <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9274>

---

 src/gallium/drivers/zink/zink_draw.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/gallium/drivers/zink/zink_draw.c 
b/src/gallium/drivers/zink/zink_draw.c
index 534314f4cd9..497e26d51fc 100644
--- a/src/gallium/drivers/zink/zink_draw.c
+++ b/src/gallium/drivers/zink/zink_draw.c
@@ -670,6 +670,11 @@ zink_draw_vbo(struct pipe_context *pctx,
    VkDeviceSize counter_buffer_offsets[PIPE_MAX_SO_OUTPUTS] = {};
    bool need_index_buffer_unref = false;
 
+   /* flush anytime our total batch memory usage is potentially >= 1/10 of 
total gpu memory
+    * this should also eventually trigger a stall if the app is going nuts 
with gpu memory
+    */
+   if (zink_curr_batch(ctx)->resource_size >= screen->total_mem / 10 / 
ZINK_NUM_BATCHES)
+      ctx->base.flush(&ctx->base, NULL, 0);
 
    if (dinfo->primitive_restart && !restart_supported(dinfo->mode)) {
        util_draw_vbo_without_prim_restart(pctx, dinfo, dindirect, &draws[0]);
@@ -964,6 +969,13 @@ zink_launch_grid(struct pipe_context *pctx, const struct 
pipe_grid_info *info)
    struct zink_context *ctx = zink_context(pctx);
    struct zink_screen *screen = zink_screen(pctx->screen);
    struct zink_batch *batch = &ctx->compute_batch;
+
+   /* flush anytime our total batch memory usage is potentially >= 1/10 of 
total gpu memory
+    * this should also eventually trigger a stall if the app is going nuts 
with gpu memory
+    */
+   if (batch->resource_size >= screen->total_mem / 10 / ZINK_NUM_BATCHES)
+      zink_flush_compute(ctx);
+
    struct zink_compute_program *comp_program = get_compute_program(ctx);
    if (!comp_program)
       return;

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to