panfrost: Separate postfix from emits
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 24 Aug 2020 17:54:20 +0000 (13:54 -0400)
committerMarge Bot <eric+marge@anholt.net>
Fri, 28 Aug 2020 14:53:53 +0000 (14:53 +0000)
This is the easy subset, where we have functions that take in a postfix
pointer but only to use as a return address. We can use an actual return
instead, which is a bit simpler and helps prepare for condensed postfix
packing.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6476>

src/gallium/drivers/panfrost/pan_cmdstream.c
src/gallium/drivers/panfrost/pan_cmdstream.h
src/gallium/drivers/panfrost/pan_compute.c
src/gallium/drivers/panfrost/pan_context.c

index 34c6f42784f7aa0cadbd4d9b3271fe4fb91ae5c7..dc6b2ffe18f2b4d2165f6950b1529f692e63da39 100644 (file)
@@ -51,12 +51,10 @@ panfrost_bo_access_for_stage(enum pipe_shader_type stage)
                PAN_BO_ACCESS_VERTEX_TILER;
 }
 
-static void
-panfrost_vt_emit_shared_memory(struct panfrost_context *ctx,
-                               struct mali_vertex_tiler_postfix *postfix)
+static mali_ptr
+panfrost_vt_emit_shared_memory(struct panfrost_batch *batch)
 {
-        struct panfrost_device *dev = pan_device(ctx->base.screen);
-        struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
+        struct panfrost_device *dev = pan_device(batch->ctx->base.screen);
 
         struct mali_shared_memory shared = {
                 .shared_workgroup_count = ~0,
@@ -72,15 +70,7 @@ panfrost_vt_emit_shared_memory(struct panfrost_context *ctx,
                 shared.scratchpad = stack->gpu;
         }
 
-        postfix->shared_memory = panfrost_pool_upload_aligned(&batch->pool, &shared, sizeof(shared), 64);
-}
-
-static void
-panfrost_vt_attach_framebuffer(struct panfrost_context *ctx,
-                               struct mali_vertex_tiler_postfix *postfix)
-{
-        struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
-        postfix->shared_memory = panfrost_batch_reserve_framebuffer(batch);
+        return panfrost_pool_upload_aligned(&batch->pool, &shared, sizeof(shared), 64);
 }
 
 static void
@@ -138,6 +128,7 @@ panfrost_vt_init(struct panfrost_context *ctx,
                  struct mali_vertex_tiler_postfix *postfix)
 {
         struct panfrost_device *device = pan_device(ctx->base.screen);
+        struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
 
         if (!ctx->shader[stage])
                 return;
@@ -147,10 +138,10 @@ panfrost_vt_init(struct panfrost_context *ctx,
 
         if (device->quirks & IS_BIFROST) {
                 postfix->gl_enables = 0x2;
-                panfrost_vt_emit_shared_memory(ctx, postfix);
+                postfix->shared_memory = panfrost_vt_emit_shared_memory(batch);
         } else {
                 postfix->gl_enables = 0x6;
-                panfrost_vt_attach_framebuffer(ctx, postfix);
+                postfix->shared_memory = panfrost_batch_reserve_framebuffer(batch);
         }
 
         if (stage == PIPE_SHADER_FRAGMENT) {
@@ -747,9 +738,8 @@ panfrost_emit_frag_shader_meta(struct panfrost_batch *batch)
         return xfer.gpu;
 }
 
-void
-panfrost_emit_viewport(struct panfrost_batch *batch,
-                       struct mali_vertex_tiler_postfix *tiler_postfix)
+mali_ptr
+panfrost_emit_viewport(struct panfrost_batch *batch)
 {
         struct panfrost_context *ctx = batch->ctx;
         const struct pipe_viewport_state *vp = &ctx->pipe_viewport;
@@ -794,8 +784,8 @@ panfrost_emit_viewport(struct panfrost_batch *batch,
                 cfg.maximum_z = rast->depth_clip_far ? maxz : INFINITY;
         }
 
-        tiler_postfix->viewport = T.gpu;
         panfrost_batch_union_scissor(batch, minx, miny, maxx, maxy);
+        return T.gpu;
 }
 
 static mali_ptr
@@ -1083,10 +1073,9 @@ panfrost_emit_const_buf(struct panfrost_batch *batch,
         buf->dirty_mask = 0;
 }
 
-void
+mali_ptr
 panfrost_emit_shared_memory(struct panfrost_batch *batch,
-                            const struct pipe_grid_info *info,
-                            struct midgard_payload_vertex_tiler *vtp)
+                            const struct pipe_grid_info *info)
 {
         struct panfrost_context *ctx = batch->ctx;
         struct panfrost_device *dev = pan_device(ctx->base.screen);
@@ -1111,8 +1100,8 @@ panfrost_emit_shared_memory(struct panfrost_batch *batch,
                 .shared_shift = util_logbase2(single_size) + 1
         };
 
-        vtp->postfix.shared_memory = panfrost_pool_upload_aligned(&batch->pool, &shared,
-                                                               sizeof(shared), 64);
+        return panfrost_pool_upload_aligned(&batch->pool, &shared,
+                        sizeof(shared), 64);
 }
 
 static mali_ptr
@@ -1151,16 +1140,15 @@ panfrost_update_sampler_view(struct panfrost_sampler_view *view,
         }
 }
 
-void
+mali_ptr
 panfrost_emit_texture_descriptors(struct panfrost_batch *batch,
-                                  enum pipe_shader_type stage,
-                                  struct mali_vertex_tiler_postfix *postfix)
+                                  enum pipe_shader_type stage)
 {
         struct panfrost_context *ctx = batch->ctx;
         struct panfrost_device *device = pan_device(ctx->base.screen);
 
         if (!ctx->sampler_view_count[stage])
-                return;
+                return 0;
 
         if (device->quirks & IS_BIFROST) {
                 struct panfrost_transfer T = panfrost_pool_alloc_aligned(&batch->pool,
@@ -1190,7 +1178,7 @@ panfrost_emit_texture_descriptors(struct panfrost_batch *batch,
                                               panfrost_bo_access_for_stage(stage));
                 }
 
-                postfix->textures = T.gpu;
+                return T.gpu;
         } else {
                 uint64_t trampolines[PIPE_MAX_SHADER_SAMPLER_VIEWS];
 
@@ -1202,23 +1190,21 @@ panfrost_emit_texture_descriptors(struct panfrost_batch *batch,
                         trampolines[i] = panfrost_get_tex_desc(batch, stage, view);
                 }
 
-                postfix->textures = panfrost_pool_upload_aligned(&batch->pool,
-                                                              trampolines,
-                                                              sizeof(uint64_t) *
-                                                              ctx->sampler_view_count[stage],
-                                                              sizeof(uint64_t));
+                return panfrost_pool_upload_aligned(&batch->pool, trampolines,
+                                sizeof(uint64_t) *
+                                ctx->sampler_view_count[stage],
+                                sizeof(uint64_t));
         }
 }
 
