r300/compiler: Fix incorrect assumption
authorTom Stellard <tstellar@gmail.com>
Wed, 6 Oct 2010 05:53:40 +0000 (22:53 -0700)
committerTom Stellard <tstellar@gmail.com>
Tue, 19 Oct 2010 03:51:05 +0000 (20:51 -0700)
It is possible for a single pair instruction arg to select from both an
RGB and an Alpha source.

src/mesa/drivers/dri/r300/compiler/radeon_pair_schedule.c
src/mesa/drivers/dri/r300/compiler/radeon_program_pair.c
src/mesa/drivers/dri/r300/compiler/radeon_program_pair.h

index 15e7c0b1437bb06d652a4556e216b857ce19a749..d4a38607d9e5ba71b6556930a27259aaf2da12cd 100644 (file)
@@ -286,7 +286,7 @@ static void emit_all_tex(struct schedule_state * s, struct rc_instruction * befo
 static int merge_presub_sources(
        struct rc_pair_instruction * dst_full,
        struct rc_pair_sub_instruction src,
-       rc_pair_source_type type)
+       unsigned int type)
 {
        unsigned int srcp_src, srcp_regs, is_rgb, is_alpha;
        struct rc_pair_sub_instruction * dst_sub;
@@ -355,9 +355,9 @@ static int merge_presub_sources(
                for(arg = 0; arg < info->NumSrcRegs; arg++) {
                        /*If this arg does not read from an rgb source,
                         * do nothing. */
-                       if (rc_source_type_that_arg_reads(
+                       if (!(rc_source_type_that_arg_reads(
                                dst_full->RGB.Arg[arg].Source,
-                               dst_full->RGB.Arg[arg].Swizzle, 3) != type) {
+                               dst_full->RGB.Arg[arg].Swizzle) & type)) {
                                continue;
                        }
                        if (dst_full->RGB.Arg[arg].Source == srcp_src)
index c31efdb059058f863cbed993dd995cd0a1f3f738..a21fe8d3df8ac0c15b4cc4ff4be611863752ca1e 100644 (file)
@@ -206,34 +206,22 @@ void rc_pair_foreach_source_that_rgb_reads(
 
 /*return 0 for rgb, 1 for alpha -1 for error. */
 
-rc_pair_source_type rc_source_type_that_arg_reads(
+unsigned int rc_source_type_that_arg_reads(
        unsigned int source,
-       unsigned int swizzle,
-       unsigned int channels)
+       unsigned int swizzle)
 {
        unsigned int chan;
        unsigned int swz = RC_SWIZZLE_UNUSED;
-       int isRGB = 0;
-       int isAlpha = 0;
-       /* Find a swizzle that is either X,Y,Z,or W.  We assume here
-        * that if one channel swizzles X,Y, or Z, then none of the
-        * other channels swizzle W, and vice-versa. */
-       for(chan = 0; chan < channels; chan++) {
+       unsigned int ret = RC_PAIR_SOURCE_NONE;
+
+       for(chan = 0; chan < 3; chan++) {
                swz = GET_SWZ(swizzle, chan);
                if (swz == RC_SWIZZLE_W) {
-                       isAlpha = 1;
+                       ret |= RC_PAIR_SOURCE_ALPHA;
                } else if (swz == RC_SWIZZLE_X || swz == RC_SWIZZLE_Y
                                                || swz == RC_SWIZZLE_Z) {
-                       isRGB = 1;
+                       ret |= RC_PAIR_SOURCE_RGB;
                }
        }
-       assert(!isRGB || !isAlpha);
-
-       if(!isRGB && !isAlpha)
-               return RC_PAIR_SOURCE_NONE;
-
-       if (isRGB)
-               return RC_PAIR_SOURCE_RGB;
-       /*isAlpha*/
-       return RC_PAIR_SOURCE_ALPHA;
+       return ret;
 }
index 01cdb154240f14cd96669ef11678fc673dbd6cf5..54d44a2098b02459d0bc4aa6e4deba251b2db1ec 100644 (file)
@@ -55,6 +55,10 @@ struct radeon_compiler;
  */
 #define RC_PAIR_PRESUB_SRC 3
 
+#define RC_PAIR_SOURCE_NONE  0x0
+#define RC_PAIR_SOURCE_RGB   0x1
+#define RC_PAIR_SOURCE_ALPHA 0x2
+
 struct rc_pair_instruction_source {
        unsigned int Used:1;
        unsigned int File:3;
@@ -93,12 +97,6 @@ struct rc_pair_instruction {
 typedef void (*rc_pair_foreach_src_fn)
                        (void *, struct rc_pair_instruction_source *);
 
-typedef enum {
-       RC_PAIR_SOURCE_NONE = 0,
-       RC_PAIR_SOURCE_RGB,
-       RC_PAIR_SOURCE_ALPHA
-} rc_pair_source_type;
-
 /**
  * General helper functions for dealing with the paired instruction format.
  */
@@ -117,10 +115,9 @@ void rc_pair_foreach_source_that_rgb_reads(
        void * data,
        rc_pair_foreach_src_fn cb);
 
-rc_pair_source_type rc_source_type_that_arg_reads(
+unsigned int rc_source_type_that_arg_reads(
        unsigned int source,
-       unsigned int swizzle,
-       unsigned int channels);
+       unsigned int swizzle);
 /*@}*/