panfrost: Move panfrost_emit_vertex_data() to pan_cmdstream.c
authorBoris Brezillon <boris.brezillon@collabora.com>
Fri, 6 Mar 2020 08:09:03 +0000 (09:09 +0100)
committerBoris Brezillon <boris.brezillon@collabora.com>
Tue, 10 Mar 2020 11:47:34 +0000 (12:47 +0100)
Move panfrost_emit_vertex_data() to pan_cmdstream.c where other emit
functions live, and adjust the prototype for consistency.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4083>

src/gallium/drivers/panfrost/Makefile.sources
src/gallium/drivers/panfrost/meson.build
src/gallium/drivers/panfrost/pan_attributes.c [deleted file]
src/gallium/drivers/panfrost/pan_cmdstream.c
src/gallium/drivers/panfrost/pan_cmdstream.h
src/gallium/drivers/panfrost/pan_context.c
src/gallium/drivers/panfrost/pan_context.h

index 835f2255fb619e59e21c6b141b3a8a4c0ecec17b..78bd155a3d6b4097049d6a5089bf153dae41b2a4 100644 (file)
@@ -20,7 +20,6 @@ C_SOURCES := \
        pan_context.c \
        pan_context.h \
        pan_fragment.c \
-       pan_attributes.c \
        pan_job.c \
        pan_job.h \
        pan_mfbd.c \
index 6505cbaaf1d80901a39b17a0d1c5bfdd88ac9b7f..eb5d62715b4eab4c670e2b167a99147ac10506f6 100644 (file)
@@ -41,7 +41,6 @@ files_panfrost = files(
   'pan_cmdstream.c',
   'pan_compute.c',
   'pan_fragment.c',
-  'pan_attributes.c',
   'pan_scoreboard.c',
   'pan_sfbd.c',
   'pan_mfbd.c',
diff --git a/src/gallium/drivers/panfrost/pan_attributes.c b/src/gallium/drivers/panfrost/pan_attributes.c
deleted file mode 100644 (file)
index 31bdd2c..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright (C) 2018-2019 Alyssa Rosenzweig
- * Copyright (C) 2019 Collabora, Ltd.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#include "pan_bo.h"
-#include "pan_context.h"
-
-void
-panfrost_emit_vertex_data(struct panfrost_batch *batch)
-{
-        struct panfrost_context *ctx = batch->ctx;
-        struct panfrost_vertex_state *so = ctx->vertex;
-
-        /* Staged mali_attr, and index into them. i =/= k, depending on the
-         * vertex buffer mask and instancing. Twice as much room is allocated,
-         * for a worst case of NPOT_DIVIDEs which take up extra slot */
-        union mali_attr attrs[PIPE_MAX_ATTRIBS * 2];
-        unsigned k = 0;
-
-        for (unsigned i = 0; i < so->num_elements; ++i) {
-                /* We map a mali_attr to be 1:1 with the mali_attr_meta, which
-                 * means duplicating some vertex buffers (who cares? aside from
-                 * maybe some caching implications but I somehow doubt that
-                 * matters) */
-
-                struct pipe_vertex_element *elem = &so->pipe[i];
-                unsigned vbi = elem->vertex_buffer_index;
-
-                /* The exception to 1:1 mapping is that we can have multiple
-                 * entries (NPOT divisors), so we fixup anyways */
-
-                so->hw[i].index = k;
-
-                if (!(ctx->vb_mask & (1 << vbi))) continue;
-
-                struct pipe_vertex_buffer *buf = &ctx->vertex_buffers[vbi];
-                struct panfrost_resource *rsrc = (struct panfrost_resource *) (buf->buffer.resource);
-
-                if (!rsrc) continue;
-
-                /* Align to 64 bytes by masking off the lower bits. This
-                 * will be adjusted back when we fixup the src_offset in
-                 * mali_attr_meta */
-
-                mali_ptr raw_addr = rsrc->bo->gpu + buf->buffer_offset;
-                mali_ptr addr = raw_addr & ~63;
-                unsigned chopped_addr = raw_addr - addr;
-
-                /* Add a dependency of the batch on the vertex buffer */
-                panfrost_batch_add_bo(batch, rsrc->bo,
-                                      PAN_BO_ACCESS_SHARED |
-                                      PAN_BO_ACCESS_READ |
-                                      PAN_BO_ACCESS_VERTEX_TILER);
-
-                /* Set common fields */
-                attrs[k].elements = addr;
-                attrs[k].stride = buf->stride;
-
-                /* Since we advanced the base pointer, we shrink the buffer
-                 * size */
-                attrs[k].size = rsrc->base.width0 - buf->buffer_offset;
-
-                /* We need to add the extra size we masked off (for
-                 * correctness) so the data doesn't get clamped away */
-                attrs[k].size += chopped_addr;
-
-                /* For non-instancing make sure we initialize */
-                attrs[k].shift = attrs[k].extra_flags = 0;
-
-                /* Instancing uses a dramatically different code path than
-                 * linear, so dispatch for the actual emission now that the
-                 * common code is finished */
-
-                unsigned divisor = elem->instance_divisor;
-
-                if (divisor && ctx->instance_count == 1) {
-                        /* Silly corner case where there's a divisor(=1) but
-                         * there's no legitimate instancing. So we want *every*
-                         * attribute to be the same. So set stride to zero so
-                         * we don't go anywhere. */
-
-                        attrs[k].size = attrs[k].stride + chopped_addr;
-                        attrs[k].stride = 0;
-                        attrs[k++].elements |= MALI_ATTR_LINEAR;
-                } else if (ctx->instance_count <= 1) {
-                        /* Normal, non-instanced attributes */
-                        attrs[k++].elements |= MALI_ATTR_LINEAR;
-                } else {
-                        unsigned instance_shift = batch->ctx->payloads[PIPE_SHADER_FRAGMENT].instance_shift;
-                        unsigned instance_odd = batch->ctx->payloads[PIPE_SHADER_FRAGMENT].instance_odd;
-
-                        k += panfrost_vertex_instanced(batch->ctx->padded_count,
-                                        instance_shift, instance_odd, divisor, &attrs[k]);
-                }
-        }
-
-        /* Add special gl_VertexID/gl_InstanceID buffers */
-
-        panfrost_vertex_id(ctx->padded_count, &attrs[k]);
-        so->hw[PAN_VERTEX_ID].index = k++;
-        panfrost_instance_id(ctx->padded_count, &attrs[k]);
-        so->hw[PAN_INSTANCE_ID].index = k++;
-
-        /* Upload whatever we emitted and go */
-
-        ctx->payloads[PIPE_SHADER_VERTEX].postfix.attributes =
-                panfrost_upload_transient(batch, attrs, k * sizeof(union mali_attr));
-}
-
-
index a4816363ddf5a6bb36c0e7a4ebbaf024379b457f..d49bdd95ec252a4d47478b2f4e91cdf1b6ce0660 100644 (file)
@@ -1206,6 +1206,114 @@ panfrost_emit_vertex_attr_meta(struct panfrost_batch *batch,
                                                                PAN_MAX_ATTRIBUTE);
 }
 
