braodcom/vc5: Flush the job when it grows over 1GB.
authorEric Anholt <eric@anholt.net>
Tue, 7 Nov 2017 19:05:16 +0000 (11:05 -0800)
committerEric Anholt <eric@anholt.net>
Tue, 7 Nov 2017 20:58:03 +0000 (12:58 -0800)
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
src/gallium/drivers/vc5/vc5_draw.c
src/gallium/drivers/vc5/vc5_job.c

index 4917153fd46bffcc58d5ece65c84a9ea1070b78d..73fb0d0bc53d7fe1ae47298e2914b914d1260d30 100644 (file)
@@ -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. */
index 6f45b6340558280668486972ec5fbcd040cd9ea1..f834207863d4a26eeaf8de97ed38835bdaecfd77 100644 (file)
@@ -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);
 }
index 46c85e7edf41c0fa5944f1d8efdcf488b96a92c4..0141802b43ee287940f857a258e9eb39de18528a 100644 (file)
@@ -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;