mesa: add bool param to _mesa_free_context_data
[mesa.git] / src / mesa / drivers / dri / radeon / radeon_swtcl.c
index e61f59eaeaf89146c8fa13939a023e7079d01326..f1e55e0b68e10633cc48ae97c60f89911c63d085 100644 (file)
@@ -29,19 +29,19 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 /*
  * Authors:
- *   Keith Whitwell <keith@tungstengraphics.com>
+ *   Keith Whitwell <keithw@vmware.com>
  */
 
 #include "main/glheader.h"
 #include "main/mtypes.h"
-#include "main/colormac.h"
 #include "main/enums.h"
-#include "main/imports.h"
 #include "main/macros.h"
-#include "main/simple_list.h"
+#include "main/state.h"
+
+#include "math/m_xform.h"
 
 #include "swrast_setup/swrast_setup.h"
-#include "math/m_translate.h"
+
 #include "tnl/tnl.h"
 #include "tnl/t_context.h"
 #include "tnl/t_pipeline.h"
@@ -59,7 +59,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define RADEON_MAX_TNL_VERTEX_SIZE (15 * sizeof(GLfloat))      /* for mesa _tnl stage */
 
 /***********************************************************************
- *                         Initialization 
+ *                         Initialization
  ***********************************************************************/
 
 #define EMIT_ATTR( ATTR, STYLE, F0 )                                   \
@@ -85,17 +85,15 @@ static GLuint radeon_cp_vc_frmts[3][2] =
    { RADEON_CP_VC_FRMT_ST2, RADEON_CP_VC_FRMT_ST2 | RADEON_CP_VC_FRMT_Q2 },
 };
 
-static void radeonSetVertexFormat( GLcontext *ctx )
+static void radeonSetVertexFormat( struct gl_context *ctx )
 {
    r100ContextPtr rmesa = R100_CONTEXT( ctx );
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    struct vertex_buffer *VB = &tnl->vb;
-   DECLARE_RENDERINPUTS(index_bitset);
+   GLbitfield64 index_bitset = tnl->render_inputs_bitset;
    int fmt_0 = 0;
    int offset = 0;
 
-   RENDERINPUTS_COPY( index_bitset, tnl->render_inputs_bitset );
-
    /* Important:
     */
    if ( VB->NdcPtr != NULL ) {
@@ -112,20 +110,21 @@ static void radeonSetVertexFormat( GLcontext *ctx )
     * build up a hardware vertex.
     */
    if ( !rmesa->swtcl.needproj ||
-        RENDERINPUTS_TEST_RANGE( index_bitset, _TNL_FIRST_TEX, _TNL_LAST_TEX )) {      /* for projtex */
-      EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F, 
+        (index_bitset & BITFIELD64_RANGE(_TNL_ATTRIB_TEX0, _TNL_NUM_TEX))) {
+      /* for projtex */
+      EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F,
                 RADEON_CP_VC_FRMT_XY | RADEON_CP_VC_FRMT_Z | RADEON_CP_VC_FRMT_W0 );
       offset = 4;
    }
    else {
-      EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_3F, 
+      EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_3F,
                 RADEON_CP_VC_FRMT_XY | RADEON_CP_VC_FRMT_Z );
       offset = 3;
    }
 
    rmesa->swtcl.coloroffset = offset;
-#if MESA_LITTLE_ENDIAN 
-   EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_RGBA, 
+#if MESA_LITTLE_ENDIAN
+   EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_RGBA,
              RADEON_CP_VC_FRMT_PKCOLOR );
 #else
    EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_ABGR,
@@ -134,11 +133,11 @@ static void radeonSetVertexFormat( GLcontext *ctx )
    offset += 1;
 
    rmesa->swtcl.specoffset = 0;
-   if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 ) ||
-       RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG )) {
+   if (index_bitset &
+       (BITFIELD64_BIT(_TNL_ATTRIB_COLOR1) | BITFIELD64_BIT(_TNL_ATTRIB_FOG))) {
 
-#if MESA_LITTLE_ENDIAN 
-      if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 )) {
+#if MESA_LITTLE_ENDIAN
+      if (index_bitset & BITFIELD64_BIT(_TNL_ATTRIB_COLOR1)) {
         rmesa->swtcl.specoffset = offset;
         EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_RGB,
                    RADEON_CP_VC_FRMT_PKSPEC );
@@ -147,7 +146,7 @@ static void radeonSetVertexFormat( GLcontext *ctx )
         EMIT_PAD( 3 );
       }
 
