summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorRoland Scheidegger <[email protected]>2006-09-22 15:48:50 +0000
committerRoland Scheidegger <[email protected]>2006-09-22 15:48:50 +0000
commit9f819dc0145aabe18717dcd1de6e83e62bb8b19a (patch)
tree23157282a07ccbb9ed13bf2fe36cdda38a052f13 /src/mesa
parent9c5d75e592edd15b737294853fc247b66d74619e (diff)
fix up access to vertex attrib components which don't really exist but are defined to some default value by the spec (fogcoord yzw, normal w, secondary color w), by replacing those components with zero/one respectively using swizzling.
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/dri/r200/r200_vertprog.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/src/mesa/drivers/dri/r200/r200_vertprog.c b/src/mesa/drivers/dri/r200/r200_vertprog.c
index cf0c15093fd..366d242270e 100644
--- a/src/mesa/drivers/dri/r200/r200_vertprog.c
+++ b/src/mesa/drivers/dri/r200/r200_vertprog.c
@@ -587,8 +587,46 @@ static GLboolean r200_translate_vertex_program(struct r200_vertex_program *vp)
are_srcs_scalar = operands & SCALAR_FLAG;
operands &= OP_MASK;
- for(i = 0; i < operands; i++)
+ for(i = 0; i < operands; i++) {
src[i] = vpi->SrcReg[i];
+ /* hack up default attrib values as per spec as swizzling.
+ normal, fog, secondary color. Crazy?
+ May need more if we don't submit vec4 elements? */
+ if (src[i].File == PROGRAM_INPUT) {
+ if (src[i].Index == VERT_ATTRIB_NORMAL) {
+ int j;
+ for (j = 0; j < 4; j++) {
+ if (GET_SWZ(src[i].Swizzle, j) == SWIZZLE_W) {
+ src[i].Swizzle &= ~(SWIZZLE_W << (j*3));
+ src[i].Swizzle |= SWIZZLE_ONE << (j*3);
+ }
+ }
+ }
+ else if (src[i].Index == VERT_ATTRIB_COLOR1) {
+ int j;
+ for (j = 0; j < 4; j++) {
+ if (GET_SWZ(src[i].Swizzle, j) == SWIZZLE_W) {
+ src[i].Swizzle &= ~(SWIZZLE_W << (j*3));
+ src[i].Swizzle |= SWIZZLE_ZERO << (j*3);
+ }
+ }
+ }
+ else if (src[i].Index == VERT_ATTRIB_FOG) {
+ int j;
+ for (j = 0; j < 4; j++) {
+ if (GET_SWZ(src[i].Swizzle, j) == SWIZZLE_W) {
+ src[i].Swizzle &= ~(SWIZZLE_W << (j*3));
+ src[i].Swizzle |= SWIZZLE_ONE << (j*3);
+ }
+ else if ((GET_SWZ(src[i].Swizzle, j) == SWIZZLE_Y) ||
+ GET_SWZ(src[i].Swizzle, j) == SWIZZLE_Z) {
+ src[i].Swizzle &= ~(SWIZZLE_W << (j*3));
+ src[i].Swizzle |= SWIZZLE_ZERO << (j*3);
+ }
+ }
+ }
+ }
+ }
if(operands == 3){
if( CMP_SRCS(src[1], src[2]) || CMP_SRCS(src[0], src[2]) ){