summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2005-05-11 16:28:33 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2005-05-11 16:28:33 +0000
commitac6728d2d9208c4e8147b1ebfde50efdf37a8428 (patch)
treef80f62c794ee83d73f807be6da48ac75c6902039 /src
parent49d8cbe8d110e5c0a23300b5b82d110286bc3609 (diff)
Previously in TXP and TEX instructions, lambda was passed to
fetch_texel as zero, but I believe this is incorrect. The spec uses a pseudocode function: vec4 TextureSample(float s, float t, float r, float lodBias, int texImageUnit, enum texTarget); to specify the behaviour of TEX, TXB and TXP instructions. For TEX and TXP, lodBias is passed as zero, TXB is passed with texcoord[4]. In our code we have static void fetch_texel( GLcontext *ctx, const GLfloat texcoord[4], GLfloat lambda, GLuint unit, GLfloat color[4] ) and were passing zero and a biased lambda value respectively. The difference is that TextureSample() would add in the lambda term itself, while in our code the caller is expected to do this. Thus in the TEX and TXP cases, it is necessary to pass an unbiased lambda value for things to work out correctly.
Diffstat (limited to 'src')
-rw-r--r--src/mesa/swrast/s_nvfragprog.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/mesa/swrast/s_nvfragprog.c b/src/mesa/swrast/s_nvfragprog.c
index bb9c986afc..88fe9899d8 100644
--- a/src/mesa/swrast/s_nvfragprog.c
+++ b/src/mesa/swrast/s_nvfragprog.c
@@ -1179,7 +1179,19 @@ execute_program( GLcontext *ctx,
/* 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 );
+ /* KW: Previously lambda was passed as zero, but I
+ * believe this is incorrect, the spec seems to
+ * indicate rather that lambda should not be
+ * changed/biased, unlike TXB where texcoord[3] is
+ * added to the lambda calculations. The lambda should
+ * still be calculated normally for TEX & TXP though,
+ * not set to zero. Otherwise it's very difficult to
+ * implement normal GL semantics through the fragment
+ * shader.
+ */
+ fetch_texel( ctx, texcoord,
+ span->array->lambda[inst->TexSrcUnit][column],
+ inst->TexSrcUnit, color );
if (color[3])
printf("color[3] = %f\n", color[3]);
store_vector4( inst, machine, color );
@@ -1227,8 +1239,17 @@ execute_program( GLcontext *ctx,
texcoord[1] /= texcoord[3];
texcoord[2] /= texcoord[3];
}
- /* Note: LOD=0 */
- fetch_texel( ctx, texcoord, 0.0F, inst->TexSrcUnit, color );
+ /* KW: Previously lambda was passed as zero, but I
+ * believe this is incorrect, the spec seems to
+ * indicate rather that lambda should not be
+ * changed/biased, unlike TXB where texcoord[3] is
+ * added to the lambda calculations. The lambda should
+ * still be calculated normally for TEX & TXP though,
+ * not set to zero.
+ */
+ fetch_texel( ctx, texcoord,
+ span->array->lambda[inst->TexSrcUnit][column],
+ inst->TexSrcUnit, color );
store_vector4( inst, machine, color );
}
break;