From feba676f9cfa0c4cff8c01daa1c93f7fd3a0b766 Mon Sep 17 00:00:00 2001
From: Niklas Haas <git@haasn.dev>
Date: Tue, 19 Sep 2023 13:53:30 +0200
Subject: [PATCH] tests/bench: flush after every iteration

The whole point of pl_gpu_flush() is to commit work to the GPU and
rotate queues, there is literally no point in holding on to work like
this besides the miniscule amount of submission overhead. It also
completely destroys the parallelism that we get from async compute.

Fixes: https://code.videolan.org/videolan/libplacebo/-/issues/306
---
 src/tests/bench.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/tests/bench.c b/src/tests/bench.c
index 48071bff..1f562b6c 100644
--- a/src/tests/bench.c
+++ b/src/tests/bench.c
@@ -128,10 +128,10 @@ static void benchmark(pl_gpu gpu, const char *name,
     start = pl_clock_now();
     do {
         frames++;
-        run_bench(gpu, dp, &state, src, fbos[index++], timer, bench);
-        index %= NUM_FBOS;
+        run_bench(gpu, dp, &state, src, fbos[index], timer, bench);
+        pl_gpu_flush(gpu);
+        index = (index + 1) % NUM_FBOS;
         if (index == 0) {
-            pl_gpu_flush(gpu);
             stop = pl_clock_now();
         }
         while ((gputime = pl_timer_query(gpu, timer))) {
-- 
GitLab