+void
+panfrost_emit_vertex_data(struct panfrost_batch *batch,
+                          struct midgard_payload_vertex_tiler *vp)
+{
+        struct panfrost_context *ctx = batch->ctx;
+        struct panfrost_vertex_state *so = ctx->vertex;
+
+        /* Staged mali_attr, and index into them. i =/= k, depending on the
+         * vertex buffer mask and instancing. Twice as much room is allocated,
+         * for a worst case of NPOT_DIVIDEs which take up extra slot */
+        union mali_attr attrs[PIPE_MAX_ATTRIBS * 2];
+        unsigned k = 0;
+
+        for (unsigned i = 0; i < so->num_elements; ++i) {
+                /* We map a mali_attr to be 1:1 with the mali_attr_meta, which
+                 * means duplicating some vertex buffers (who cares? aside from
+                 * maybe some caching implications but I somehow doubt that
+                 * matters) */
+
+                struct pipe_vertex_element *elem = &so->pipe[i];
+                unsigned vbi = elem->vertex_buffer_index;
+
+                /* The exception to 1:1 mapping is that we can have multiple
+                 * entries (NPOT divisors), so we fixup anyways */
+
+                so->hw[i].index = k;
+
+                if (!(ctx->vb_mask & (1 << vbi)))
+                        continue;
+
+                struct pipe_vertex_buffer *buf = &ctx->vertex_buffers[vbi];
+                struct panfrost_resource *rsrc;
+
+                rsrc = pan_resource(buf->buffer.resource);
+                if (!rsrc)
+                        continue;
+
+                /* Align to 64 bytes by masking off the lower bits. This
+                 * will be adjusted back when we fixup the src_offset in
+                 * mali_attr_meta */
+
+                mali_ptr raw_addr = rsrc->bo->gpu + buf->buffer_offset;
+                mali_ptr addr = raw_addr & ~63;
+                unsigned chopped_addr = raw_addr - addr;
+
+                /* Add a dependency of the batch on the vertex buffer */
+                panfrost_batch_add_bo(batch, rsrc->bo,
+                                      PAN_BO_ACCESS_SHARED |
+                                      PAN_BO_ACCESS_READ |
+                                      PAN_BO_ACCESS_VERTEX_TILER);
+
+                /* Set common fields */
+                attrs[k].elements = addr;
+                attrs[k].stride = buf->stride;
+
+                /* Since we advanced the base pointer, we shrink the buffer
+                 * size */
+                attrs[k].size = rsrc->base.width0 - buf->buffer_offset;
+
+                /* We need to add the extra size we masked off (for
+                 * correctness) so the data doesn't get clamped away */
+                attrs[k].size += chopped_addr;
+
+                /* For non-instancing make sure we initialize */
+                attrs[k].shift = attrs[k].extra_flags = 0;
+
+                /* Instancing uses a dramatically different code path than
+                 * linear, so dispatch for the actual emission now that the
+                 * common code is finished */
+
+                unsigned divisor = elem->instance_divisor;
+
+                if (divisor && ctx->instance_count == 1) {
+                        /* Silly corner case where there's a divisor(=1) but
+                         * there's no legitimate instancing. So we want *every*
+                         * attribute to be the same. So set stride to zero so
+                         * we don't go anywhere. */
+
+                        attrs[k].size = attrs[k].stride + chopped_addr;
+                        attrs[k].stride = 0;
+                        attrs[k++].elements |= MALI_ATTR_LINEAR;
+                } else if (ctx->instance_count <= 1) {
+                        /* Normal, non-instanced attributes */
+                        attrs[k++].elements |= MALI_ATTR_LINEAR;
+                } else {
+                        unsigned instance_shift = vp->instance_shift;
+                        unsigned instance_odd = vp->instance_odd;
+
+                        k += panfrost_vertex_instanced(ctx->padded_count,
+                                                       instance_shift,
+                                                       instance_odd,
+                                                       divisor, &attrs[k]);
+                }
+        }
+
+        /* Add special gl_VertexID/gl_InstanceID buffers */
+
+        panfrost_vertex_id(ctx->padded_count, &attrs[k]);
+        so->hw[PAN_VERTEX_ID].index = k++;
+        panfrost_instance_id(ctx->padded_count, &attrs[k]);
+        so->hw[PAN_INSTANCE_ID].index = k++;
+
+        /* Upload whatever we emitted and go */
+
+        vp->postfix.attributes = panfrost_upload_transient(batch, attrs,
+                                                           k * sizeof(*attrs));
+}
+
 void
 panfrost_emit_vertex_tiler_jobs(struct panfrost_batch *batch,
                                 struct midgard_payload_vertex_tiler *vp,
index 0d35de70f90198757756566c6ec5460995ac51ed..4574750af0654e7e5ae6bd66ff06c5e351ee8011 100644 (file)
@@ -89,6 +89,10 @@ void
 panfrost_emit_vertex_attr_meta(struct panfrost_batch *batch,
                                struct midgard_payload_vertex_tiler *vp);
 
+void
+panfrost_emit_vertex_data(struct panfrost_batch *batch,
+                          struct midgard_payload_vertex_tiler *vp);
+
 void
 panfrost_emit_vertex_tiler_jobs(struct panfrost_batch *batch,
                                 struct midgard_payload_vertex_tiler *vp,
index f09c0edf385d26fdb90f0efc095c61e2fa909c00..d938e43d2f43af93f275d5b35dbe9b98c19362f9 100644 (file)
@@ -445,7 +445,7 @@ panfrost_draw_vbo(
                 1, 1, 1);
 
         /* Emit all sort of descriptors. */
-        panfrost_emit_vertex_data(batch);
+        panfrost_emit_vertex_data(batch, &ctx->payloads[PIPE_SHADER_VERTEX]);
         panfrost_emit_varying_descriptor(ctx,
                                          ctx->padded_count *
                                          ctx->instance_count);
index cc8d0eb16dfadf349071a00b4d8f669ea1e0df3c..3139309a94c0f419d4e4d6be9b9ee8e233613c03 100644 (file)
@@ -332,9 +332,6 @@ panfrost_ubo_count(struct panfrost_context *ctx, enum pipe_shader_type stage);
 mali_ptr
 panfrost_vertex_buffer_address(struct panfrost_context *ctx, unsigned i);
 
-void
-panfrost_emit_vertex_data(struct panfrost_batch *batch);
-
 /* Compute */
 
 void