summaryrefslogtreecommitdiff
path: root/src/mesa/swrast/s_nvfragprog.c
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2004-04-18 20:11:52 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2004-04-18 20:11:52 +0000
commitd8b82147c3cb17a06bf41e97141b8427b4580459 (patch)
tree6d8363f5d5fba37f1c128f21f2003778cbad986e /src/mesa/swrast/s_nvfragprog.c
parentc83d09e3b09b0b7a48eb0e025c220e95453c2033 (diff)
Audit/fixes for NV/ARB TEX, TXP, TXB, TXD instructions.
Some texture instructions were using wrong LOD. Fixed interpolate_texcoords() so it doesn't do texcoord projective division when using a fragment program. The TXP instruction does that.
Diffstat (limited to 'src/mesa/swrast/s_nvfragprog.c')
-rw-r--r--src/mesa/swrast/s_nvfragprog.c37
1 files changed, 27 insertions, 10 deletions
diff --git a/src/mesa/swrast/s_nvfragprog.c b/src/mesa/swrast/s_nvfragprog.c
index f7510bf3dd..6529022fe9 100644
--- a/src/mesa/swrast/s_nvfragprog.c
+++ b/src/mesa/swrast/s_nvfragprog.c
@@ -1140,19 +1140,19 @@ execute_program( GLcontext *ctx,
store_vector4( inst, machine, result );
}
break;
- case FP_OPCODE_TEX:
+ case FP_OPCODE_TEX: /* Both ARB and NV frag prog */
/* Texel lookup */
{
GLfloat texcoord[4], color[4];
fetch_vector4( ctx, &inst->SrcReg[0], machine, program, texcoord );
- /* XXX: Undo perspective divide from interpolate_texcoords() */
- fetch_texel( ctx, texcoord,
- span->array->lambda[inst->TexSrcUnit][column],
- inst->TexSrcUnit, color );
+ /* Note: we pass 0 for LOD. The ARB extension requires it
+ * while the NV extension says it's implementation dependant.
+ */
+ fetch_texel( ctx, texcoord, 0.0F, inst->TexSrcUnit, color );
store_vector4( inst, machine, color );
}
break;
- case FP_OPCODE_TXB:
+ case FP_OPCODE_TXB: /* GL_ARB_fragment_program only */
/* Texel lookup with LOD bias */
{
GLfloat texcoord[4], color[4], bias, lambda;
@@ -1168,7 +1168,7 @@ execute_program( GLcontext *ctx,
store_vector4( inst, machine, color );
}
break;
- case FP_OPCODE_TXD:
+ case FP_OPCODE_TXD: /* GL_NV_fragment_program only */
/* Texture lookup w/ partial derivatives for LOD */
{
GLfloat texcoord[4], dtdx[4], dtdy[4], color[4];
@@ -1180,12 +1180,29 @@ execute_program( GLcontext *ctx,
store_vector4( inst, machine, color );
}
break;
- case FP_OPCODE_TXP:
- /* Texture lookup w/ perspective divide */
+ case FP_OPCODE_TXP: /* GL_ARB_fragment_program only */
+ /* Texture lookup w/ projective divide */
+ {
+ GLfloat texcoord[4], color[4];
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, texcoord );
+ texcoord[0] /= texcoord[3];
+ texcoord[1] /= texcoord[3];
+ texcoord[2] /= texcoord[3];
+ /* Note: LOD=0 */
+ fetch_texel( ctx, texcoord, 0.0F, inst->TexSrcUnit, color );
+ store_vector4( inst, machine, color );
+ }
+ break;
+ case FP_OPCODE_TXP_NV: /* GL_NV_fragment_program only */
+ /* Texture lookup w/ projective divide */
{
GLfloat texcoord[4], color[4];
fetch_vector4( ctx, &inst->SrcReg[0], machine, program, texcoord );
- /* Already did perspective divide in interpolate_texcoords() */
+ if (inst->TexSrcBit != TEXTURE_CUBE_BIT) {
+ texcoord[0] /= texcoord[3];
+ texcoord[1] /= texcoord[3];
+ texcoord[2] /= texcoord[3];
+ }
fetch_texel( ctx, texcoord,
span->array->lambda[inst->TexSrcUnit][column],
inst->TexSrcUnit, color );