From bb8a9038ff3c8564c7fcc2750c6e59000457db65 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 5 Apr 2022 12:40:08 -0400 Subject: [PATCH] panfrost: Move assign_vertex_buffer to pan_helpers Signed-off-by: Alyssa Rosenzweig Part-of: --- 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 0f23da2..dc87f68 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 82486f7..4f58e44 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 418f29d..69331d0 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; +} -- 2.7.4