Mesa (master): mesa: fix saturation logic in emit_texenv()

Brian Paul brianp at kemper.freedesktop.org
Mon Aug 31 17:23:23 UTC 2009


Module: Mesa
Branch: master
Commit: 956e6c3978abe918348377cf05e5c92971e50d3f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=956e6c3978abe918348377cf05e5c92971e50d3f

Author: Brian Paul <brianp at vmware.com>
Date:   Mon Aug 31 11:14:16 2009 -0600

mesa: fix saturation logic in emit_texenv()

We need to clamp/saturate after each texenv stage, not just the last one.
Fixes glean texEnv failure for softpipe (and probably other fragment program-
based drivers).

---

 src/mesa/main/texenvprogram.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c
index 3736138..847db5c 100644
--- a/src/mesa/main/texenvprogram.c
+++ b/src/mesa/main/texenvprogram.c
@@ -1113,7 +1113,7 @@ static struct ureg
 emit_texenv(struct texenv_fragment_program *p, GLuint unit)
 {
    struct state_key *key = p->state;
-   GLboolean saturate = (unit < p->last_tex_stage);
+   GLboolean saturate;
    GLuint rgb_shift, alpha_shift;
    struct ureg out, shift;
    struct ureg dest;
@@ -1141,6 +1141,11 @@ emit_texenv(struct texenv_fragment_program *p, GLuint unit)
       break;
    }
    
+   /* If we'll do rgb/alpha shifting don't saturate in emit_combine().
+    * We don't want to clamp twice.
+    */
+   saturate = !(rgb_shift || alpha_shift);
+
    /* If this is the very last calculation, emit direct to output reg:
     */
    if (key->separate_specular ||
@@ -1189,6 +1194,7 @@ emit_texenv(struct texenv_fragment_program *p, GLuint unit)
    /* Deal with the final shift:
     */
    if (alpha_shift || rgb_shift) {
+      saturate = GL_TRUE;  /* always saturate at this point */
       if (rgb_shift == alpha_shift) {
 	 shift = register_scalar_const(p, (GLfloat)(1<<rgb_shift));
       }




More information about the mesa-commit mailing list