vc4: Use the intrinsic's first_component for vattr VPM index.
authorEric Anholt <eric@anholt.net>
Thu, 4 Aug 2016 23:33:16 +0000 (16:33 -0700)
committerEric Anholt <eric@anholt.net>
Fri, 19 Aug 2016 20:11:36 +0000 (13:11 -0700)
Avoids another multiplication by 4 of the base in the NIR.

src/gallium/drivers/vc4/vc4_nir_lower_io.c
src/gallium/drivers/vc4/vc4_program.c

index d2b27bd7c8a7d169461b6bc3cb76ef9617548ae0..ad96ef5ad82880946a6e0139bcabd87d413a7791 100644 (file)
@@ -196,8 +196,8 @@ vc4_nir_lower_vertex_attr(struct vc4_compile *c, nir_builder *b,
                         nir_intrinsic_instr_create(c->s,
                                                    nir_intrinsic_load_input);
                 intr_comp->num_components = 1;
-                nir_intrinsic_set_base(intr_comp,
-                                       nir_intrinsic_base(intr) * 4 + i);
+                nir_intrinsic_set_base(intr_comp, nir_intrinsic_base(intr));
+                nir_intrinsic_set_component(intr_comp, i);
                 intr_comp->src[0] = nir_src_for_ssa(nir_imm_int(b, 0));
                 nir_ssa_dest_init(&intr_comp->instr, &intr_comp->dest, 1, 32, NULL);
                 nir_builder_instr_insert(b, &intr_comp->instr);
index 4d1d6237a0cba768c166dcffa9fb8d66dd90f677..454202753a5d6862ebffc59772716a0021842790 100644 (file)
@@ -1627,15 +1627,11 @@ ntq_emit_intrinsic(struct vc4_compile *c, nir_intrinsic_instr *instr)
                         }
                         ntq_store_dest(c, &instr->dest, 0,
                                        c->color_reads[sample_index]);
-                } else if (c->stage == QSTAGE_FRAG) {
+                } else {
                         offset = nir_intrinsic_base(instr) + const_offset->u32[0];
                         int comp = nir_intrinsic_component(instr);
                         ntq_store_dest(c, &instr->dest, 0,
                                        c->inputs[offset * 4 + comp]);
-                } else {
-                        offset = nir_intrinsic_base(instr) + const_offset->u32[0];
-                        ntq_store_dest(c, &instr->dest, 0,
-                                       c->inputs[offset]);
                 }
                 break;