From cc9f6e607abd0c3c28298807134b037a5fb72ccc Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Mon, 5 Jul 2010 16:23:01 -0700 Subject: [PATCH] r300/compiler: Rename TEX destination registers before scheduling. --- .../dri/r300/compiler/radeon_pair_schedule.c | 53 ++++++++++++++++++++ 1 files changed, 53 insertions(+), 0 deletions(-) diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_pair_schedule.c b/src/mesa/drivers/dri/r300/compiler/radeon_pair_schedule.c index a279549..ab564af 100644 --- a/src/mesa/drivers/dri/r300/compiler/radeon_pair_schedule.c +++ b/src/mesa/drivers/dri/r300/compiler/radeon_pair_schedule.c @@ -481,9 +481,62 @@ static int is_controlflow(struct rc_instruction * inst) return 0; } +static void rewrite_tex_dst_reg(struct r300_fragment_program_compiler *c) +{ + char used_regs[RC_REGISTER_MAX_INDEX]; + struct rc_instruction * inst; + memset(used_regs, 0, sizeof(used_regs)); + + for(inst = c->Base.Program.Instructions.Next; + inst != &c->Base.Program.Instructions; + inst = inst->Next){ + struct rc_instruction * temp; + int old_index, new_index; + const struct rc_opcode_info * info; + if(inst->Type != RC_INSTRUCTION_NORMAL || is_controlflow(inst)) + continue; + + info = rc_get_opcode_info(inst->U.I.Opcode); + if(!info->HasDstReg){ + continue; + } + old_index = inst->U.I.DstReg.Index; + if(!used_regs[old_index]){ + used_regs[old_index] = 1; + continue; + } + fprintf(stderr, "Rewriting TEX\n"); + new_index = rc_find_free_temporary(&c->Base); + for(temp = inst; temp != &c->Base.Program.Instructions; + temp = temp->Next){ + unsigned int i; + info = rc_get_opcode_info(temp->U.I.Opcode); + if(info->HasDstReg){ + struct rc_dst_register *dst = &temp->U.I.DstReg; + if(dst->Index == old_index + && dst->File == RC_FILE_TEMPORARY){ + dst->Index = new_index; + } + } + for(i=0; i < info->NumSrcRegs; i++){ + struct rc_src_register *src = + &temp->U.I.SrcReg[i]; + if(src->Index == old_index + && src->File == RC_FILE_TEMPORARY){ + src->Index = new_index; + } + } + } + used_regs[new_index] = 1; + } +} + void rc_pair_schedule(struct r300_fragment_program_compiler *c) { struct rc_instruction * inst = c->Base.Program.Instructions.Next; + + rewrite_tex_dst_reg(c); + while(inst != &c->Base.Program.Instructions) { if (is_controlflow(inst)) { inst = inst->Next; -- 1.7.1