panfrost: Use packs for attributes
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 14 Aug 2020 16:19:10 +0000 (12:19 -0400)
committerMarge Bot <eric+marge@anholt.net>
Mon, 17 Aug 2020 11:43:52 +0000 (11:43 +0000)
Now that state is grouped, this is natural.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6326>

src/gallium/drivers/panfrost/pan_cmdstream.c

index b36afb29530fa085a51fcaa268ff4bff681906dc..1069dab5c1e9200fff802f7287e4baa77688ddd6 100644 (file)
@@ -1431,17 +1431,25 @@ panfrost_emit_vertex_data(struct panfrost_batch *batch,
 
         /* Add special gl_VertexID/gl_InstanceID buffers */
 
-        struct mali_attr_meta hw[PIPE_MAX_ATTRIBS];
+        struct panfrost_transfer T = panfrost_pool_alloc(&batch->pool,
+                        MALI_ATTRIBUTE_LENGTH * (PAN_INSTANCE_ID + 1));
+
+        struct mali_attribute_packed *out =
+                (struct mali_attribute_packed *) T.cpu;
 
         panfrost_vertex_id(ctx->padded_count, &attrs[k]);
-        hw[PAN_VERTEX_ID].index = k++;
-        hw[PAN_VERTEX_ID].format = so->formats[PAN_VERTEX_ID];
-        hw[PAN_VERTEX_ID].unknown1 = 0x2;
+
+        pan_pack(out + PAN_VERTEX_ID, ATTRIBUTE, cfg) {
+                cfg.buffer_index = k++;
+                cfg.format = so->formats[PAN_VERTEX_ID];
+        }
 
         panfrost_instance_id(ctx->padded_count, &attrs[k]);
-        hw[PAN_INSTANCE_ID].index = k++;
-        hw[PAN_INSTANCE_ID].format = so->formats[PAN_VERTEX_ID];
-        hw[PAN_INSTANCE_ID].unknown1 = 0x2;
+
+        pan_pack(out + PAN_INSTANCE_ID, ATTRIBUTE, cfg) {
+                cfg.buffer_index = k++;
+                cfg.format = so->formats[PAN_INSTANCE_ID];
+        }
 
         /* Attribute addresses require 64-byte alignment, so let:
          *
@@ -1473,19 +1481,18 @@ panfrost_emit_vertex_data(struct panfrost_batch *batch,
                 if (so->pipe[i].instance_divisor && ctx->instance_count > 1 && start)
                         src_offset -= buf->stride * start;
 
-                hw[i].src_offset = src_offset;
-                hw[i].index = attrib_to_buffer[i];
-                hw[i].format = so->formats[i];
-                hw[i].unknown1 = 0x2;
+                pan_pack(out + i, ATTRIBUTE, cfg) {
+                        cfg.buffer_index = attrib_to_buffer[i];
+                        cfg.format = so->formats[i];
+                        cfg.offset = src_offset;
+                }
         }
 
 
         vertex_postfix->attributes = panfrost_pool_upload(&batch->pool, attrs,
                                                            k * sizeof(*attrs));
 
-        vertex_postfix->attribute_meta = panfrost_pool_upload(&batch->pool, hw,
-                                                               sizeof(hw[0]) *
-                                                               PAN_MAX_ATTRIBUTE);
+        vertex_postfix->attribute_meta = T.gpu;
 }
 
 static mali_ptr