[Mesa-dev] [PATCH 10/20] i915: Fix t_vb_rendertmp.h's provoking vertex handywork

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


From: Ville Syrjälä <ville.syrjala at linux.intel.com>

t_vb_rendertmp.h reorder the vertices passed to the driver based on
the provoking vertex convention. The last vertex passed is always the
provoking vertex. For us however that's a bit bad since the hardware
itself handles the provoking vertex. Reorder the vertices back to the
original order in the driver to make sure the correct provoking vertex
is used.

This seemed easier than trying to adjust t_vd_rendertmp.h to not
reorder (mainly because swrast would still need the reordering),
or having to mess about with the hardware state depending on the
path we take to render the primitives.

Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
 src/mesa/drivers/dri/i915/intel_tris.c | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i915/intel_tris.c b/src/mesa/drivers/dri/i915/intel_tris.c
index 2b62104..09f0c78 100644
--- a/src/mesa/drivers/dri/i915/intel_tris.c
+++ b/src/mesa/drivers/dri/i915/intel_tris.c
@@ -372,6 +372,17 @@ intel_draw_quad(struct intel_context *intel,
    GLuint *vb = intel_get_prim_space(intel, 6);
    int j;
 
+   /* hardware handles provoking vertex so undo t_vb_rendertmp.h's handywork */
+   if (intel->ctx.Light.ProvokingVertex == GL_FIRST_VERTEX_CONVENTION) {
+      intelVertexPtr _v0;
+
+      _v0 = v0;
+      v0 = v3;
+      v3 = v2;
+      v2 = v1;
+      v1 = _v0;
+   }
+
    COPY_DWORDS(j, vb, vertsize, v0);
    COPY_DWORDS(j, vb, vertsize, v1);
 
@@ -379,7 +390,8 @@ intel_draw_quad(struct intel_context *intel,
     * rasterization.  Otherwise draw as two triangles with provoking
     * vertex in third position as required for flat shading.
     */
-   if (intel->ctx.Light.ShadeModel == GL_FLAT) {
+   if (intel->ctx.Light.ShadeModel == GL_FLAT &&
+       intel->ctx.Light.ProvokingVertex == GL_LAST_VERTEX_CONVENTION) {
       COPY_DWORDS(j, vb, vertsize, v3);
       COPY_DWORDS(j, vb, vertsize, v1);
    }
@@ -400,6 +412,16 @@ intel_draw_triangle(struct intel_context *intel,
    GLuint *vb = intel_get_prim_space(intel, 3);
    int j;
 
+  /* hardware handles provoking vertex so undo t_vb_rendertmp.h's handywork */
+   if (intel->ctx.Light.ProvokingVertex == GL_FIRST_VERTEX_CONVENTION) {
+      intelVertexPtr _v0;
+
+      _v0 = v0;
+      v0 = v2;
+      v2 = v1;
+      v1 = _v0;
+   }
+
    COPY_DWORDS(j, vb, vertsize, v0);
    COPY_DWORDS(j, vb, vertsize, v1);
    COPY_DWORDS(j, vb, vertsize, v2);
@@ -414,6 +436,15 @@ intel_draw_line(struct intel_context *intel,
    GLuint *vb = intel_get_prim_space(intel, 2);
    int j;
 
+   /* hardware handles provoking vertex so undo t_vb_rendertmp.h's handywork */
+   if (intel->ctx.Light.ProvokingVertex == GL_FIRST_VERTEX_CONVENTION) {
+      intelVertexPtr _v0;
+
+      _v0 = v0;
+      v0 = v1;
+      v1 = _v0;
+   }
+
    COPY_DWORDS(j, vb, vertsize, v0);
    COPY_DWORDS(j, vb, vertsize, v1);
 }
-- 
2.0.5



More information about the mesa-dev mailing list