panfrost: Make ctx->job useful
authorBoris Brezillon <boris.brezillon@collabora.com>
Fri, 2 Aug 2019 17:18:40 +0000 (19:18 +0200)
committerBoris Brezillon <boris.brezillon@collabora.com>
Fri, 2 Aug 2019 19:52:56 +0000 (21:52 +0200)
ctx->job is supposed to serve as a cache to avoid an hash table lookup
everytime we access the job attached to the currently bound FB, except
it was never assigned to anything but NULL.

Fix that by adding the missing assignment in panfrost_get_job_for_fbo().
Also add a missing NULL assignment in the ->set_framebuffer_state()
path.

While at it, add extra assert()s to make sure ctx->job is consistent.

Fixes: 59c9623d0a75 ("panfrost: Import job data structures from v3d")
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/gallium/drivers/panfrost/pan_context.c
src/gallium/drivers/panfrost/pan_job.c

index 014f8f6a9d07a172e4192ac9ed35de00674008d5..ba2df2ce66ae0a1e1ccc4eb53552b3a4f756cbfd 100644 (file)
@@ -2372,6 +2372,11 @@ panfrost_set_framebuffer_state(struct pipe_context *pctx,
                 panfrost_flush(pctx, NULL, PIPE_FLUSH_END_OF_FRAME);
         }
 
+        /* Invalidate the FBO job cache since we've just been assigned a new
+         * FB state.
+         */
+        ctx->job = NULL;
+
         util_copy_framebuffer_state(&ctx->pipe_framebuffer, fb);
 
         /* Given that we're rendering, we'd love to have compression */
index 6339b39d29a01eb7e69881227672fd66161a43a7..cc81d475165ed920dd528e6465f5957f030432c9 100644 (file)
@@ -23,6 +23,8 @@
  *
  */
 
+#include <assert.h>
+
 #include "pan_context.h"
 #include "util/hash_table.h"
 #include "util/ralloc.h"
@@ -124,8 +126,13 @@ panfrost_get_job_for_fbo(struct panfrost_context *ctx)
 
         /* If we already began rendering, use that */
 
-        if (ctx->job)
+        if (ctx->job) {
+                assert(ctx->job->key.zsbuf == ctx->pipe_framebuffer.zsbuf &&
+                       !memcmp(ctx->job->key.cbufs,
+                               ctx->pipe_framebuffer.cbufs,
+                               sizeof(ctx->job->key.cbufs)));
                 return ctx->job;
+        }
 
         /* If not, look up the job */
 
@@ -133,6 +140,10 @@ panfrost_get_job_for_fbo(struct panfrost_context *ctx)
         struct pipe_surface *zsbuf = ctx->pipe_framebuffer.zsbuf;
         struct panfrost_job *job = panfrost_get_job(ctx, cbufs, zsbuf);
 
+        /* Set this job as the current FBO job. Will be reset when updating the
+         * FB state and when submitting or releasing a job.
+         */
+        ctx->job = job;
         return job;
 }
 
@@ -181,6 +192,12 @@ panfrost_job_submit(struct panfrost_context *ctx, struct panfrost_job *job)
 
         if (ret)
                 fprintf(stderr, "panfrost_job_submit failed: %d\n", ret);
+
+        /* The job has been submitted, let's invalidate the current FBO job
+         * cache.
+        */
+        assert(!ctx->job || job == ctx->job);
+        ctx->job = NULL;
 }
 
 void