diff options
author | Roland Scheidegger <[email protected]> | 2005-09-08 13:41:54 +0000 |
---|---|---|
committer | Roland Scheidegger <[email protected]> | 2005-09-08 13:41:54 +0000 |
commit | f4ff4d36ed320b1551e1f41ee8f52e449c89a626 (patch) | |
tree | f4dacf0be81dc79d02c793f9b605983a7b26ad6d /src/mesa/shader/atifragshader.c | |
parent | 21ed29598f7f06008017004fcca3a5f397be0f23 (diff) |
fix incorrect swizzling handling. fix code so it can potentially handle implementations with less than 6 texture units correctly.
Diffstat (limited to 'src/mesa/shader/atifragshader.c')
-rw-r--r-- | src/mesa/shader/atifragshader.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/src/mesa/shader/atifragshader.c b/src/mesa/shader/atifragshader.c index b86396afc8b..e16c029aa55 100644 --- a/src/mesa/shader/atifragshader.c +++ b/src/mesa/shader/atifragshader.c @@ -395,13 +395,14 @@ _mesa_PassTexCoordATI(GLuint dst, GLuint coord, GLenum swizzle) _mesa_error(ctx, GL_INVALID_OPERATION, "glPassTexCoord(pass)"); return; } - if ((dst < GL_REG_0_ATI) || (dst > GL_REG_5_ATI)) { + if ((dst < GL_REG_0_ATI) || (dst > GL_REG_5_ATI) || + ((dst - GL_REG_0_ATI) >= ctx->Const.MaxTextureUnits)) { _mesa_error(ctx, GL_INVALID_ENUM, "glPassTexCoordATI(dst)"); return; } if (((coord < GL_REG_0_ATI) || (coord > GL_REG_5_ATI)) && - ((coord < GL_TEXTURE0_ARB) || (coord > GL_TEXTURE5_ARB))) { - /* is this texture5 or texture7? spec is a bit unclear there */ + ((coord < GL_TEXTURE0_ARB) || (coord > GL_TEXTURE7_ARB) || + ((coord - GL_TEXTURE0_ARB) >= ctx->Const.MaxTextureUnits))) { _mesa_error(ctx, GL_INVALID_ENUM, "glPassTexCoordATI(coord)"); return; } @@ -417,13 +418,14 @@ _mesa_PassTexCoordATI(GLuint dst, GLuint coord, GLenum swizzle) _mesa_error(ctx, GL_INVALID_OPERATION, "glPassTexCoordATI(swizzle)"); return; } - if (coord <= GL_TEXTURE5) { - if ((((curProg->swizzlerq >> (coord * 2)) & 3) != 0) && - (((swizzle & 1) + 1) != ((curProg->swizzlerq >> (coord * 2)) & 3))) { + if (coord <= GL_TEXTURE7_ARB) { + GLuint tmp = coord - GL_TEXTURE0_ARB; + if ((((curProg->swizzlerq >> (tmp * 2)) & 3) != 0) && + (((swizzle & 1) + 1) != ((curProg->swizzlerq >> (tmp * 2)) & 3))) { _mesa_error(ctx, GL_INVALID_OPERATION, "glPassTexCoordATI(swizzle)"); return; } else { - curProg->swizzlerq |= (((swizzle & 1) + 1) << (coord * 2)); + curProg->swizzlerq |= (((swizzle & 1) + 1) << (tmp * 2)); } } @@ -465,12 +467,14 @@ _mesa_SampleMapATI(GLuint dst, GLuint interp, GLenum swizzle) _mesa_error(ctx, GL_INVALID_OPERATION, "glSampleMapATI(pass)"); return; } - if ((dst < GL_REG_0_ATI) || (dst > GL_REG_5_ATI)) { + if ((dst < GL_REG_0_ATI) || (dst > GL_REG_5_ATI) || + ((dst - GL_REG_0_ATI) >= ctx->Const.MaxTextureUnits)) { _mesa_error(ctx, GL_INVALID_ENUM, "glSampleMapATI(dst)"); return; } if (((interp < GL_REG_0_ATI) || (interp > GL_REG_5_ATI)) && - ((interp < GL_TEXTURE0_ARB) || (interp > GL_TEXTURE5_ARB))) { + ((interp < GL_TEXTURE0_ARB) || (interp > GL_TEXTURE7_ARB) || + ((interp - GL_TEXTURE0_ARB) >= ctx->Const.MaxTextureUnits))) { /* is this texture5 or texture7? spec is a bit unclear there */ _mesa_error(ctx, GL_INVALID_ENUM, "glSampleMapATI(interp)"); return; @@ -487,13 +491,14 @@ _mesa_SampleMapATI(GLuint dst, GLuint interp, GLenum swizzle) _mesa_error(ctx, GL_INVALID_OPERATION, "glSampleMapATI(swizzle)"); return; } - if (interp <= GL_TEXTURE5) { - if ((((curProg->swizzlerq >> (interp * 2)) & 3) != 0) && - (((swizzle & 1) + 1) != ((curProg->swizzlerq >> (interp * 2)) & 3))) { + if (interp <= GL_TEXTURE7_ARB) { + GLuint tmp = interp - GL_TEXTURE0_ARB; + if ((((curProg->swizzlerq >> (tmp * 2)) & 3) != 0) && + (((swizzle & 1) + 1) != ((curProg->swizzlerq >> (tmp * 2)) & 3))) { _mesa_error(ctx, GL_INVALID_OPERATION, "glSampleMapATI(swizzle)"); return; } else { - curProg->swizzlerq |= (((swizzle & 1) + 1) << (interp * 2)); + curProg->swizzlerq |= (((swizzle & 1) + 1) << (tmp * 2)); } } |