OSDN Git Service

i915: Fix t_vb_rendertmp.h's provoking vertex handywork
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Sat, 28 Jun 2014 18:58:47 +0000 (21:58 +0300)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Thu, 16 Jul 2015 13:48:41 +0000 (21:48 +0800)
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@linux.intel.com>
src/mesa/drivers/dri/i915/intel_tris.c

index a555edb..b7feb85 100644 (file)
@@ -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);
 }