r300/compiler: Don't allow presubtract sources to be remapped twice
authorTom Stellard <tstellar@gmail.com>
Tue, 23 Nov 2010 07:48:47 +0000 (23:48 -0800)
committerTom Stellard <tstellar@gmail.com>
Tue, 23 Nov 2010 08:02:03 +0000 (00:02 -0800)
https://bugs.freedesktop.org/show_bug.cgi?id=31193

NOTE: This is a candidate for the 7.9 branch.

src/mesa/drivers/dri/r300/compiler/radeon_dataflow.c

index 9df07edf2b1a704818a4b31fa94a10626116751a..d0a64d936e055fdab01db8fa3e0b0fead73b6172 100644 (file)
@@ -347,6 +347,7 @@ static void remap_normal_instruction(struct rc_instruction * fullinst,
 {
        struct rc_sub_instruction * inst = &fullinst->U.I;
        const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->Opcode);
+       unsigned int remapped_presub = 0;
 
        if (opcode->HasDstReg) {
                rc_register_file file = inst->DstReg.File;
@@ -366,6 +367,12 @@ static void remap_normal_instruction(struct rc_instruction * fullinst,
                        unsigned int i;
                        unsigned int srcp_srcs = rc_presubtract_src_reg_count(
                                                inst->PreSub.Opcode);
+                       /* Make sure we only remap presubtract sources once in
+                        * case more than one source register reads the
+                        * presubtract result. */
+                       if (remapped_presub)
+                               continue;
+
                        for(i = 0; i < srcp_srcs; i++) {
                                file = inst->PreSub.SrcReg[i].File;
                                index = inst->PreSub.SrcReg[i].Index;
@@ -373,7 +380,7 @@ static void remap_normal_instruction(struct rc_instruction * fullinst,
                                inst->PreSub.SrcReg[i].File = file;
                                inst->PreSub.SrcReg[i].Index = index;
                        }
-
+                       remapped_presub = 1;
                }
                else {
                        cb(userdata, fullinst, &file, &index);