panfrost: Move attr_meta emission to the draw routine
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 14 Aug 2020 16:14:20 +0000 (12:14 -0400)
committerMarge Bot <eric+marge@anholt.net>
Mon, 17 Aug 2020 11:43:52 +0000 (11:43 +0000)
It's unfortunate that we can't do more at CSO time, but actually all we
really need is the format after all, and this lets us group the state.

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

index 28607b4b7d509c61577de2e7d7df9a9098e6c982..b36afb29530fa085a51fcaa268ff4bff681906dc 100644 (file)
@@ -1431,10 +1431,17 @@ panfrost_emit_vertex_data(struct panfrost_batch *batch,
 
         /* Add special gl_VertexID/gl_InstanceID buffers */
 
+        struct mali_attr_meta hw[PIPE_MAX_ATTRIBS];
+
         panfrost_vertex_id(ctx->padded_count, &attrs[k]);
-        so->hw[PAN_VERTEX_ID].index = k++;
+        hw[PAN_VERTEX_ID].index = k++;
+        hw[PAN_VERTEX_ID].format = so->formats[PAN_VERTEX_ID];
+        hw[PAN_VERTEX_ID].unknown1 = 0x2;
+
         panfrost_instance_id(ctx->padded_count, &attrs[k]);
-        so->hw[PAN_INSTANCE_ID].index = k++;
+        hw[PAN_INSTANCE_ID].index = k++;
+        hw[PAN_INSTANCE_ID].format = so->formats[PAN_VERTEX_ID];
+        hw[PAN_INSTANCE_ID].unknown1 = 0x2;
 
         /* Attribute addresses require 64-byte alignment, so let:
          *
@@ -1466,16 +1473,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;
 
-                so->hw[i].src_offset = src_offset;
-                so->hw[i].index = attrib_to_buffer[i];
+                hw[i].src_offset = src_offset;
+                hw[i].index = attrib_to_buffer[i];
+                hw[i].format = so->formats[i];
+                hw[i].unknown1 = 0x2;
         }
 
 
         vertex_postfix->attributes = panfrost_pool_upload(&batch->pool, attrs,
                                                            k * sizeof(*attrs));
 
-        vertex_postfix->attribute_meta = panfrost_pool_upload(&batch->pool, so->hw,
-                                                               sizeof(*so->hw) *
+        vertex_postfix->attribute_meta = panfrost_pool_upload(&batch->pool, hw,
+                                                               sizeof(hw[0]) *
                                                                PAN_MAX_ATTRIBUTE);
 }
 
index 72c435792c5d861d8418c79303a4c5f5e427c242..46cbfe896fff77beec98df03216a15f658228651 100644 (file)
@@ -445,12 +445,8 @@ panfrost_create_vertex_elements_state(
         memcpy(so->pipe, elements, sizeof(*elements) * num_elements);
 
         for (int i = 0; i < num_elements; ++i) {
-                so->hw[i].index = i;
-
                 enum pipe_format fmt = elements[i].src_format;
                 const struct util_format_description *desc = util_format_description(fmt);
-                so->hw[i].unknown1 = 0x2;
-
                 unsigned swizzle = 0;
                 if (dev->quirks & HAS_SWIZZLES)
                         swizzle = panfrost_translate_swizzle_4(desc->swizzle);
@@ -458,21 +454,20 @@ panfrost_create_vertex_elements_state(
                         swizzle = panfrost_bifrost_swizzle(desc->nr_channels);
 
                 enum mali_format hw_format = panfrost_pipe_format_table[desc->format].hw;
-                so->hw[i].format = (hw_format << 12) | swizzle;
+                so->formats[i] = (hw_format << 12) | swizzle;
                 assert(hw_format);
         }
 
         /* Let's also prepare vertex builtins */
-        so->hw[PAN_VERTEX_ID].format = MALI_R32UI;
         if (dev->quirks & HAS_SWIZZLES)
-                so->hw[PAN_VERTEX_ID].format = (MALI_R32UI << 12) | panfrost_get_default_swizzle(1);
+                so->formats[PAN_VERTEX_ID] = (MALI_R32UI << 12) | panfrost_get_default_swizzle(1);
         else
-                so->hw[PAN_VERTEX_ID].format = (MALI_R32UI << 12) | panfrost_bifrost_swizzle(1);
+                so->formats[PAN_VERTEX_ID] = (MALI_R32UI << 12) | panfrost_bifrost_swizzle(1);
 
         if (dev->quirks & HAS_SWIZZLES)
-                so->hw[PAN_INSTANCE_ID].format = (MALI_R32UI << 12) | panfrost_get_default_swizzle(1);
+                so->formats[PAN_INSTANCE_ID] = (MALI_R32UI << 12) | panfrost_get_default_swizzle(1);
         else
-                so->hw[PAN_INSTANCE_ID].format = (MALI_R32UI << 12) | panfrost_bifrost_swizzle(1);
+                so->formats[PAN_INSTANCE_ID] = (MALI_R32UI << 12) | panfrost_bifrost_swizzle(1);
 
         return so;
 }
index a53db0d611f85f54f8cf54743cbac88553dbcc9d..e1a6dc8b5c237fd123798c27ce60016506f93df9 100644 (file)
@@ -254,7 +254,7 @@ struct panfrost_vertex_state {
         unsigned num_elements;
 
         struct pipe_vertex_element pipe[PIPE_MAX_ATTRIBS];
-        struct mali_attr_meta hw[PIPE_MAX_ATTRIBS];
+        unsigned formats[PIPE_MAX_ATTRIBS];
 };
 
 struct panfrost_zsa_state {