panfrost: Factor batch/resource out of instancing routines
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Thu, 19 Dec 2019 21:26:43 +0000 (16:26 -0500)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 25 Dec 2019 00:48:57 +0000 (19:48 -0500)
They don't need them; this will allow us to move the code into encoder/
which in turn will make the messy Gallium code less scary.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/gallium/drivers/panfrost/pan_attributes.c

index 473026cb8a0607ff6749698f3bddeaaa584bc728..4fa3546f3a38ae1f745f5bcb0524827be1816652 100644 (file)
@@ -165,23 +165,11 @@ panfrost_padded_vertex_count(
 
 static unsigned
 panfrost_vertex_instanced(
-        struct panfrost_batch *batch,
-        struct panfrost_resource *rsrc,
+        unsigned padded_count,
+        unsigned instance_shift, unsigned instance_odd,
         unsigned divisor,
-        union mali_attr *attrs,
-        mali_ptr addr,
-        unsigned vertex_count,
-        unsigned instance_count)
+        union mali_attr *attrs)
 {
-        /* First, grab the padded vertex count */
-
-        struct pan_shift_odd o = {
-                .shift = batch->ctx->payloads[PIPE_SHADER_FRAGMENT].instance_shift,
-                .odd = batch->ctx->payloads[PIPE_SHADER_FRAGMENT].instance_odd,
-        };
-
-        unsigned padded_count = batch->ctx->padded_count;
-
         /* Depending if there is an instance divisor or not, packing varies.
          * When there is a divisor, the hardware-level divisor is actually the
          * product of the instance divisor and the padded count */
@@ -193,8 +181,8 @@ panfrost_vertex_instanced(
                  * the modulus */
 
                 attrs->elements |= MALI_ATTR_MODULO;
-                attrs->shift = o.shift;
-                attrs->extra_flags = o.odd;
+                attrs->shift = instance_shift;
+                attrs->extra_flags = instance_odd;
 
                 return 1;
         } else if (util_is_power_of_two_or_zero(hw_divisor)) {
@@ -337,8 +325,11 @@ panfrost_emit_vertex_data(struct panfrost_batch *batch)
                         /* Normal, non-instanced attributes */
                         attrs[k++].elements |= MALI_ATTR_LINEAR;
                 } else {
-                        k += panfrost_vertex_instanced(
-                                     batch, rsrc, divisor, &attrs[k], addr, vertex_count, instanced_count);
+                        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]);
                 }
         }