Mesa (mesa_7_5_branch): swrast: add lod bias when texture sampling

Brian Paul brianp at kemper.freedesktop.org
Wed Sep 23 19:37:38 UTC 2009


Module: Mesa
Branch: mesa_7_5_branch
Commit: 2acd5de22651a3461c0576107c8e8fab1f01469a
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2acd5de22651a3461c0576107c8e8fab1f01469a

Author: Brian Paul <brianp at vmware.com>
Date:   Wed Sep 23 13:35:03 2009 -0600

swrast: add lod bias when texture sampling

Mostly fixes progs/demos/lodbias when MESA_TEX_PROG=1.  But the LOD still
seems off by -1 or so.
May be an issue with the params passed to _swrast_compute_lambda()

---

 src/mesa/swrast/s_fragprog.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/mesa/swrast/s_fragprog.c b/src/mesa/swrast/s_fragprog.c
index 144f78b..b326acf 100644
--- a/src/mesa/swrast/s_fragprog.c
+++ b/src/mesa/swrast/s_fragprog.c
@@ -89,6 +89,8 @@ fetch_texel_lod( GLcontext *ctx, const GLfloat texcoord[4], GLfloat lambda,
  * Fetch a texel with the given partial derivatives to compute a level
  * of detail in the mipmap.
  * Called via machine->FetchTexelDeriv()
+ * \param lodBias  the lod bias which may be specified by a TXB instruction,
+ *                 otherwise zero.
  */
 static void
 fetch_texel_deriv( GLcontext *ctx, const GLfloat texcoord[4],
@@ -96,7 +98,8 @@ fetch_texel_deriv( GLcontext *ctx, const GLfloat texcoord[4],
                    GLfloat lodBias, GLuint unit, GLfloat color[4] )
 {
    SWcontext *swrast = SWRAST_CONTEXT(ctx);
-   const struct gl_texture_object *texObj = ctx->Texture.Unit[unit]._Current;
+   const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+   const struct gl_texture_object *texObj = texUnit->_Current;
 
    if (texObj) {
       const struct gl_texture_image *texImg =
@@ -111,7 +114,9 @@ fetch_texel_deriv( GLcontext *ctx, const GLfloat texcoord[4],
                                       texdx[3], texdy[3], /* dq/dx, dq/dy */
                                       texW, texH,
                                       texcoord[0], texcoord[1], texcoord[3],
-                                      1.0F / texcoord[3]) + lodBias;
+                                      1.0F / texcoord[3]);
+
+      lambda += lodBias + texUnit->LodBias + texObj->LodBias;
 
       lambda = CLAMP(lambda, texObj->MinLod, texObj->MaxLod);
 




More information about the mesa-commit mailing list