glsl_to_ir: do lower_blend_equation if PIPE_CAP_FBFETCH
[mesa.git] / src / mesa / tnl_dd / t_dd_dmatmp2.h
index dd0286b453b070c92493d0065f9c6a89e41eaadc..96c5b47e5717f575b96bf471eba7e128f98d2100 100644 (file)
@@ -1,9 +1,7 @@
-
 /*
  * Mesa 3-D graphics library
- * Version:  4.0.3
  *
- * Copyright (C) 1999-2002  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
  *
  * Authors:
- *    Keith Whitwell <keith@tungstengraphics.com>
+ *    Keith Whitwell <keithw@vmware.com>
  */
 
 
-/* Template for render stages which build and emit vertices directly
+/**
+ * \file t_dd_dmatmp2.h
+ * Template for render stages which build and emit vertices directly
  * to fixed-size dma buffers.  Useful for rendering strips and other
  * native primitives where clipping and per-vertex tweaks such as
  * those in t_dd_tritmp.h are not required.
@@ -69,7 +70,7 @@ do {                                          \
 /**********************************************************************/
 
 
-static ELT_TYPE *TAG(emit_elts)( GLcontext *ctx, 
+static ELT_TYPE *TAG(emit_elts)( struct gl_context *ctx, 
                            ELT_TYPE *dest,
                            GLuint *elts, GLuint nr )
 {
@@ -88,7 +89,7 @@ static ELT_TYPE *TAG(emit_elts)( GLcontext *ctx,
    return dest;
 }
 
-static ELT_TYPE *TAG(emit_consecutive_elts)( GLcontext *ctx, 
+static ELT_TYPE *TAG(emit_consecutive_elts)( struct gl_context *ctx, 
                                        ELT_TYPE *dest,
                                        GLuint start, GLuint nr )
 {
@@ -113,25 +114,25 @@ static ELT_TYPE *TAG(emit_consecutive_elts)( GLcontext *ctx,
 
 
 
-static void TAG(render_points_verts)( GLcontext *ctx,
+static void TAG(render_points_verts)( struct gl_context *ctx,
                                      GLuint start,
                                      GLuint count,
                                      GLuint flags )
 {
    if (start < count) {
       LOCAL_VARS;
-      if (0) fprintf(stderr, "%s\n", __FUNCTION__);
+      if (0) fprintf(stderr, "%s\n", __func__);
       EMIT_PRIM( ctx, GL_POINTS, HW_POINTS, start, count );
    }
 }
 
-static void TAG(render_lines_verts)( GLcontext *ctx,
+static void TAG(render_lines_verts)( struct gl_context *ctx,
                                     GLuint start,
                                     GLuint count,
                                     GLuint flags )
 {
    LOCAL_VARS;
-   if (0) fprintf(stderr, "%s\n", __FUNCTION__);
+   if (0) fprintf(stderr, "%s\n", __func__);
    count -= (count-start) & 1;
 
    if (start+1 >= count)
@@ -149,13 +150,13 @@ static void TAG(render_lines_verts)( GLcontext *ctx,
 }
 
 
-static void TAG(render_line_strip_verts)( GLcontext *ctx,
+static void TAG(render_line_strip_verts)( struct gl_context *ctx,
                                          GLuint start,
                                          GLuint count,
                                          GLuint flags )
 {
    LOCAL_VARS;
-   if (0) fprintf(stderr, "%s\n", __FUNCTION__);
+   if (0) fprintf(stderr, "%s\n", __func__);
 
    if (start+1 >= count)
       return;
@@ -196,14 +197,14 @@ static void TAG(render_line_strip_verts)( GLcontext *ctx,
 }
 
 
-static void TAG(render_line_loop_verts)( GLcontext *ctx,
+static void TAG(render_line_loop_verts)( struct gl_context *ctx,
                                         GLuint start,
                                         GLuint count,
                                         GLuint flags )
 {
    LOCAL_VARS;
    GLuint j, nr;
-   if (0) fprintf(stderr, "%s\n", __FUNCTION__);
+   if (0) fprintf(stderr, "%s\n", __func__);
 
    if (flags & PRIM_BEGIN) {
       j = start;
@@ -265,6 +266,7 @@ static void TAG(render_line_loop_verts)( GLcontext *ctx,
            if (j + nr < count) {
               ELT_TYPE *dest = ALLOC_ELTS( nr );
               dest = TAG(emit_consecutive_elts)( ctx, dest, j, nr );
+              (void) dest;
               j += nr - 1;
               CLOSE_ELTS();
            }
@@ -272,6 +274,7 @@ static void TAG(render_line_loop_verts)( GLcontext *ctx,
               ELT_TYPE *dest = ALLOC_ELTS( nr + 1 );
               dest = TAG(emit_consecutive_elts)( ctx, dest, j, nr );
               dest = TAG(emit_consecutive_elts)( ctx, dest, start, 1 );
+              (void) dest;
               j += nr;
               CLOSE_ELTS();
            }
@@ -283,13 +286,13 @@ static void TAG(render_line_loop_verts)( GLcontext *ctx,
 }
 
 
-static void TAG(render_triangles_verts)( GLcontext *ctx,
+static void TAG(render_triangles_verts)( struct gl_context *ctx,
                                         GLuint start,
                                         GLuint count,
                                         GLuint flags )
 {
    LOCAL_VARS;
-   if (0) fprintf(stderr, "%s\n", __FUNCTION__);
+   if (0) fprintf(stderr, "%s\n", __func__);
 
    count -= (count-start)%3;
 
@@ -304,13 +307,13 @@ static void TAG(render_triangles_verts)( GLcontext *ctx,
 
 
 
-static void TAG(render_tri_strip_verts)( GLcontext *ctx,
+static void TAG(render_tri_strip_verts)( struct gl_context *ctx,
                                         GLuint start,
                                         GLuint count,
                                         GLuint flags )
 {
    LOCAL_VARS;
-   if (0) fprintf(stderr, "%s\n", __FUNCTION__);
+   if (0) fprintf(stderr, "%s\n", __func__);
 
    if (start + 2 >= count)
       return;
@@ -345,38 +348,17 @@ static void TAG(render_tri_strip_verts)( GLcontext *ctx,
         CLOSE_ELTS();
       }
    }
-   else if (HAVE_TRI_STRIP_1)
-      EMIT_PRIM( ctx, GL_TRIANGLE_STRIP, HW_TRIANGLE_STRIP_1, start, count );
-   else {
-      /* Emit the first triangle with elts, then the rest as a regular strip.
-       * TODO:  Make this unlikely in t_imm_api.c
-       */
-      ELT_TYPE *dest;
-
-      ELT_INIT( GL_TRIANGLES, HW_TRIANGLES );
-      dest = ALLOC_ELTS( 3 );
-      EMIT_ELT( dest, 0, (start+1) );
-      EMIT_ELT( dest, 1, (start+0) );
-      EMIT_ELT( dest, 2, (start+2) );
-      dest += 3;
-      CLOSE_ELTS();
-
-      start++;
-      if (start + 2 >= count)
-        return;
-
-      EMIT_PRIM( ctx, GL_TRIANGLE_STRIP, HW_TRIANGLE_STRIP_0, start, 
-                count );
-   }
+   else
+      EMIT_PRIM( ctx, GL_TRIANGLE_STRIP, HW_TRIANGLE_STRIP_0, start, count );
 }
 
-static void TAG(render_tri_fan_verts)( GLcontext *ctx,
+static void TAG(render_tri_fan_verts)( struct gl_context *ctx,
                                       GLuint start,
                                       GLuint count,
                                       GLuint flags )
 {
    LOCAL_VARS;
-   if (0) fprintf(stderr, "%s\n", __FUNCTION__);
+   if (0) fprintf(stderr, "%s\n", __func__);
 
    if (start+2 >= count) 
       return;
@@ -413,13 +395,13 @@ static void TAG(render_tri_fan_verts)( GLcontext *ctx,
 }
 
 
-static void TAG(render_poly_verts)( GLcontext *ctx,
+static void TAG(render_poly_verts)( struct gl_context *ctx,
                                    GLuint start,
                                    GLuint count,
                                    GLuint flags )
 {
    LOCAL_VARS;
-   if (0) fprintf(stderr, "%s\n", __FUNCTION__);
+   if (0) fprintf(stderr, "%s\n", __func__);
 
    if (start+2 >= count) 
       return;
@@ -427,13 +409,13 @@ static void TAG(render_poly_verts)( GLcontext *ctx,
    EMIT_PRIM( ctx, GL_POLYGON, HW_POLYGON, start, count );
 }
 
-static void TAG(render_quad_strip_verts)( GLcontext *ctx,
+static void TAG(render_quad_strip_verts)( struct gl_context *ctx,
                                          GLuint start,
                                          GLuint count,
                                          GLuint flags )
 {
    LOCAL_VARS;
-   if (0) fprintf(stderr, "%s\n", __FUNCTION__);
+   if (0) fprintf(stderr, "%s\n", __func__);
 
    count -= (count-start) & 1;
 
@@ -443,7 +425,7 @@ static void TAG(render_quad_strip_verts)( GLcontext *ctx,
    if (HAVE_QUAD_STRIPS) {
       EMIT_PRIM( ctx, GL_QUAD_STRIP, HW_QUAD_STRIP, start, count );
    } 
-   else if (ctx->_TriangleCaps & DD_FLATSHADE) {
+   else if (ctx->Light.ShadeModel == GL_FLAT) {
       LOCAL_VARS;
       int dmasz = GET_MAX_HW_ELTS();
       GLuint j, nr;
@@ -478,20 +460,20 @@ static void TAG(render_quad_strip_verts)( GLcontext *ctx,
 }
 
 
-static void TAG(render_quads_verts)( GLcontext *ctx,
+static void TAG(render_quads_verts)( struct gl_context *ctx,
                                     GLuint start,
                                     GLuint count,
                                     GLuint flags )
 {
    LOCAL_VARS;
-   if (0) fprintf(stderr, "%s\n", __FUNCTION__);
+   if (0) fprintf(stderr, "%s\n", __func__);
    count -= (count-start)%4;
 
    if (start+3 >= count) 
       return;
 
    if (HAVE_QUADS) {
-      EMIT_PRIM( ctx, HW_QUADS, GL_QUADS, start, count );
+      EMIT_PRIM( ctx, GL_QUADS, HW_QUADS, start, count );
    } 
    else {
       /* Hardware doesn't have a quad primitive type -- simulate it
@@ -527,7 +509,7 @@ static void TAG(render_quads_verts)( GLcontext *ctx,
    }
 }
 
-static void TAG(render_noop)( GLcontext *ctx,
+static void TAG(render_noop)( struct gl_context *ctx,
                              GLuint start,
                              GLuint count,
                              GLuint flags )
@@ -537,7 +519,7 @@ static void TAG(render_noop)( GLcontext *ctx,
 
 
 
-static render_func TAG(render_tab_verts)[GL_POLYGON+2] =
+static tnl_render_func TAG(render_tab_verts)[GL_POLYGON+2] =
 {
    TAG(render_points_verts),
    TAG(render_lines_verts),
@@ -557,7 +539,7 @@ static render_func TAG(render_tab_verts)[GL_POLYGON+2] =
  *                 Render elts using hardware indexed verts                 *
  ****************************************************************************/
 
-static void TAG(render_points_elts)( GLcontext *ctx,
+static void TAG(render_points_elts)( struct gl_context *ctx,
                                     GLuint start,
                                     GLuint count,
                                     GLuint flags )
@@ -574,13 +556,14 @@ static void TAG(render_points_elts)( GLcontext *ctx,
       nr = MIN2( dmasz, count - j );
       dest = ALLOC_ELTS( nr );
       dest = TAG(emit_elts)( ctx, dest, elts+j, nr );
+      (void) dest;
       CLOSE_ELTS();
    }
 }
 
 
 
-static void TAG(render_lines_elts)( GLcontext *ctx,
+static void TAG(render_lines_elts)( struct gl_context *ctx,
                                    GLuint start,
                                    GLuint count,
                                    GLuint flags )
@@ -610,6 +593,7 @@ static void TAG(render_lines_elts)( GLcontext *ctx,
       nr = MIN2( dmasz, count - j );
       dest = ALLOC_ELTS( nr );
       dest = TAG(emit_elts)( ctx, dest, elts+j, nr );
+      (void) dest;
       CLOSE_ELTS();
    }
 
@@ -618,7 +602,7 @@ static void TAG(render_lines_elts)( GLcontext *ctx,
 }
 
 
-static void TAG(render_line_strip_elts)( GLcontext *ctx,
+static void TAG(render_line_strip_elts)( struct gl_context *ctx,
                                         GLuint start,
                                         GLuint count,
                                         GLuint flags )
@@ -641,12 +625,13 @@ static void TAG(render_line_strip_elts)( GLcontext *ctx,
       nr = MIN2( dmasz, count - j );
       dest = ALLOC_ELTS( nr );
       dest = TAG(emit_elts)( ctx, dest, elts+j, nr );
+      (void) dest;
       CLOSE_ELTS();
    }
 }
 
 
-static void TAG(render_line_loop_elts)( GLcontext *ctx,
+static void TAG(render_line_loop_elts)( struct gl_context *ctx,
                                        GLuint start,
                                        GLuint count,
                                        GLuint flags )
@@ -657,7 +642,7 @@ static void TAG(render_line_loop_elts)( GLcontext *ctx,
    GLuint j, nr;
    ELT_TYPE *dest;
 
-   if (0) fprintf(stderr, "%s\n", __FUNCTION__);
+   if (0) fprintf(stderr, "%s\n", __func__);
 
    if (flags & PRIM_BEGIN)
       j = start;
@@ -691,13 +676,14 @@ static void TAG(render_line_loop_elts)( GLcontext *ctx,
       j += nr - 1;
       if (j + 1 >= count && (flags & PRIM_END)) {
         dest = TAG(emit_elts)( ctx, dest, elts+start, 1 );
+        (void) dest;
       }
       CLOSE_ELTS();
    }
 }
 
 
-static void TAG(render_triangles_elts)( GLcontext *ctx,
+static void TAG(render_triangles_elts)( struct gl_context *ctx,
                                        GLuint start,
                                        GLuint count,
                                        GLuint flags )
@@ -723,13 +709,14 @@ static void TAG(render_triangles_elts)( GLcontext *ctx,
       nr = MIN2( dmasz, count - j );
       dest = ALLOC_ELTS( nr );
       dest = TAG(emit_elts)( ctx, dest, elts+j, nr );
+      (void) dest;
       CLOSE_ELTS();
    }
 }
 
 
 
-static void TAG(render_tri_strip_elts)( GLcontext *ctx,
+static void TAG(render_tri_strip_elts)( struct gl_context *ctx,
                                        GLuint start,
                                        GLuint count,
                                        GLuint flags )
@@ -754,11 +741,12 @@ static void TAG(render_tri_strip_elts)( GLcontext *ctx,
 
       dest = ALLOC_ELTS( nr );
       dest = TAG(emit_elts)( ctx, dest, elts+j, nr );
+      (void) dest;
       CLOSE_ELTS();
    }
 }
 
-static void TAG(render_tri_fan_elts)( GLcontext *ctx,
+static void TAG(render_tri_fan_elts)( struct gl_context *ctx,
                                      GLuint start,
                                      GLuint count,
                                      GLuint flags )
@@ -779,12 +767,13 @@ static void TAG(render_tri_fan_elts)( GLcontext *ctx,
       dest = ALLOC_ELTS( nr );
       dest = TAG(emit_elts)( ctx, dest, elts+start, 1 );
       dest = TAG(emit_elts)( ctx, dest, elts+j, nr - 1 );
+      (void) dest;
       CLOSE_ELTS();
    }
 }
 
 
-static void TAG(render_poly_elts)( GLcontext *ctx,
+static void TAG(render_poly_elts)( struct gl_context *ctx,
                                   GLuint start,
                                   GLuint count,
                                   GLuint flags )
@@ -805,11 +794,12 @@ static void TAG(render_poly_elts)( GLcontext *ctx,
       dest = ALLOC_ELTS( nr );
       dest = TAG(emit_elts)( ctx, dest, elts+start, 1 );
       dest = TAG(emit_elts)( ctx, dest, elts+j, nr - 1 );
+      (void) dest;
       CLOSE_ELTS();
    }
 }
 
-static void TAG(render_quad_strip_elts)( GLcontext *ctx,
+static void TAG(render_quad_strip_elts)( struct gl_context *ctx,
                                         GLuint start,
                                         GLuint count,
                                         GLuint flags )
@@ -831,7 +821,7 @@ static void TAG(render_quad_strip_elts)( GLcontext *ctx,
       dmasz -= dmasz & 1;
       count -= (count-start) & 1;
 
-      if (ctx->_TriangleCaps & DD_FLATSHADE) {
+      if (ctx->Light.ShadeModel == GL_FLAT) {
         ELT_INIT( GL_TRIANGLES, HW_TRIANGLES );
 
         dmasz = dmasz/6*2;
@@ -863,6 +853,7 @@ static void TAG(render_quad_strip_elts)( GLcontext *ctx,
            nr = MIN2( dmasz, count - j );
            dest = ALLOC_ELTS( nr );
            dest = TAG(emit_elts)( ctx, dest, elts+j, nr );
+           (void) dest;
            CLOSE_ELTS();
         }
       }
@@ -870,7 +861,7 @@ static void TAG(render_quad_strip_elts)( GLcontext *ctx,
 }
 
 
-static void TAG(render_quads_elts)( GLcontext *ctx,
+static void TAG(render_quads_elts)( struct gl_context *ctx,
                                    GLuint start,
                                    GLuint count,
                                    GLuint flags )
@@ -919,7 +910,7 @@ static void TAG(render_quads_elts)( GLcontext *ctx,
 
 
 
-static render_func TAG(render_tab_elts)[GL_POLYGON+2] =
+static tnl_render_func TAG(render_tab_elts)[GL_POLYGON+2] =
 {
    TAG(render_points_elts),
    TAG(render_lines_elts),