From: Maciej Cencora Date: Sat, 11 Jul 2009 17:10:58 +0000 (+0200) Subject: r300: fix swizzle masking in getUsedComponents X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3f5382819e31071c2af6cb39c1ca09bf3243f83f;p=mesa.git r300: fix swizzle masking in getUsedComponents --- diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index 703fba48744..9f807dbc993 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -1524,10 +1524,14 @@ static GLuint getUsedComponents(const GLuint swizzle) ret = 0; /* need to mask out ZERO, ONE and NIL swizzles */ - ret |= 1 << (GET_SWZ(swizzle, SWIZZLE_X) & 0x3); - ret |= 1 << (GET_SWZ(swizzle, SWIZZLE_Y) & 0x3); - ret |= 1 << (GET_SWZ(swizzle, SWIZZLE_Z) & 0x3); - ret |= 1 << (GET_SWZ(swizzle, SWIZZLE_W) & 0x3); + if (GET_SWZ(swizzle, SWIZZLE_X) <= SWIZZLE_W) + ret |= 1 << (GET_SWZ(swizzle, SWIZZLE_X)); + if (GET_SWZ(swizzle, SWIZZLE_Y) <= SWIZZLE_W) + ret |= 1 << (GET_SWZ(swizzle, SWIZZLE_Y)); + if (GET_SWZ(swizzle, SWIZZLE_Z) <= SWIZZLE_W) + ret |= 1 << (GET_SWZ(swizzle, SWIZZLE_Z)); + if (GET_SWZ(swizzle, SWIZZLE_W) <= SWIZZLE_W) + ret |= 1 << (GET_SWZ(swizzle, SWIZZLE_W)); return ret; }