nv50: release hw TEMPs early
authorChristoph Bumiller <e0425955@student.tuwien.ac.at>
Sat, 23 May 2009 13:15:20 +0000 (15:15 +0200)
committerBen Skeggs <bskeggs@redhat.com>
Thu, 28 May 2009 06:06:23 +0000 (16:06 +1000)
Since we know when we don't use a TEMP or FP ATTR register anymore,
we can release their hw resources early.

src/gallium/drivers/nv50/nv50_program.c

index 30aa35886041f905e101085229250e87d8aa5c7b..15d7ab0da569a9cc0e58c79d5bcdd1eb8921ff03 100644 (file)
@@ -214,6 +214,22 @@ assimilate_temp(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src)
        FREE(src);
 }
 
+/* release the hardware resource held by r */
+static void
+release_hw(struct nv50_pc *pc, struct nv50_reg *r)
+{
+       assert(r->type == P_TEMP);
+       if (r->hw == -1)
+               return;
+
+       assert(pc->r_temp[r->hw] == r);
+       pc->r_temp[r->hw] = NULL;
+
+       r->acc = 0;
+       if (r->index == -1)
+               FREE(r);
+}
+
 static void
 free_temp(struct nv50_pc *pc, struct nv50_reg *r)
 {
@@ -1496,6 +1512,9 @@ nv50_program_tx_insn(struct nv50_pc *pc, const union tgsi_full_token *tok)
                                continue;
                        if (src[i][c]->index == -1 && src[i][c]->type == P_IMMD)
                                FREE(src[i][c]);
+                       else
+                       if (src[i][c]->acc == pc->insn_cur)
+                               release_hw(pc, src[i][c]);
                }
        }