v3d/compiler: handle compact varyings
[mesa.git] / src / broadcom / compiler / nir_to_vir.c
index 999c7eef3e21375e60b2b32e82065393721fe243..fa4910fea3fc0c60e65cc2f5ae2d3c675c748fc7 100644 (file)
@@ -737,6 +737,19 @@ emit_fragment_input(struct v3d_compile *c, int attr, nir_variable *var,
         }
 }
 
         }
 }
 
+static void
+emit_compact_fragment_input(struct v3d_compile *c, int attr, nir_variable *var,
+                            int array_index)
+{
+        /* Compact variables are scalar arrays where each set of 4 elements
+         * consumes a single location.
+         */
+        int loc_offset = array_index / 4;
+        int chan = var->data.location_frac + array_index % 4;
+        c->inputs[(attr + loc_offset) * 4  + chan] =
+              emit_fragment_varying(c, var, chan, loc_offset);
+}
+
 static void
 add_output(struct v3d_compile *c,
            uint32_t decl_offset,
 static void
 add_output(struct v3d_compile *c,
            uint32_t decl_offset,
@@ -1658,6 +1671,9 @@ ntq_setup_fs_inputs(struct v3d_compile *c)
                                                        c->fs_key->point_sprite_mask)) {
                         c->inputs[loc * 4 + 0] = c->point_x;
                         c->inputs[loc * 4 + 1] = c->point_y;
                                                        c->fs_key->point_sprite_mask)) {
                         c->inputs[loc * 4 + 0] = c->point_x;
                         c->inputs[loc * 4 + 1] = c->point_y;
+                } else if (var->data.compact) {
+                        for (int j = 0; j < array_len; j++)
+                                emit_compact_fragment_input(c, loc, var, j);
                 } else {
                         for (int j = 0; j < array_len; j++)
                                 emit_fragment_input(c, loc + j, var, j);
                 } else {
                         for (int j = 0; j < array_len; j++)
                                 emit_fragment_input(c, loc + j, var, j);