Mesa (master): r300/compiler: Use memory_pool_array_reserve in r500-fragprog_emit

Marek Olšák mareko at kemper.freedesktop.org
Sun Apr 18 22:40:25 UTC 2010


Module: Mesa
Branch: master
Commit: 0321f9c6f13a7571376e5eb9ce6c110061ed09fd
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0321f9c6f13a7571376e5eb9ce6c110061ed09fd

Author: Nicolai Hähnle <nhaehnle at gmail.com>
Date:   Sun Oct 11 14:22:16 2009 +0200

r300/compiler: Use memory_pool_array_reserve in r500-fragprog_emit

Signed-off-by: Nicolai Hähnle <nhaehnle at gmail.com>

---

 .../drivers/dri/r300/compiler/r500_fragprog_emit.c |   19 ++-----------------
 1 files changed, 2 insertions(+), 17 deletions(-)

diff --git a/src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c b/src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c
index b6dfe28..10c5e23 100644
--- a/src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c
+++ b/src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c
@@ -348,21 +348,6 @@ static int emit_tex(struct r300_fragment_program_compiler *c, struct rc_sub_inst
 	return 1;
 }
 
-static void grow_branches(struct emit_state * s)
-{
-	unsigned int newreserved = s->BranchesReserved * 2;
-	struct branch_info * newbranches;
-
-	if (!newreserved)
-		newreserved = 4;
-
-	newbranches = memory_pool_malloc(&s->C->Pool, newreserved*sizeof(struct branch_info));
-	memcpy(newbranches, s->Branches, s->CurrentBranchDepth*sizeof(struct branch_info));
-
-	s->Branches = newbranches;
-	s->BranchesReserved = newreserved;
-}
-
 static void emit_flowcontrol(struct emit_state * s, struct rc_instruction * inst)
 {
 	if (s->Code->inst_end >= 511) {
@@ -380,8 +365,8 @@ static void emit_flowcontrol(struct emit_state * s, struct rc_instruction * inst
 			return;
 		}
 
-		if (s->CurrentBranchDepth >= s->BranchesReserved)
-			grow_branches(s);
+		memory_pool_array_reserve(&s->C->Pool, struct branch_info,
+				s->Branches, s->CurrentBranchDepth, s->BranchesReserved, 1);
 
 		struct branch_info * branch = &s->Branches[s->CurrentBranchDepth++];
 		branch->If = newip;




More information about the mesa-commit mailing list