OSDN Git Service

i915: Use c99 initializers for primitive arrays
[android-x86/external-mesa.git] / src / mesa / drivers / dri / i915 / intel_tris.c
index 94d85ce..f069bef 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);
 }
@@ -670,16 +701,16 @@ do {                                                      \
  ***********************************************************************/
 
 static const GLuint hw_prim[GL_POLYGON + 1] = {
-   PRIM3D_POINTLIST,
-   PRIM3D_LINELIST,
-   PRIM3D_LINELIST,
-   PRIM3D_LINELIST,
-   PRIM3D_TRILIST,
-   PRIM3D_TRILIST,
-   PRIM3D_TRILIST,
-   PRIM3D_TRILIST,
-   PRIM3D_TRILIST,
-   PRIM3D_TRILIST
+   [GL_POINTS] = PRIM3D_POINTLIST,
+   [GL_LINES] = PRIM3D_LINELIST,
+   [GL_LINE_LOOP] = PRIM3D_LINELIST,
+   [GL_LINE_STRIP] = PRIM3D_LINELIST,
+   [GL_TRIANGLES] = PRIM3D_TRILIST,
+   [GL_TRIANGLE_STRIP] = PRIM3D_TRILIST,
+   [GL_TRIANGLE_FAN] = PRIM3D_TRILIST,
+   [GL_QUADS] = PRIM3D_TRILIST,
+   [GL_QUAD_STRIP] = PRIM3D_TRILIST,
+   [GL_POLYGON] = PRIM3D_TRILIST,
 };
 
 #define RASTERIZE(x) intelRasterPrimitive( ctx, x, hw_prim[x] )
@@ -891,18 +922,11 @@ intelRenderClippedPoly(struct gl_context * ctx, const GLuint * elts, GLuint n)
 {
    struct intel_context *intel = intel_context(ctx);
    TNLcontext *tnl = TNL_CONTEXT(ctx);
-   struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
    GLuint prim = intel->render_primitive;
 
    /* Render the new vertices as an unclipped polygon.
     */
-   {
-      GLuint *tmp = VB->Elts;
-      VB->Elts = (GLuint *) elts;
-      tnl->Driver.Render.PrimTabElts[GL_POLYGON] (ctx, 0, n,
-                                                  PRIM_BEGIN | PRIM_END);
-      VB->Elts = tmp;
-   }
+   _tnl_RenderClippedPolygon(ctx, elts, n);
 
    /* Restore the render primitive
     */
@@ -911,14 +935,6 @@ intelRenderClippedPoly(struct gl_context * ctx, const GLuint * elts, GLuint n)
 }
 
 static void
-intelRenderClippedLine(struct gl_context * ctx, GLuint ii, GLuint jj)
-{
-   TNLcontext *tnl = TNL_CONTEXT(ctx);
-
-   tnl->Driver.Render.Line(ctx, ii, jj);
-}
-
-static void
 intelFastRenderClippedPoly(struct gl_context * ctx, const GLuint * elts, GLuint n)
 {
    struct intel_context *intel = intel_context(ctx);
@@ -928,10 +944,18 @@ intelFastRenderClippedPoly(struct gl_context * ctx, const GLuint * elts, GLuint
    const GLuint *start = (const GLuint *) V(elts[0]);
    int i, j;
 
-   for (i = 2; i < n; i++) {
-      COPY_DWORDS(j, vb, vertsize, V(elts[i - 1]));
-      COPY_DWORDS(j, vb, vertsize, V(elts[i]));
-      COPY_DWORDS(j, vb, vertsize, start);
+   if (ctx->Light.ProvokingVertex == GL_LAST_VERTEX_CONVENTION) {
+      for (i = 2; i < n; i++) {
+         COPY_DWORDS(j, vb, vertsize, V(elts[i - 1]));
+         COPY_DWORDS(j, vb, vertsize, V(elts[i]));
+         COPY_DWORDS(j, vb, vertsize, start);
+      }
+   } else {
+      for (i = 2; i < n; i++) {
+         COPY_DWORDS(j, vb, vertsize, start);
+         COPY_DWORDS(j, vb, vertsize, V(elts[i - 1]));
+         COPY_DWORDS(j, vb, vertsize, V(elts[i]));
+      }
    }
 }
 
@@ -1036,23 +1060,23 @@ intelChooseRenderState(struct gl_context * ctx)
       else {
          tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
          tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
-         tnl->Driver.Render.ClippedLine = intelRenderClippedLine;
+         tnl->Driver.Render.ClippedLine = _tnl_RenderClippedLine;
          tnl->Driver.Render.ClippedPolygon = intelRenderClippedPoly;
       }
    }
 }
 
 static const GLenum reduced_prim[GL_POLYGON + 1] = {
-   GL_POINTS,
-   GL_LINES,
-   GL_LINES,
-   GL_LINES,
-   GL_TRIANGLES,
-   GL_TRIANGLES,
-   GL_TRIANGLES,
-   GL_TRIANGLES,
-   GL_TRIANGLES,
-   GL_TRIANGLES
+   [GL_POINTS] = GL_POINTS,
+   [GL_LINES] = GL_LINES,
+   [GL_LINE_LOOP] = GL_LINES,
+   [GL_LINE_STRIP] = GL_LINES,
+   [GL_TRIANGLES] = GL_TRIANGLES,
+   [GL_TRIANGLE_STRIP] = GL_TRIANGLES,
+   [GL_TRIANGLE_FAN] = GL_TRIANGLES,
+   [GL_QUADS] = GL_TRIANGLES,
+   [GL_QUAD_STRIP] = GL_TRIANGLES,
+   [GL_POLYGON] = GL_TRIANGLES
 };