panfrost: Move assign_vertex_buffer to pan_helpers
authorAlyssa Rosenzweig <alyssa@collabora.com>
Tue, 5 Apr 2022 16:40:08 +0000 (12:40 -0400)
committerMarge Bot <emma+marge@anholt.net>
Thu, 7 Apr 2022 15:11:04 +0000 (15:11 +0000)
Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15795>

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

index 0f23da2..dc87f68 100644 (file)
@@ -3366,31 +3366,6 @@ panfrost_create_rasterizer_state(
         return so;
 }
 
-/* Assigns a vertex buffer for a given (index, divisor) tuple */
-
-static unsigned
-pan_assign_vertex_buffer(struct pan_vertex_buffer *buffers,
-                         unsigned *nr_bufs,
-                         unsigned vbi,
-                         unsigned divisor)
-{
-        /* Look up the buffer */
-        for (unsigned i = 0; i < (*nr_bufs); ++i) {
-                if (buffers[i].vbi == vbi && buffers[i].divisor == divisor)
-                        return i;
-        }
-
-        /* Else, create a new buffer */
-        unsigned idx = (*nr_bufs)++;
-
-        buffers[idx] = (struct pan_vertex_buffer) {
-                .vbi = vbi,
-                .divisor = divisor
-        };
-
-        return idx;
-}
-
 static void *
 panfrost_create_vertex_elements_state(
         struct pipe_context *pctx,
index 82486f7..4f58e44 100644 (file)
@@ -297,6 +297,9 @@ struct panfrost_shader_variants {
         unsigned active_variant;
 };
 
+/** (Vertex buffer index, divisor) tuple that will become an Attribute Buffer
+ * Descriptor at draw-time on Midgard
+ */
 struct pan_vertex_buffer {
         unsigned vbi;
         unsigned divisor;
@@ -315,6 +318,12 @@ struct panfrost_vertex_state {
         unsigned formats[PIPE_MAX_ATTRIBS];
 };
 
+unsigned
+pan_assign_vertex_buffer(struct pan_vertex_buffer *buffers,
+                         unsigned *nr_bufs,
+                         unsigned vbi,
+                         unsigned divisor);
+
 struct panfrost_zsa_state;
 struct panfrost_sampler_state;
 struct panfrost_sampler_view;
index 418f29d..69331d0 100644 (file)
@@ -140,4 +140,32 @@ panfrost_get_index_buffer_bounded(struct panfrost_batch *batch,
         return out;
 }
 
+/**
+ * Given an (index, divisor) tuple, assign a vertex buffer. Midgard and
+ * Bifrost put divisor information on the attribute buffer descriptor, so this
+ * is the most we can compact in general. Crucially, this runs at vertex
+ * elements CSO create time, not at draw time.
+ */
+unsigned
+pan_assign_vertex_buffer(struct pan_vertex_buffer *buffers,
+                         unsigned *nr_bufs,
+                         unsigned vbi,
+                         unsigned divisor)
+{
+        /* Look up the buffer */
+        for (unsigned i = 0; i < (*nr_bufs); ++i) {
+                if (buffers[i].vbi == vbi && buffers[i].divisor == divisor)
+                        return i;
+        }
+
+        /* Else, create a new buffer */
+        unsigned idx = (*nr_bufs)++;
+
+        buffers[idx] = (struct pan_vertex_buffer) {
+                .vbi = vbi,
+                .divisor = divisor
+        };
+
+        return idx;
+}