panfrost: Move the mali_attr.src_offset adjustment to a sub-function
authorBoris Brezillon <boris.brezillon@collabora.com>
Thu, 5 Mar 2020 18:32:01 +0000 (19:32 +0100)
committerBoris Brezillon <boris.brezillon@collabora.com>
Tue, 10 Mar 2020 11:47:34 +0000 (12:47 +0100)
Create a panfrost_vertex_state_upd_attr_offs() helper to adjust
the attr_meta src_offsets.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4083>

src/gallium/drivers/panfrost/pan_context.c

index f91a2d2..0028018 100644 (file)
@@ -183,13 +183,13 @@ panfrost_writes_point_size(struct panfrost_context *ctx)
         return vs->writes_point_size && ctx->payloads[PIPE_SHADER_FRAGMENT].prefix.draw_mode == MALI_POINTS;
 }
 
-/* Stage the attribute descriptors so we can adjust src_offset
- * to let BOs align nicely */
-
 static void
-panfrost_stage_attributes(struct panfrost_context *ctx)
+panfrost_vertex_state_upd_attr_offs(struct panfrost_context *ctx,
+                                    struct midgard_payload_vertex_tiler *vp)
 {
-        struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
+        if (!ctx->vertex)
+                return;
+
         struct panfrost_vertex_state *so = ctx->vertex;
 
         /* Fixup offsets for the second pass. Recall that the hardware
@@ -213,7 +213,7 @@ panfrost_stage_attributes(struct panfrost_context *ctx)
          * QED.
          */
 
-        unsigned start = ctx->payloads[PIPE_SHADER_VERTEX].offset_start;
+        unsigned start = vp->offset_start;
 
         for (unsigned i = 0; i < so->num_elements; ++i) {
                 unsigned vbi = so->pipe[i].vertex_buffer_index;
@@ -236,6 +236,21 @@ panfrost_stage_attributes(struct panfrost_context *ctx)
 
                 so->hw[i].src_offset = src_offset;
         }
+}
+
+/* Stage the attribute descriptors so we can adjust src_offset
+ * to let BOs align nicely */
+
+static void
+panfrost_stage_attributes(struct panfrost_context *ctx)
+{
+        struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
+        struct panfrost_vertex_state *so = ctx->vertex;
+
+        /* Update src_offsets before copying to the GPU buffer. */
+
+        panfrost_vertex_state_upd_attr_offs(ctx,
+                                            &ctx->payloads[PIPE_SHADER_VERTEX]);
 
         mali_ptr out = panfrost_upload_transient(batch, so->hw,
                                                  sizeof(*so->hw) *