panfrost: Avoid postfix dep for vertex_data
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tue, 25 Aug 2020 16:48:12 +0000 (12:48 -0400)
committerMarge Bot <eric+marge@anholt.net>
Fri, 28 Aug 2020 14:53:53 +0000 (14:53 +0000)
We need to thread some extra data through the context but still gets us
a bit closer.

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_context.c
src/gallium/drivers/panfrost/pan_context.h
src/panfrost/lib/midgard.xml

index 20639cdee5aab25508b3d976888513c80777a7c2..7d7ec775dc0fd7a0ee73e92a26cebfc3213680c5 100644 (file)
@@ -262,6 +262,7 @@ panfrost_vt_set_draw_info(struct panfrost_context *ctx,
         }
 
         tiler_prefix->unknown_draw = draw_flags;
+        ctx->offset_start = vertex_postfix->offset_start;
 
         /* Encode the padded vertex count */
 
@@ -1204,24 +1205,19 @@ panfrost_emit_sampler_descriptors(struct panfrost_batch *batch,
         return T.gpu;
 }
 
-void
+mali_ptr
 panfrost_emit_vertex_data(struct panfrost_batch *batch,
-                          struct mali_vertex_tiler_postfix *vertex_postfix)
+                          mali_ptr *buffers)
 {
         struct panfrost_context *ctx = batch->ctx;
         struct panfrost_vertex_state *so = ctx->vertex;
         struct panfrost_shader_state *vs = panfrost_get_shader_state(ctx, PIPE_SHADER_VERTEX);
 
-        unsigned instance_shift = vertex_postfix->instance_shift;
-        unsigned instance_odd = vertex_postfix->instance_odd;
-
         /* Worst case: everything is NPOT, which is only possible if instancing
          * is enabled. Otherwise single record is gauranteed */
-        bool could_npot = instance_shift || instance_odd;
-
         struct panfrost_transfer S = panfrost_pool_alloc_aligned(&batch->pool,
                         MALI_ATTRIBUTE_BUFFER_LENGTH * vs->attribute_count *
-                        (could_npot ? 2 : 1),
+                        (ctx->instance_count > 1 ? 2 : 1),
                         MALI_ATTRIBUTE_BUFFER_LENGTH * 2);
 
         struct panfrost_transfer T = panfrost_pool_alloc_aligned(&batch->pool,
@@ -1286,14 +1282,14 @@ panfrost_emit_vertex_data(struct panfrost_batch *batch,
 
                 if (!divisor || ctx->instance_count <= 1) {
                         pan_pack(bufs + k, ATTRIBUTE_BUFFER, cfg) {
-                                if (ctx->instance_count > 1)
+                                if (ctx->instance_count > 1) {
                                         cfg.type = MALI_ATTRIBUTE_TYPE_1D_MODULUS;
+                                        cfg.divisor = ctx->padded_count;
+                                }
 
                                 cfg.pointer = addr;
                                 cfg.stride = stride;
                                 cfg.size = size;
-                                cfg.divisor_r = instance_shift;
-                                cfg.divisor_p = instance_odd;
                         }
                 } else if (util_is_power_of_two_or_zero(hw_divisor)) {
                         pan_pack(bufs + k, ATTRIBUTE_BUFFER, cfg) {
@@ -1358,8 +1354,6 @@ panfrost_emit_vertex_data(struct panfrost_batch *batch,
          * addressing modes and now base is 64 aligned.
          */
 
-        unsigned start = vertex_postfix->offset_start;
-
         for (unsigned i = 0; i < so->num_elements; ++i) {
                 unsigned vbi = so->pipe[i].vertex_buffer_index;
                 struct pipe_vertex_buffer *buf = &ctx->vertex_buffers[vbi];
@@ -1376,8 +1370,8 @@ panfrost_emit_vertex_data(struct panfrost_batch *batch,
                 /* Also, somewhat obscurely per-instance data needs to be
                  * offset in response to a delayed start in an indexed draw */
 
-                if (so->pipe[i].instance_divisor && ctx->instance_count > 1 && start)
-                        src_offset -= buf->stride * start;
+                if (so->pipe[i].instance_divisor && ctx->instance_count > 1)
+                        src_offset -= buf->stride * ctx->offset_start;
 
                 pan_pack(out + i, ATTRIBUTE, cfg) {
                         cfg.buffer_index = attrib_to_buffer[i];
@@ -1386,8 +1380,8 @@ panfrost_emit_vertex_data(struct panfrost_batch *batch,
                 }
         }
 
-        vertex_postfix->attributes = S.gpu;
-        vertex_postfix->attribute_meta = T.gpu;
+        *buffers = S.gpu;
+        return T.gpu;
 }
 
 static mali_ptr
index 430d47243b1ff9cf5c7a7edce6079b3e4b846e49..3603dcc2bc3ff657d5a522dcd3ad0355dd0244f0 100644 (file)
@@ -77,9 +77,9 @@ mali_ptr
 panfrost_emit_sampler_descriptors(struct panfrost_batch *batch,
                                   enum pipe_shader_type stage);
 
-void
+mali_ptr
 panfrost_emit_vertex_data(struct panfrost_batch *batch,
-                          struct mali_vertex_tiler_postfix *vertex_postfix);
+                          mali_ptr *buffers);
 
 void
 panfrost_emit_varying_descriptor(struct panfrost_batch *batch,
index 215fe594406d4bba409c5b035090d87a4a28a2eb..9f22c2b698c24187f44f5ceeb0b9367f3ac2a824 100644 (file)
@@ -319,9 +319,10 @@ panfrost_draw_vbo(
                                         1, 1, 1);
 
         /* Emit all sort of descriptors. */
-        mali_ptr push_vert = 0, push_frag = 0;
+        mali_ptr push_vert = 0, push_frag = 0, attribs = 0;
 
-        panfrost_emit_vertex_data(batch, &vertex_postfix);
+        vertex_postfix.attribute_meta = panfrost_emit_vertex_data(batch, &attribs);
+        vertex_postfix.attributes = attribs;
         panfrost_emit_varying_descriptor(batch,
                                          ctx->padded_count *
                                          ctx->instance_count,
index b7314c59e5f82efa4ccf8f89397695d23ca5ecf5..eb28e552db033864b3b8f0f83c8c11b15d06ceb6 100644 (file)
@@ -124,6 +124,7 @@ struct panfrost_context {
 
         unsigned vertex_count;
         unsigned instance_count;
+        unsigned offset_start;
         enum pipe_prim_type active_prim;
 
         /* If instancing is enabled, vertex count padded for instance; if
index a6c96b35d730e3f16dbf6f1df40f70ccd4bb7a47..af209576a66355cbe25ab9430e215f86791281fe 100644 (file)
     <field name="Stride" size="32" start="64" type="uint"/>
     <field name="Size" size="32" start="96" type="uint"/>
 
+    <field name="Divisor" size="8" start="56" type="padded" default="1"/>
     <field name="Divisor R" size="5" start="56" type="uint"/>
     <field name="Divisor P" size="3" start="61" type="uint"/>
     <field name="Divisor E" size="1" start="61" type="uint"/>