-void
+mali_ptr
 panfrost_emit_sampler_descriptors(struct panfrost_batch *batch,
-                                  enum pipe_shader_type stage,
-                                  struct mali_vertex_tiler_postfix *postfix)
+                                  enum pipe_shader_type stage)
 {
         struct panfrost_context *ctx = batch->ctx;
 
         if (!ctx->sampler_count[stage])
-                return;
+                return 0;
 
         size_t desc_size = MALI_BIFROST_SAMPLER_LENGTH;
         assert(MALI_BIFROST_SAMPLER_LENGTH == MALI_MIDGARD_SAMPLER_LENGTH);
@@ -1230,7 +1216,7 @@ panfrost_emit_sampler_descriptors(struct panfrost_batch *batch,
         for (unsigned i = 0; i < ctx->sampler_count[stage]; ++i)
                 out[i] = ctx->samplers[stage][i]->hw;
 
-        postfix->sampler_descriptor = T.gpu;
+        return T.gpu;
 }
 
 void
index f03d1a617616c0561d78be5bc6753efc4b23dd90..5eb5e64c43a9693b3bc9ec37894898025bad137a 100644 (file)
@@ -57,29 +57,25 @@ panfrost_emit_compute_shader_meta(struct panfrost_batch *batch, enum pipe_shader
 mali_ptr
 panfrost_emit_frag_shader_meta(struct panfrost_batch *batch);
 
-void
-panfrost_emit_viewport(struct panfrost_batch *batch,
-                       struct mali_vertex_tiler_postfix *tiler_postfix);
+mali_ptr
+panfrost_emit_viewport(struct panfrost_batch *batch);
 
 void
 panfrost_emit_const_buf(struct panfrost_batch *batch,
                         enum pipe_shader_type stage,
                         struct mali_vertex_tiler_postfix *postfix);
 
-void
+mali_ptr
 panfrost_emit_shared_memory(struct panfrost_batch *batch,
-                            const struct pipe_grid_info *info,
-                            struct midgard_payload_vertex_tiler *vtp);
+                            const struct pipe_grid_info *info);
 
-void
+mali_ptr
 panfrost_emit_texture_descriptors(struct panfrost_batch *batch,
-                                  enum pipe_shader_type stage,
-                                  struct mali_vertex_tiler_postfix *postfix);
+                                  enum pipe_shader_type stage);
 
