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;
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)
/*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;
}
*/
#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;
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.
*/
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);
/*@}*/