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

Author: Marek Olšák <mar...@gmail.com>
Date:   Tue Mar  8 06:54:14 2011 +0100

r300/compiler: detect constants harder

---

 .../drivers/dri/r300/compiler/radeon_optimize.c    |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_optimize.c 
b/src/mesa/drivers/dri/r300/compiler/radeon_optimize.c
index 3915cb4..c4e6a5e 100644
--- a/src/mesa/drivers/dri/r300/compiler/radeon_optimize.c
+++ b/src/mesa/drivers/dri/r300/compiler/radeon_optimize.c
@@ -311,14 +311,18 @@ static void constant_folding(struct radeon_compiler * c, 
struct rc_instruction *
                struct rc_constant * constant;
                struct rc_src_register newsrc;
                int have_real_reference;
+               unsigned int chan;
 
-               if (inst->U.I.SrcReg[src].Swizzle == RC_SWIZZLE_1111 ||
-                   inst->U.I.SrcReg[src].Swizzle == RC_SWIZZLE_0000 ||
-                   inst->U.I.SrcReg[src].Swizzle == RC_SWIZZLE_HHHH) {
+               /* If there are only 0, 0.5, 1, or _ swizzles, mark the source 
as a constant. */
+               for (chan = 0; chan < 4; ++chan)
+                       if (GET_SWZ(inst->U.I.SrcReg[src].Swizzle, chan) <= 3)
+                               break;
+               if (chan == 4) {
                        inst->U.I.SrcReg[src].File = RC_FILE_NONE;
                        continue;
                }
 
+               /* Convert immediates to swizzles. */
                if (inst->U.I.SrcReg[src].File != RC_FILE_CONSTANT ||
                    inst->U.I.SrcReg[src].RelAddr ||
                    inst->U.I.SrcReg[src].Index >= c->Program.Constants.Count)
@@ -332,7 +336,7 @@ static void constant_folding(struct radeon_compiler * c, 
struct rc_instruction *
 
                newsrc = inst->U.I.SrcReg[src];
                have_real_reference = 0;
-               for(unsigned int chan = 0; chan < 4; ++chan) {
+               for (chan = 0; chan < 4; ++chan) {
                        unsigned int swz = GET_SWZ(newsrc.Swizzle, chan);
                        unsigned int newswz;
                        float imm;

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to