-      if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG )) {
+      if (index_bitset & BITFIELD64_BIT(_TNL_ATTRIB_FOG)) {
         EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F,
                    RADEON_CP_VC_FRMT_PKSPEC );
       }
@@ -155,7 +154,7 @@ static void radeonSetVertexFormat( GLcontext *ctx )
         EMIT_PAD( 1 );
       }
 #else
-      if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG )) {
+      if (index_bitset & BITFIELD64_BIT(_TNL_ATTRIB_FOG)) {
         EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F,
                    RADEON_CP_VC_FRMT_PKSPEC );
       }
@@ -163,7 +162,7 @@ static void radeonSetVertexFormat( GLcontext *ctx )
         EMIT_PAD( 1 );
       }
 
-      if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 )) {
+      if (index_bitset & BITFIELD64_BIT(_TNL_ATTRIB_COLOR1)) {
         rmesa->swtcl.specoffset = offset;
         EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR,
                    RADEON_CP_VC_FRMT_PKSPEC );
@@ -174,12 +173,12 @@ static void radeonSetVertexFormat( GLcontext *ctx )
 #endif
    }
 
-   if (RENDERINPUTS_TEST_RANGE( index_bitset, _TNL_FIRST_TEX, _TNL_LAST_TEX )) {
+   if (index_bitset & BITFIELD64_RANGE(_TNL_ATTRIB_TEX0, _TNL_NUM_TEX)) {
       int i;
 
       for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
-        if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX(i) )) {
-           GLuint sz = VB->TexCoordPtr[i]->size;
+        if (index_bitset & BITFIELD64_BIT(_TNL_ATTRIB_TEX(i))) {
+           GLuint sz = VB->AttribPtr[_TNL_ATTRIB_TEX0 + i]->size;
 
            switch (sz) {
            case 1:
@@ -188,8 +187,18 @@ static void radeonSetVertexFormat( GLcontext *ctx )
                          radeon_cp_vc_frmts[i][0] );
               break;
            case 3:
+              if (ctx->Texture.Unit[i]._Current &&
+                   ctx->Texture.Unit[i]._Current->Target == GL_TEXTURE_CUBE_MAP) {
+                  EMIT_ATTR( _TNL_ATTRIB_TEX0+i, EMIT_3F,
+                             radeon_cp_vc_frmts[i][1] );
+               } else {
+                  EMIT_ATTR( _TNL_ATTRIB_TEX0+i, EMIT_2F,
+                             radeon_cp_vc_frmts[i][0] );
+               }
+               break;
            case 4:
-              if (ctx->Texture.Unit[i]._ReallyEnabled & (TEXTURE_CUBE_BIT) ) {
+              if (ctx->Texture.Unit[i]._Current &&
+                   ctx->Texture.Unit[i]._Current->Target == GL_TEXTURE_CUBE_MAP) {
                  EMIT_ATTR( _TNL_ATTRIB_TEX0+i, EMIT_3F,
                             radeon_cp_vc_frmts[i][1] );
               } else {
@@ -199,24 +208,24 @@ static void radeonSetVertexFormat( GLcontext *ctx )
               break;
            default:
               continue;
-           };
+           }
         }
       }
    }
 
-   if (!RENDERINPUTS_EQUAL( rmesa->radeon.tnl_index_bitset, index_bitset ) ||
-       fmt_0 != rmesa->swtcl.vertex_format) {
+   if (rmesa->radeon.tnl_index_bitset != index_bitset ||
+       fmt_0 != rmesa->swtcl.vertex_format) {
       RADEON_NEWPRIM(rmesa);
       rmesa->swtcl.vertex_format = fmt_0;
       rmesa->radeon.swtcl.vertex_size =
          _tnl_install_attrs( ctx,
-                             rmesa->radeon.swtcl.vertex_attrs, 
+                             rmesa->radeon.swtcl.vertex_attrs,
                              rmesa->radeon.swtcl.vertex_attr_count,
                              NULL, 0 );
       rmesa->radeon.swtcl.vertex_size /= 4;
-      RENDERINPUTS_COPY( rmesa->radeon.tnl_index_bitset, index_bitset );
+      rmesa->radeon.tnl_index_bitset = index_bitset;
       radeon_print(RADEON_SWRENDER, RADEON_VERBOSE,
-         "%s: vertex_size= %d floats\n",  __FUNCTION__, rmesa->radeon.swtcl.vertex_size);
+         "%s: vertex_size= %d floats\n",  __func__, rmesa->radeon.swtcl.vertex_size);
    }
 }
 
