llvmpipe: fix incorrect front-facing value for fragment shader
authorBrian Paul <brianp@vmware.com>
Tue, 20 Apr 2010 17:43:58 +0000 (11:43 -0600)
committerBrian Paul <brianp@vmware.com>
Tue, 20 Apr 2010 17:44:01 +0000 (11:44 -0600)
The TGSI convention is +1 for front-facing, -1 for back-facing
Fixes glean glsl1 gl_FrontFacing tests.

src/gallium/drivers/llvmpipe/lp_setup_tri.c

index a95053444bfa12391e0019117969510692f2a97e..f8a581657335d525bc0da81be4ceceff06e62c65 100644 (file)
@@ -163,12 +163,17 @@ setup_fragcoord_coef(struct lp_setup_context *setup,
 }
 
 
+/**
+ * Setup the fragment input attribute with the front-facing value.
+ * \param frontface  is the triangle front facing?
+ */
 static void setup_facing_coef( struct lp_setup_context *setup,
                                struct lp_rast_triangle *tri,
                                unsigned slot,
                                boolean frontface )
 {
-   constant_coef( setup, tri, slot, 1.0f - frontface, 0 );
+   /* convert TRUE to 1.0 and FALSE to -1.0 */
+   constant_coef( setup, tri, slot, 2.0f * frontface - 1.0f, 0 );
    constant_coef( setup, tri, slot, 0.0f, 1 ); /* wasted */
    constant_coef( setup, tri, slot, 0.0f, 2 ); /* wasted */
    constant_coef( setup, tri, slot, 0.0f, 3 ); /* wasted */