-void
+mali_ptr
 panfrost_emit_sampler_descriptors(struct panfrost_batch *batch,
-                                  enum pipe_shader_type stage,
-                                  struct mali_vertex_tiler_postfix *postfix);
+                                  enum pipe_shader_type stage);
 
 void
 panfrost_emit_vertex_data(struct panfrost_batch *batch,
index 8ad1485a566c30b8d3757939e03e4409dcfcdcde..4996afd11d0b56b4224aa8ebd18b374011a1694a 100644 (file)
@@ -121,7 +121,7 @@ panfrost_launch_grid(struct pipe_context *pipe,
 
         payload.postfix.shader = panfrost_emit_compute_shader_meta(batch, PIPE_SHADER_COMPUTE);
         panfrost_emit_const_buf(batch, PIPE_SHADER_COMPUTE, &payload.postfix);
-        panfrost_emit_shared_memory(batch, info, &payload);
+        payload.postfix.shared_memory = panfrost_emit_shared_memory(batch, info);
 
         /* Invoke according to the grid info */
 
index 78a6a9baa816f8ca84208b3c4c1322659fd2b9c0..5f39613114a6052808bc024724dbee6365f02785 100644 (file)
@@ -325,13 +325,13 @@ panfrost_draw_vbo(
                                          ctx->instance_count,
                                          &vertex_postfix, &tiler_postfix,
                                          &primitive_size);
-        panfrost_emit_sampler_descriptors(batch, PIPE_SHADER_VERTEX, &vertex_postfix);
-        panfrost_emit_sampler_descriptors(batch, PIPE_SHADER_FRAGMENT, &tiler_postfix);
-        panfrost_emit_texture_descriptors(batch, PIPE_SHADER_VERTEX, &vertex_postfix);
-        panfrost_emit_texture_descriptors(batch, PIPE_SHADER_FRAGMENT, &tiler_postfix);
+        vertex_postfix.sampler_descriptor = panfrost_emit_sampler_descriptors(batch, PIPE_SHADER_VERTEX);
+        tiler_postfix.sampler_descriptor = panfrost_emit_sampler_descriptors(batch, PIPE_SHADER_FRAGMENT);
+        vertex_postfix.textures = panfrost_emit_texture_descriptors(batch, PIPE_SHADER_VERTEX);
+        tiler_postfix.textures = panfrost_emit_texture_descriptors(batch, PIPE_SHADER_FRAGMENT);
         panfrost_emit_const_buf(batch, PIPE_SHADER_VERTEX, &vertex_postfix);
         panfrost_emit_const_buf(batch, PIPE_SHADER_FRAGMENT, &tiler_postfix);
-        panfrost_emit_viewport(batch, &tiler_postfix);
+        tiler_postfix.viewport = panfrost_emit_viewport(batch);
 
         vertex_postfix.shader = panfrost_emit_compute_shader_meta(batch, PIPE_SHADER_VERTEX);
         tiler_postfix.shader = panfrost_emit_frag_shader_meta(batch);