For OpenGL, the front-facing attribute is either 0 (back) or 1 (front) rather 
than +/-1.

I think we'll need to do some additional work (insert a MAD instr?) in the 
Mesa->TGSI translation to account for this difference.  I could dig into that 
someday...

-Brian


________________________________________
From: [email protected] 
[[email protected]] On Behalf Of Micha?? Kr??l 
[[email protected]]
Sent: Monday, November 23, 2009 2:58 AM
To: [email protected]
Subject: Mesa (master): tgsi: Fix POSITION and FACE fragment shader inputs.

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

Author: Michal Krol <[email protected]>
Date:   Mon Nov 23 10:49:41 2009 +0100

tgsi: Fix POSITION and FACE fragment shader inputs.

---

 src/gallium/auxiliary/tgsi/tgsi_exec.c |   77 +++++++++++++++++---------------
 src/gallium/auxiliary/tgsi/tgsi_exec.h |    1 +
 2 files changed, 42 insertions(+), 36 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c 
b/src/gallium/auxiliary/tgsi/tgsi_exec.c
index 36682bb..0197db8 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c
@@ -1832,53 +1832,58 @@ typedef void (* eval_coef_func)(
    unsigned chan );

 static void
-exec_declaration(
-   struct tgsi_exec_machine *mach,
-   const struct tgsi_full_declaration *decl )
+exec_declaration(struct tgsi_exec_machine *mach,
+                 const struct tgsi_full_declaration *decl)
 {
-   if( mach->Processor == TGSI_PROCESSOR_FRAGMENT ) {
-      if( decl->Declaration.File == TGSI_FILE_INPUT ) {
-         unsigned first, last, mask;
-         eval_coef_func eval;
+   if (mach->Processor == TGSI_PROCESSOR_FRAGMENT) {
+      if (decl->Declaration.File == TGSI_FILE_INPUT) {
+         uint first, last, mask;

          first = decl->DeclarationRange.First;
          last = decl->DeclarationRange.Last;
          mask = decl->Declaration.UsageMask;

-         switch( decl->Declaration.Interpolate ) {
-         case TGSI_INTERPOLATE_CONSTANT:
-            eval = eval_constant_coef;
-            break;
-
-         case TGSI_INTERPOLATE_LINEAR:
-            eval = eval_linear_coef;
-            break;
+         if (decl->Semantic.SemanticName == TGSI_SEMANTIC_POSITION) {
+            assert(decl->Semantic.SemanticIndex == 0);
+            assert(first == last);
+            assert(mask = TGSI_WRITEMASK_XYZW);

-         case TGSI_INTERPOLATE_PERSPECTIVE:
-            eval = eval_perspective_coef;
-            break;
+            mach->Inputs[first] = mach->QuadPos;
+         } else if (decl->Semantic.SemanticName == TGSI_SEMANTIC_FACE) {
+            uint i;

-         default:
-            assert( 0 );
-            return;
-         }
+            assert(decl->Semantic.SemanticIndex == 0);
+            assert(first == last);

-         if( mask == TGSI_WRITEMASK_XYZW ) {
-            unsigned i, j;
-
-            for( i = first; i <= last; i++ ) {
-               for( j = 0; j < NUM_CHANNELS; j++ ) {
-                  eval( mach, i, j );
-               }
+            for (i = 0; i < QUAD_SIZE; i++) {
+               mach->Inputs[first].xyzw[0].f[i] = mach->Face;
+            }
+         } else {
+            eval_coef_func eval;
+            uint i, j;
+
+            switch (decl->Declaration.Interpolate) {
+            case TGSI_INTERPOLATE_CONSTANT:
+               eval = eval_constant_coef;
+               break;
+
+            case TGSI_INTERPOLATE_LINEAR:
+               eval = eval_linear_coef;
+               break;
+
+            case TGSI_INTERPOLATE_PERSPECTIVE:
+               eval = eval_perspective_coef;
+               break;
+
+            default:
+               assert(0);
+               return;
             }
-         }
-         else {
-            unsigned i, j;

-            for( j = 0; j < NUM_CHANNELS; j++ ) {
-               if( mask & (1 << j) ) {
-                  for( i = first; i <= last; i++ ) {
-                     eval( mach, i, j );
+            for (j = 0; j < NUM_CHANNELS; j++) {
+               if (mask & (1 << j)) {
+                  for (i = first; i <= last; i++) {
+                     eval(mach, i, j);
                   }
                }
             }
diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.h 
b/src/gallium/auxiliary/tgsi/tgsi_exec.h
index f0aaca9..3dff69a 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.h
@@ -232,6 +232,7 @@ struct tgsi_exec_machine
    /* FRAGMENT processor only. */
    const struct tgsi_interp_coef *InterpCoefs;
    struct tgsi_exec_vector       QuadPos;
+   float                         Face;    /**< +1 if front facing, -1 if back 
facing */

    /* Conditional execution masks */
    uint CondMask;  /**< For IF/ELSE/ENDIF */

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Mesa3d-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to