diff options
author | Tom Stellard <[email protected]> | 2010-10-05 22:53:40 -0700 |
---|---|---|
committer | Tom Stellard <[email protected]> | 2010-10-18 20:51:05 -0700 |
commit | 75734d0a37c7cb24fb97c9ba0166f9f2d2da60f8 (patch) | |
tree | 8c616f3838f1927f0b14adf532f4cabad06e83cd /src | |
parent | ad683577b202750ffac917392d50fb7202d5bf2a (diff) |
r300/compiler: Fix incorrect assumption
It is possible for a single pair instruction arg to select from both an
RGB and an Alpha source.
Diffstat (limited to 'src')
3 files changed, 17 insertions, 32 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 15e7c0b1437..d4a38607d9e 100644 --- a/src/mesa/drivers/dri/r300/compiler/radeon_pair_schedule.c +++ b/src/mesa/drivers/dri/r300/compiler/radeon_pair_schedule.c @@ -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) diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_program_pair.c b/src/mesa/drivers/dri/r300/compiler/radeon_program_pair.c index c31efdb0590..a21fe8d3df8 100644 --- a/src/mesa/drivers/dri/r300/compiler/radeon_program_pair.c +++ b/src/mesa/drivers/dri/r300/compiler/radeon_program_pair.c @@ -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; } diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_program_pair.h b/src/mesa/drivers/dri/r300/compiler/radeon_program_pair.h index 01cdb154240..54d44a2098b 100644 --- a/src/mesa/drivers/dri/r300/compiler/radeon_program_pair.h +++ b/src/mesa/drivers/dri/r300/compiler/radeon_program_pair.h @@ -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); /*@}*/ |