Mesa (master): softpipe: fix computation of fragment[FACE] attribute

Brian Paul brianp at kemper.freedesktop.org
Sun Apr 18 16:02:31 UTC 2010


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

Author: Brian Paul <brianp at vmware.com>
Date:   Sun Apr 18 09:46:25 2010 -0600

softpipe: fix computation of fragment[FACE] attribute

In TGSI, front facing is +1 and back-facing is -1.  We were computing
this attribute as +1 and 0 before.  However, the value isn't actually
used anywhere because we machine->Face attribute overrides it in
tgsi_exec.c.  That could be changed, removing some special-case code...

---

 src/gallium/drivers/softpipe/sp_setup.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/softpipe/sp_setup.c b/src/gallium/drivers/softpipe/sp_setup.c
index 61be55c..7e2b580 100644
--- a/src/gallium/drivers/softpipe/sp_setup.c
+++ b/src/gallium/drivers/softpipe/sp_setup.c
@@ -387,6 +387,7 @@ setup_sort_vertices(struct setup_context *setup,
    /* We need to know if this is a front or back-facing triangle for:
     *  - the GLSL gl_FrontFacing fragment attribute (bool)
     *  - two-sided stencil test
+    * 0 = front-facing, 1 = back-facing
     */
    setup->facing = 
       ((det > 0.0) ^ 
@@ -664,7 +665,8 @@ setup_tri_coefficients(struct setup_context *setup)
       }
 
       if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FACE) {
-         setup->coef[fragSlot].a0[0] = 1.0f - setup->facing;
+         /* convert 0 to 1.0 and 1 to -1.0 */
+         setup->coef[fragSlot].a0[0] = setup->facing * -2.0f + 1.0f;
          setup->coef[fragSlot].dadx[0] = 0.0;
          setup->coef[fragSlot].dady[0] = 0.0;
       }
@@ -1019,7 +1021,8 @@ setup_line_coefficients(struct setup_context *setup,
       }
 
       if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FACE) {
-         setup->coef[fragSlot].a0[0] = 1.0f - setup->facing;
+         /* convert 0 to 1.0 and 1 to -1.0 */
+         setup->coef[fragSlot].a0[0] = setup->facing * -2.0f + 1.0f;
          setup->coef[fragSlot].dadx[0] = 0.0;
          setup->coef[fragSlot].dady[0] = 0.0;
       }
@@ -1265,7 +1268,8 @@ sp_setup_point(struct setup_context *setup,
       }
 
       if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FACE) {
-         setup->coef[fragSlot].a0[0] = 1.0f - setup->facing;
+         /* convert 0 to 1.0 and 1 to -1.0 */
+         setup->coef[fragSlot].a0[0] = setup->facing * -2.0f + 1.0f;
          setup->coef[fragSlot].dadx[0] = 0.0;
          setup->coef[fragSlot].dady[0] = 0.0;
       }




More information about the mesa-commit mailing list