[Mesa-dev] [PATCH 04/20] t_dd_dmatmp: Check provoking vertex convention when rendering quads

ville.syrjala at linux.intel.com ville.syrjala at linux.intel.com
Mon Mar 23 05:47:20 PDT 2015


From: Ville Syrjälä <ville.syrjala at 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.syrjala at 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



More information about the mesa-dev mailing list