[PATCH] mesa: Fix bug in handling of read channel masks get_src_ar=
Eric Anholt
eric at anholt.net
Mon Jul 26 16:20:11 PDT 2010
g_mask.
Fixes piglit glsl-fs-add-masked, and my GLSL demo.
---
src/mesa/program/prog_optimize.c | 14 ++++----------
1 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/src/mesa/program/prog_optimize.c b/src/mesa/program/prog_optim=
ize.c
index 9119b10..c853330 100644
--- a/src/mesa/program/prog_optimize.c
+++ b/src/mesa/program/prog_optimize.c
@@ -51,12 +51,11 @@ static const int expand_one[5] =3D {0,1,3,7,15};
static GLuint
get_src_arg_mask(const struct prog_instruction *inst, int arg, int dst_mas=
k)
{
- int read_mask, channel_mask, read_count;
+ int read_mask, channel_mask;
int comp;
/* Form the dst register, find the written channels */
if (inst->CondUpdate) {
- read_count =3D 4;
channel_mask =3D WRITEMASK_XYZW;
}
else {
@@ -67,8 +66,7 @@ get_src_arg_mask(const struct prog_instruction *inst, int=
arg, int dst_mask)
case OPCODE_MAD:
case OPCODE_MUL:
case OPCODE_SUB:
- read_count =3D bit_count[inst->DstReg.WriteMask & dst_mask];
- channel_mask =3D expand_one[read_count];
+ channel_mask =3D inst->DstReg.WriteMask & dst_mask;
break;
case OPCODE_RCP:
case OPCODE_SIN:
@@ -76,20 +74,16 @@ get_src_arg_mask(const struct prog_instruction *inst, i=
nt arg, int dst_mask)
case OPCODE_RSQ:
case OPCODE_POW:
case OPCODE_EX2:
- read_count =3D 1;
channel_mask =3D WRITEMASK_X;
break;
case OPCODE_DP2:
- read_count =3D 2;
channel_mask =3D WRITEMASK_XY;
break;
case OPCODE_DP3:
case OPCODE_XPD:
- read_count =3D 3;
channel_mask =3D WRITEMASK_XYZ;
break;
default:
- read_count =3D 4;
channel_mask =3D WRITEMASK_XYZW;
break;
}
@@ -99,9 +93,9 @@ get_src_arg_mask(const struct prog_instruction *inst, int=
arg, int dst_mask)
* components are actually read
*/
read_mask =3D 0;
- for (comp =3D 0; comp < read_count; ++comp) {
+ for (comp =3D 0; comp < 4; ++comp) {
const int coord =3D GET_SWZ(inst->SrcReg[arg].Swizzle, comp);
- if (coord <=3D SWIZZLE_W)
+ if (channel_mask & (1 << comp) && coord <=3D SWIZZLE_W)
read_mask |=3D 1 << coord;
}
--
1.7.1
More information about the mesa-dev
mailing list