@@ -232,7 +241,7 @@ static void radeon_predict_emit_size( r100ContextPtr rmesa )
         if (rcommonEnsureCmdBufSpace(&rmesa->radeon,
                     state_size +
                     (scissor_size + prims_size + vertex_size),
-                    __FUNCTION__))
+                    __func__))
             rmesa->radeon.swtcl.emit_prediction = radeonCountStateEmitSize( &rmesa->radeon );
         else
             rmesa->radeon.swtcl.emit_prediction = state_size;
@@ -241,7 +250,7 @@ static void radeon_predict_emit_size( r100ContextPtr rmesa )
     }
 }
 
-static void radeonRenderStart( GLcontext *ctx )
+static void radeonRenderStart( struct gl_context *ctx )
 {
     r100ContextPtr rmesa = R100_CONTEXT( ctx );
 
@@ -258,13 +267,16 @@ static void radeonRenderStart( GLcontext *ctx )
  * determine in advance whether or not the hardware can / should do the
  * projection divide or Mesa should do it.
  */
-void radeonChooseVertexState( GLcontext *ctx )
+void radeonChooseVertexState( struct gl_context *ctx )
 {
    r100ContextPtr rmesa = R100_CONTEXT( ctx );
    TNLcontext *tnl = TNL_CONTEXT(ctx);
 
    GLuint se_coord_fmt = rmesa->hw.set.cmd[SET_SE_COORDFMT];
-   
+   GLboolean unfilled = (ctx->Polygon.FrontMode != GL_FILL ||
+                         ctx->Polygon.BackMode != GL_FILL);
+   GLboolean twosided = ctx->Light.Enabled && ctx->Light.Model.TwoSide;
+
    se_coord_fmt &= ~(RADEON_VTX_XY_PRE_MULT_1_OVER_W0 |
                     RADEON_VTX_Z_PRE_MULT_1_OVER_W0 |
                     RADEON_VTX_W0_IS_NOT_1_OVER_W0);
@@ -280,9 +292,11 @@ void radeonChooseVertexState( GLcontext *ctx )
     * bigger one.
     */
 
-   if ((!RENDERINPUTS_TEST_RANGE( tnl->render_inputs_bitset, _TNL_FIRST_TEX, _TNL_LAST_TEX ) &&
-       !RENDERINPUTS_TEST( tnl->render_inputs_bitset, _TNL_ATTRIB_COLOR1 ))
-       || (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
+   if ((0 == (tnl->render_inputs_bitset &
+        (BITFIELD64_RANGE(_TNL_ATTRIB_TEX0, _TNL_NUM_TEX)
+         | BITFIELD64_BIT(_TNL_ATTRIB_COLOR1))))
+       || twosided
+       || unfilled) {
       rmesa->swtcl.needproj = GL_TRUE;
       se_coord_fmt |= (RADEON_VTX_XY_PRE_MULT_1_OVER_W0 |
                      RADEON_VTX_Z_PRE_MULT_1_OVER_W0);
@@ -300,7 +314,7 @@ void radeonChooseVertexState( GLcontext *ctx )
    }
 }
 
-void r100_swtcl_flush(GLcontext *ctx, uint32_t current_offset)
+void r100_swtcl_flush(struct gl_context *ctx, uint32_t current_offset)
 {
    r100ContextPtr rmesa = R100_CONTEXT(ctx);
 
@@ -309,10 +323,10 @@ void r100_swtcl_flush(GLcontext *ctx, uint32_t current_offset)
    radeonEmitState(&rmesa->radeon);
    radeonEmitVertexAOS( rmesa,
                        rmesa->radeon.swtcl.vertex_size,
-                       first_elem(&rmesa->radeon.dma.reserved)->bo,
+                       rmesa->radeon.swtcl.bo,
                        current_offset);
 
-                     
+
    radeonEmitVbufPrim( rmesa,
                       rmesa->swtcl.vertex_format,
                       rmesa->radeon.swtcl.hw_primitive,
@@ -337,28 +351,25 @@ void r100_swtcl_flush(GLcontext *ctx, uint32_t current_offset)
 #define HAVE_LINE_STRIPS 1
 #define HAVE_TRIANGLES   1
 #define HAVE_TRI_STRIPS  1
-#define HAVE_TRI_STRIP_1 0
 #define HAVE_TRI_FANS    1
-#define HAVE_QUADS       0
-#define HAVE_QUAD_STRIPS 0
 #define HAVE_POLYGONS    0
 /* \todo: is it possible to make "ELTS" work with t_vertex code ? */
 #define HAVE_ELTS        0
 
 static const GLuint hw_prim[GL_POLYGON+1] = {
-   RADEON_CP_VC_CNTL_PRIM_TYPE_POINT,
-   RADEON_CP_VC_CNTL_PRIM_TYPE_LINE,
-   0,
-   RADEON_CP_VC_CNTL_PRIM_TYPE_LINE_STRIP,
-   RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_LIST,
-   RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_STRIP,
-   RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_FAN,
-   0,
-   0,
-   0
+   [GL_POINTS] = RADEON_CP_VC_CNTL_PRIM_TYPE_POINT,
+   [GL_LINES] = RADEON_CP_VC_CNTL_PRIM_TYPE_LINE,
+   [GL_LINE_LOOP] = 0,
+   [GL_LINE_STRIP] = RADEON_CP_VC_CNTL_PRIM_TYPE_LINE_STRIP,
+   [GL_TRIANGLES] = RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_LIST,
+   [GL_TRIANGLE_STRIP] = RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_STRIP,
+   [GL_TRIANGLE_FAN] = RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_FAN,
+   [GL_QUADS] = 0,
+   [GL_QUAD_STRIP] = 0,
+   [GL_POLYGON] = 0
 };
 
-static INLINE void
+static inline void
 radeonDmaPrimitive( r100ContextPtr rmesa, GLenum prim )
 {
    RADEON_NEWPRIM( rmesa );
@@ -396,18 +407,22 @@ static void* radeon_alloc_verts( r100ContextPtr rmesa , GLuint nr, GLuint size )
 /**********************************************************************/
 
 
-static GLboolean radeon_run_render( GLcontext *ctx,
+static GLboolean radeon_run_render( struct gl_context *ctx,
                                    struct tnl_pipeline_stage *stage )
 {
    r100ContextPtr rmesa = R100_CONTEXT(ctx);
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    struct vertex_buffer *VB = &tnl->vb;
-   tnl_render_func *tab = TAG(render_tab_verts);
+   const tnl_render_func *tab = TAG(render_tab_verts);
    GLuint i;
 
-   if (rmesa->radeon.swtcl.RenderIndex != 0 ||   
+   if (rmesa->radeon.swtcl.RenderIndex != 0 ||
        !radeon_dma_validate_render( ctx, VB ))
-      return GL_TRUE;          
+      return GL_TRUE;
+
+   radeon_prepare_render(&rmesa->radeon);
+   if (rmesa->radeon.NewGLState)
+      radeonValidateState( ctx );
 
    tnl->Driver.Render.Start( ctx );
 
@@ -422,11 +437,11 @@ static GLboolean radeon_run_render( GLcontext *ctx,
 
       radeon_print(RADEON_SWRENDER, RADEON_NORMAL,
          "radeon_render.c: prim %s %d..%d\n",
-                _mesa_lookup_enum_by_nr(prim & PRIM_MODE_MASK), 
+                _mesa_enum_to_string(prim & PRIM_MODE_MASK),
                 start, start+length);
 
       if (length)
-        tab[prim & PRIM_MODE_MASK]( ctx, start, start + length, prim );
+         tab[prim & PRIM_MODE_MASK](ctx, start, length, prim);
    }
 
    tnl->Driver.Render.Finish( ctx );
@@ -451,21 +466,21 @@ const struct tnl_pipeline_stage _radeon_render_stage =
 
 
 static const GLuint reduced_hw_prim[GL_POLYGON+1] = {
-   RADEON_CP_VC_CNTL_PRIM_TYPE_POINT,
-   RADEON_CP_VC_CNTL_PRIM_TYPE_LINE,
-   RADEON_CP_VC_CNTL_PRIM_TYPE_LINE,
-   RADEON_CP_VC_CNTL_PRIM_TYPE_LINE,
-   RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_LIST,
-   RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_LIST,
-   RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_LIST,
-   RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_LIST,
-   RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_LIST,
-   RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_LIST
+   [GL_POINTS] = RADEON_CP_VC_CNTL_PRIM_TYPE_POINT,
+   [GL_LINES] = RADEON_CP_VC_CNTL_PRIM_TYPE_LINE,
+   [GL_LINE_LOOP] = RADEON_CP_VC_CNTL_PRIM_TYPE_LINE,
+   [GL_LINE_STRIP] = RADEON_CP_VC_CNTL_PRIM_TYPE_LINE,
+   [GL_TRIANGLES] = RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_LIST,
+   [GL_TRIANGLE_STRIP] = RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_LIST,
+   [GL_TRIANGLE_FAN] = RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_LIST,
+   [GL_QUADS] = RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_LIST,
+   [GL_QUAD_STRIP] = RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_LIST,
+   [GL_POLYGON] = RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_LIST
 };
 
-static void radeonRasterPrimitive( GLcontext *ctx, GLuint hwprim );
-static void radeonRenderPrimitive( GLcontext *ctx, GLenum prim );
-static void radeonResetLineStipple( GLcontext *ctx );
+static void radeonRasterPrimitive( struct gl_context *ctx, GLuint hwprim );
+static void radeonRenderPrimitive( struct gl_context *ctx, GLenum prim );
+static void radeonResetLineStipple( struct gl_context *ctx );
 
 
 /***********************************************************************
@@ -482,7 +497,7 @@ static void radeonResetLineStipple( GLcontext *ctx );
    r100ContextPtr rmesa = R100_CONTEXT(ctx);           \
    const char *radeonverts = (char *)rmesa->radeon.swtcl.verts;
 #define VERT(x) (radeonVertex *)(radeonverts + ((x) * (vertsize) * sizeof(int)))
-#define VERTEX radeonVertex 
+#define VERTEX radeonVertex
 #undef TAG
 #define TAG(x) radeon_##x
 #include "tnl_dd/t_dd_triemit.h"
@@ -516,8 +531,8 @@ static struct {
 
 #define DO_FALLBACK  0
 #define DO_OFFSET    0
-#define DO_UNFILLED (IND & RADEON_UNFILLED_BIT)
-#define DO_TWOSIDE  (IND & RADEON_TWOSIDE_BIT)
+#define DO_UNFILLED ((IND & RADEON_UNFILLED_BIT) != 0)
+#define DO_TWOSIDE  ((IND & RADEON_TWOSIDE_BIT) != 0)
 #define DO_FLAT      0
 #define DO_TRI       1
 #define DO_QUAD      1
@@ -525,7 +540,6 @@ static struct {
 #define DO_POINTS    1
 #define DO_FULL_QUAD 1
 
-#define HAVE_RGBA   1
 #define HAVE_SPEC   1
 #define HAVE_BACK_COLORS  0
 #define HAVE_HW_FLATSHADE 1
@@ -675,18 +689,22 @@ static void init_rast_tab( void )
 /*                    Choose render functions                         */
 /**********************************************************************/
 
-void radeonChooseRenderState( GLcontext *ctx )
+void radeonChooseRenderState( struct gl_context *ctx )
 {
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    r100ContextPtr rmesa = R100_CONTEXT(ctx);
    GLuint index = 0;
-   GLuint flags = ctx->_TriangleCaps;
+   GLboolean unfilled = (ctx->Polygon.FrontMode != GL_FILL ||
+                         ctx->Polygon.BackMode != GL_FILL);
+   GLboolean twosided = ctx->Light.Enabled && ctx->Light.Model.TwoSide;
 
-   if (!rmesa->radeon.TclFallback || rmesa->radeon.Fallback) 
+   if (!rmesa->radeon.TclFallback || rmesa->radeon.Fallback)
       return;
 
-   if (flags & DD_TRI_LIGHT_TWOSIDE) index |= RADEON_TWOSIDE_BIT;
-   if (flags & DD_TRI_UNFILLED)      index |= RADEON_UNFILLED_BIT;
+   if (twosided)
+      index |= RADEON_TWOSIDE_BIT;
+   if (unfilled)
+      index |= RADEON_UNFILLED_BIT;
 
    if (index != rmesa->radeon.swtcl.RenderIndex) {
       tnl->Driver.Render.Points = rast_tab[index].points;
@@ -715,7 +733,7 @@ void radeonChooseRenderState( GLcontext *ctx )
 /**********************************************************************/
 
 
-static void radeonRasterPrimitive( GLcontext *ctx, GLuint hwprim )
+static void radeonRasterPrimitive( struct gl_context *ctx, GLuint hwprim )
 {
    r100ContextPtr rmesa = R100_CONTEXT(ctx);
 
@@ -725,19 +743,22 @@ static void radeonRasterPrimitive( GLcontext *ctx, GLuint hwprim )
    }
 }
 
-static void radeonRenderPrimitive( GLcontext *ctx, GLenum prim )
+static void radeonRenderPrimitive( struct gl_context *ctx, GLenum prim )
 {
    r100ContextPtr rmesa = R100_CONTEXT(ctx);
+   GLboolean unfilled = (ctx->Polygon.FrontMode != GL_FILL ||
+                         ctx->Polygon.BackMode != GL_FILL);
+
    rmesa->radeon.swtcl.render_primitive = prim;
-   if (prim < GL_TRIANGLES || !(ctx->_TriangleCaps & DD_TRI_UNFILLED)) 
+   if (prim < GL_TRIANGLES || !unfilled)
       radeonRasterPrimitive( ctx, reduced_hw_prim[prim] );
 }
 
-static void radeonRenderFinish( GLcontext *ctx )
+static void radeonRenderFinish( struct gl_context *ctx )
 {
 }
 
-static void radeonResetLineStipple( GLcontext *ctx )
+static void radeonResetLineStipple( struct gl_context *ctx )
 {
    r100ContextPtr rmesa = R100_CONTEXT(ctx);
    RADEON_STATECHANGE( rmesa, lin );
@@ -771,7 +792,7 @@ static const char *getFallbackString(GLuint bit)
 }
 
 
-void radeonFallback( GLcontext *ctx, GLuint bit, GLboolean mode )
+void radeonFallback( struct gl_context *ctx, GLuint bit, GLboolean mode )
 {
    r100ContextPtr rmesa = R100_CONTEXT(ctx);
    TNLcontext *tnl = TNL_CONTEXT(ctx);
@@ -811,7 +832,7 @@ void radeonFallback( GLcontext *ctx, GLuint bit, GLboolean mode )
             */
            _tnl_invalidate_vertex_state( ctx, ~0 );
            _tnl_invalidate_vertices( ctx, ~0 );
-           RENDERINPUTS_ZERO( rmesa->radeon.tnl_index_bitset );
+           rmesa->radeon.tnl_index_bitset = 0;
            radeonChooseVertexState( ctx );
            radeonChooseRenderState( ctx );
         }
@@ -828,7 +849,7 @@ void radeonFallback( GLcontext *ctx, GLuint bit, GLboolean mode )
 /*                            Initialization.                         */
 /**********************************************************************/
 
-void radeonInitSwtcl( GLcontext *ctx )
+void radeonInitSwtcl( struct gl_context *ctx )
 {
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    r100ContextPtr rmesa = R100_CONTEXT(ctx);
@@ -848,9 +869,9 @@ void radeonInitSwtcl( GLcontext *ctx )
    tnl->Driver.Render.CopyPV = _tnl_copy_pv;
    tnl->Driver.Render.Interp = _tnl_interp;
 
-   _tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12, 
+   _tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12,
                       RADEON_MAX_TNL_VERTEX_SIZE);
-   
+
    rmesa->radeon.swtcl.verts = (GLubyte *)tnl->clipspace.vertex_buf;
    rmesa->radeon.swtcl.RenderIndex = ~0;
    rmesa->radeon.swtcl.render_primitive = GL_TRIANGLES;