Mesa (main): panfrost: Move assign_vertex_buffer to pan_helpers

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Apr 7 15:24:27 UTC 2022


Module: Mesa
Branch: main
Commit: bb8a9038ff3c8564c7fcc2750c6e59000457db65
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=bb8a9038ff3c8564c7fcc2750c6e59000457db65

Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date:   Tue Apr  5 12:40:08 2022 -0400

panfrost: Move assign_vertex_buffer to pan_helpers

Signed-off-by: Alyssa Rosenzweig <alyssa at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15795>

---

 src/gallium/drivers/panfrost/pan_cmdstream.c | 25 -------------------------
 src/gallium/drivers/panfrost/pan_context.h   |  9 +++++++++
 src/gallium/drivers/panfrost/pan_helpers.c   | 28 ++++++++++++++++++++++++++++
 3 files changed, 37 insertions(+), 25 deletions(-)

diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c
index 0f23da2b12e..dc87f682e18 100644
--- a/src/gallium/drivers/panfrost/pan_cmdstream.c
+++ b/src/gallium/drivers/panfrost/pan_cmdstream.c
@@ -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,
diff --git a/src/gallium/drivers/panfrost/pan_context.h b/src/gallium/drivers/panfrost/pan_context.h
index 82486f7f149..4f58e4456a1 100644
--- a/src/gallium/drivers/panfrost/pan_context.h
+++ b/src/gallium/drivers/panfrost/pan_context.h
@@ -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;
diff --git a/src/gallium/drivers/panfrost/pan_helpers.c b/src/gallium/drivers/panfrost/pan_helpers.c
index 418f29de66e..69331d06795 100644
--- a/src/gallium/drivers/panfrost/pan_helpers.c
+++ b/src/gallium/drivers/panfrost/pan_helpers.c
@@ -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;
+}
 



More information about the mesa-commit mailing list