panfrost: Make instancing code more obvious
authorAlyssa Rosenzweig <alyssa@collabora.com>
Thu, 3 Jun 2021 19:14:00 +0000 (15:14 -0400)
committerMarge Bot <eric+marge@anholt.net>
Thu, 10 Jun 2021 18:06:10 +0000 (18:06 +0000)
Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11123>

src/gallium/drivers/panfrost/pan_cmdstream.c

index b5562e2..f2c1193 100644 (file)
@@ -1724,23 +1724,24 @@ panfrost_emit_vertex_data(struct panfrost_batch *batch,
 
                 unsigned hw_divisor = ctx->padded_count * divisor;
 
-                /* If there's a divisor(=1) but no instancing, we want every
-                 * attribute to be the same */
+                if (ctx->instance_count <= 1) {
+                        /* Per-instance would be every attribute equal */
+                        if (divisor)
+                                stride = 0;
 
-                if (divisor && ctx->instance_count == 1)
-                        stride = 0;
-
-                if (!divisor || ctx->instance_count <= 1) {
                         pan_pack(bufs + k, ATTRIBUTE_BUFFER, cfg) {
-                                if (ctx->instance_count > 1) {
-                                        cfg.type = MALI_ATTRIBUTE_TYPE_1D_MODULUS;
-                                        cfg.divisor = ctx->padded_count;
-                                }
-
                                 cfg.pointer = addr;
                                 cfg.stride = stride;
                                 cfg.size = size;
                         }
+                } else if (!divisor) {
+                        pan_pack(bufs + k, ATTRIBUTE_BUFFER, cfg) {
+                                cfg.type = MALI_ATTRIBUTE_TYPE_1D_MODULUS;
+                                cfg.pointer = addr;
+                                cfg.stride = stride;
+                                cfg.size = size;
+                                cfg.divisor = ctx->padded_count;
+                        }
                 } else if (util_is_power_of_two_or_zero(hw_divisor)) {
                         pan_pack(bufs + k, ATTRIBUTE_BUFFER, cfg) {
                                 cfg.type = MALI_ATTRIBUTE_TYPE_1D_POT_DIVISOR;