[4/4] panfrost: Stop passing a ctx to functions being passed a batch

Submitted by Boris Brezillon on Aug. 30, 2019, 2:05 p.m.

Details

Message ID 20190830140537.3765-5-boris.brezillon@collabora.com
State New
Headers show
Series "panfrost: Random cleanups" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Boris Brezillon Aug. 30, 2019, 2:05 p.m.
The context can be retrieved from batch->ctx.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
---
 src/gallium/drivers/panfrost/pan_context.c |  6 +++---
 src/gallium/drivers/panfrost/pan_drm.c     |  2 +-
 src/gallium/drivers/panfrost/pan_job.c     | 24 ++++++++++++++--------
 src/gallium/drivers/panfrost/pan_job.h     | 11 ++++------
 4 files changed, 23 insertions(+), 20 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c
index 9e7c6ba5c21c..25e23537bc0a 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -179,7 +179,7 @@  panfrost_clear(
         struct panfrost_context *ctx = pan_context(pipe);
         struct panfrost_job_batch *batch = panfrost_job_get_batch_for_fbo(ctx);
 
-        panfrost_job_clear(ctx, batch, buffers, color, depth, stencil);
+        panfrost_job_clear(batch, buffers, color, depth, stencil);
 }
 
 static mali_ptr
@@ -906,7 +906,7 @@  panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
                 SET_BIT(ctx->fragment_shader_core.unknown2_4, MALI_NO_MSAA, !msaa);
         }
 
