From: Ville Syrjälä <ville.syrj...@linux.intel.com>

When drawing quads using triangles we need to be careful to make
the provoking vertices match when flat shading.

Signed-off-by: Ville Syrjälä <ville.syrj...@linux.intel.com>
---
 src/mesa/tnl_dd/t_dd_dmatmp.h | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/mesa/tnl_dd/t_dd_dmatmp.h b/src/mesa/tnl_dd/t_dd_dmatmp.h
index f56b0aa..010369f 100644
--- a/src/mesa/tnl_dd/t_dd_dmatmp.h
+++ b/src/mesa/tnl_dd/t_dd_dmatmp.h
@@ -511,7 +511,9 @@ static void TAG(render_quads_verts)( struct gl_context *ctx,
          currentsz = dmasz;
       }
    }
-   else if (HAVE_TRIANGLES) {
+   else if (HAVE_TRIANGLES &&
+           (ctx->Light.ShadeModel == GL_SMOOTH ||
+            ctx->Light.ProvokingVertex == GL_LAST_VERTEX_CONVENTION_EXT)) {
       /* Hardware doesn't have a quad primitive type -- try to
        * simulate it using triangle primitive.  This is a win for
        * gears, but is it useful in the broader world?
@@ -993,7 +995,9 @@ static void TAG(render_quads_elts)( struct gl_context *ctx,
         FLUSH();
         currentsz = dmasz;
       }
-   } else {
+   } else if (HAVE_TRIANGLES &&
+             (ctx->Light.ShadeModel == GL_SMOOTH ||
+              ctx->Light.ProvokingVertex == GL_LAST_VERTEX_CONVENTION_EXT)) {
       LOCAL_VARS;
       GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts;
       int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
@@ -1131,7 +1135,9 @@ static GLboolean TAG(validate_render)( struct gl_context 
*ctx,
         if (HAVE_QUADS) {
            ok = GL_TRUE;
         } else {
-           ok = HAVE_TRIANGLES; /* flatshading is ok. */
+           ok = (HAVE_TRIANGLES &&
+                 (ctx->Light.ShadeModel == GL_SMOOTH ||
+                  ctx->Light.ProvokingVertex == 
GL_LAST_VERTEX_CONVENTION_EXT));
         }
         break;
       default:
-- 
2.0.5

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to