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

Author: Eric Anholt <e...@anholt.net>
Date:   Tue Nov  7 11:05:16 2017 -0800

braodcom/vc5: Flush the job when it grows over 1GB.

Fixes GL_OUT_OF_MEMORY from streaming-texture-leak (and will hopefully
keep piglit from ooming on my no-swap platform, as well).

---

 src/gallium/drivers/vc5/vc5_context.h | 3 +++
 src/gallium/drivers/vc5/vc5_draw.c    | 6 ++++++
 src/gallium/drivers/vc5/vc5_job.c     | 1 +
 3 files changed, 10 insertions(+)

diff --git a/src/gallium/drivers/vc5/vc5_context.h 
b/src/gallium/drivers/vc5/vc5_context.h
index 4917153fd4..73fb0d0bc5 100644
--- a/src/gallium/drivers/vc5/vc5_context.h
+++ b/src/gallium/drivers/vc5/vc5_context.h
@@ -205,6 +205,9 @@ struct vc5_job {
          */
         struct set *bos;
 
+        /** Sum of the sizes of the BOs referenced by the job. */
+        uint32_t referenced_size;
+
         struct set *write_prscs;
 
         /* Size of the submit.bo_handles array. */
diff --git a/src/gallium/drivers/vc5/vc5_draw.c 
b/src/gallium/drivers/vc5/vc5_draw.c
index 6f45b63405..f834207863 100644
--- a/src/gallium/drivers/vc5/vc5_draw.c
+++ b/src/gallium/drivers/vc5/vc5_draw.c
@@ -479,6 +479,12 @@ vc5_draw_vbo(struct pipe_context *pctx, const struct 
pipe_draw_info *info)
                 vc5_job_add_bo(job, rsc->bo);
         }
 
+        if (job->referenced_size > 768 * 1024 * 1024) {
+                perf_debug("Flushing job with %dkb to try to free up memory\n",
+                        job->referenced_size / 1024);
+                vc5_flush(pctx);
+        }
+
         if (V3D_DEBUG & V3D_DEBUG_ALWAYS_FLUSH)
                 vc5_flush(pctx);
 }
diff --git a/src/gallium/drivers/vc5/vc5_job.c 
b/src/gallium/drivers/vc5/vc5_job.c
index 46c85e7edf..0141802b43 100644
--- a/src/gallium/drivers/vc5/vc5_job.c
+++ b/src/gallium/drivers/vc5/vc5_job.c
@@ -118,6 +118,7 @@ vc5_job_add_bo(struct vc5_job *job, struct vc5_bo *bo)
 
         vc5_bo_reference(bo);
         _mesa_set_add(job->bos, bo);
+        job->referenced_size += bo->size;
 
         uint32_t *bo_handles = (void *)(uintptr_t)job->submit.bo_handles;
 

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to