-        panfrost_job_set_requirements(ctx, batch);
+        panfrost_job_set_requirements(batch);
 
         if (ctx->occlusion_query) {
                 ctx->payloads[PIPE_SHADER_FRAGMENT].gl_enables |= MALI_OCCLUSION_QUERY | MALI_OCCLUSION_PRECISE;
@@ -1332,7 +1332,7 @@  panfrost_submit_frame(struct panfrost_context *ctx, bool flush_immediate,
         struct pipe_context *gallium = (struct pipe_context *) ctx;
         struct panfrost_screen *screen = pan_screen(gallium->screen);
 
-        panfrost_job_submit(ctx, batch);
+        panfrost_job_submit(batch);
 
         /* If visual, we can stall a frame */
 
diff --git a/src/gallium/drivers/panfrost/pan_drm.c b/src/gallium/drivers/panfrost/pan_drm.c
index e7f1b7225b4a..f9bf9d94dafb 100644
--- a/src/gallium/drivers/panfrost/pan_drm.c
+++ b/src/gallium/drivers/panfrost/pan_drm.c
@@ -355,7 +355,7 @@  panfrost_drm_force_flush_fragment(struct panfrost_context *ctx,
                 screen->last_fragment_flushed = true;
 
                 /* The job finished up, so we're safe to clean it up now */
-                panfrost_job_free_batch(ctx, screen->last_batch);
+                panfrost_job_free_batch(screen->last_batch);
         }
 
         if (fence) {
diff --git a/src/gallium/drivers/panfrost/pan_job.c b/src/gallium/drivers/panfrost/pan_job.c
index b308a1722c66..8ab92bc09fd6 100644
--- a/src/gallium/drivers/panfrost/pan_job.c
+++ b/src/gallium/drivers/panfrost/pan_job.c
@@ -54,11 +54,13 @@  panfrost_job_create_batch(struct panfrost_context *ctx)
 }
 
 void
-panfrost_job_free_batch(struct panfrost_context *ctx, struct panfrost_job_batch *batch)
+panfrost_job_free_batch(struct panfrost_job_batch *batch)
 {
         if (!batch)
                 return;
 
+        struct panfrost_context *ctx = batch->ctx;
+
         set_foreach(batch->bos, entry) {
                 struct panfrost_bo *bo = (struct panfrost_bo *)entry->key;
                 panfrost_bo_unreference(ctx->base.screen, bo);
@@ -193,18 +195,20 @@  panfrost_flush_jobs_writing_resource(struct panfrost_context *panfrost,
                                    prsc);
         if (entry) {
                 struct panfrost_job_batch *batch = entry->data;
-                panfrost_job_submit(panfrost, job);
+                panfrost_job_submit(batch);
         }
 #endif
         /* TODO stub */
 }
 
 void
-panfrost_job_submit(struct panfrost_context *ctx, struct panfrost_job_batch *batch)
+panfrost_job_submit(struct panfrost_job_batch *batch)
 {
+        assert(batch);
+
+        struct panfrost_context *ctx = batch->ctx;
         int ret;
 
-        assert(batch);
         panfrost_scoreboard_link_batch(batch);
 
         bool has_draws = batch->last_job.gpu;
@@ -230,9 +234,10 @@  panfrost_job_submit(struct panfrost_context *ctx, struct panfrost_job_batch *bat
 }
 
 void
-panfrost_job_set_requirements(struct panfrost_context *ctx,
-                              struct panfrost_job_batch *batch)
+panfrost_job_set_requirements(struct panfrost_job_batch *batch)
 {
+        struct panfrost_context *ctx = batch->ctx;
+
         if (ctx->rasterizer && ctx->rasterizer->base.multisample)
                 batch->requirements |= PAN_REQ_MSAA;
 
@@ -334,13 +339,14 @@  pan_pack_color(uint32_t *packed, const union pipe_color_union *color, enum pipe_
 }
 
 void
-panfrost_job_clear(struct panfrost_context *ctx,
-                   struct panfrost_job_batch *batch,
+panfrost_job_clear(struct panfrost_job_batch *batch,
                    unsigned buffers,
                    const union pipe_color_union *color,
                    double depth, unsigned stencil)
 
 {
+        struct panfrost_context *ctx = batch->ctx;
+
         if (buffers & PIPE_CLEAR_COLOR) {
                 for (unsigned i = 0; i < PIPE_MAX_COLOR_BUFS; ++i) {
                         if (!(buffers & (PIPE_CLEAR_COLOR0 << i)))
@@ -384,7 +390,7 @@  panfrost_flush_jobs_reading_resource(struct panfrost_context *panfrost,
 
                 if (_mesa_set_search(batch->bos, rsc->bo)) {
                         printf("TODO: submit job for flush\n");
-                        //panfrost_job_submit(panfrost, job);
+                        //panfrost_job_submit(job);
                         continue;
                 }
         }
diff --git a/src/gallium/drivers/panfrost/pan_job.h b/src/gallium/drivers/panfrost/pan_job.h
index 593f5203dffe..087a16ee3e61 100644
--- a/src/gallium/drivers/panfrost/pan_job.h
+++ b/src/gallium/drivers/panfrost/pan_job.h
@@ -123,8 +123,7 @@  struct panfrost_job_batch *
 panfrost_job_create_batch(struct panfrost_context *ctx);
 
 void
-panfrost_job_free_batch(struct panfrost_context *ctx,
-                        struct panfrost_job_batch *batch);
+panfrost_job_free_batch(struct panfrost_job_batch *batch);
 
 struct panfrost_job_batch *
 panfrost_job_get_batch(struct panfrost_context *ctx,
@@ -149,18 +148,16 @@  panfrost_flush_jobs_reading_resource(struct panfrost_context *panfrost,
                                      struct pipe_resource *prsc);
 
 void
-panfrost_job_submit(struct panfrost_context *ctx, struct panfrost_job_batch *batch);
+panfrost_job_submit(struct panfrost_job_batch *batch);
 
 void
-panfrost_job_set_requirements(struct panfrost_context *ctx,
-                              struct panfrost_job_batch *batch);
+panfrost_job_set_requirements(struct panfrost_job_batch *batch);
 
 mali_ptr
 panfrost_job_get_polygon_list(struct panfrost_job_batch *batch, unsigned size);
 
 void
-panfrost_job_clear(struct panfrost_context *ctx,
-                   struct panfrost_job_batch *batch,
+panfrost_job_clear(struct panfrost_job_batch *batch,
                    unsigned buffers,
                    const union pipe_color_union *color,
                    double depth, unsigned stencil);