Drop GLcontext typedef and use struct gl_context instead
[mesa.git] / src / mesa / swrast_setup / ss_context.c
index f4d90c514bbac658fbdfe90fcb65f34f0db2fe34..5da2e1eabeeb09eb2f12dbf9e9981bd050f83fff 100644 (file)
@@ -47,7 +47,7 @@
 
 
 GLboolean
-_swsetup_CreateContext( GLcontext *ctx )
+_swsetup_CreateContext( struct gl_context *ctx )
 {
    SScontext *swsetup = (SScontext *)CALLOC(sizeof(SScontext));
 
@@ -67,7 +67,7 @@ _swsetup_CreateContext( GLcontext *ctx )
 }
 
 void
-_swsetup_DestroyContext( GLcontext *ctx )
+_swsetup_DestroyContext( struct gl_context *ctx )
 {
    SScontext *swsetup = SWSETUP_CONTEXT(ctx);
 
@@ -80,7 +80,7 @@ _swsetup_DestroyContext( GLcontext *ctx )
 }
 
 static void
-_swsetup_RenderPrimitive( GLcontext *ctx, GLenum mode )
+_swsetup_RenderPrimitive( struct gl_context *ctx, GLenum mode )
 {
    SWSETUP_CONTEXT(ctx)->render_prim = mode;
    _swrast_render_primitive( ctx, mode );
@@ -108,26 +108,29 @@ do {                                              \
  * _tnl_install_attrs().
  */
 static void
-setup_vertex_format(GLcontext *ctx)
+setup_vertex_format(struct gl_context *ctx)
 {
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    SScontext *swsetup = SWSETUP_CONTEXT(ctx);
+   GLboolean intColors = !ctx->FragmentProgram._Current
+                      && !ctx->ATIFragmentShader._Enabled
+                      && ctx->RenderMode == GL_RENDER
+                      && CHAN_TYPE != GL_FLOAT;
 
-   if (!RENDERINPUTS_EQUAL(tnl->render_inputs_bitset,
+   if (intColors != swsetup->intColors ||
+       !RENDERINPUTS_EQUAL(tnl->render_inputs_bitset,
                            swsetup->last_index_bitset)) {
       DECLARE_RENDERINPUTS(index_bitset);
       struct tnl_attr_map map[_TNL_ATTRIB_MAX];
-      int i, e = 0;
+      unsigned int i, e = 0;
+
+      swsetup->intColors = intColors;
 
       RENDERINPUTS_COPY( index_bitset, tnl->render_inputs_bitset );
 
       EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, attrib[FRAG_ATTRIB_WPOS] );
 
       if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR0 )) {
-         swsetup->intColors = !ctx->FragmentProgram._Current
-                           && !ctx->ATIFragmentShader._Enabled
-                           && ctx->RenderMode == GL_RENDER
-                           && CHAN_TYPE == GL_UNSIGNED_BYTE;
          if (swsetup->intColors)
             EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4CHAN_4F_RGBA, color );
          else
@@ -138,11 +141,6 @@ setup_vertex_format(GLcontext *ctx)
          EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_4F, attrib[FRAG_ATTRIB_COL1]);
       }
 
-      if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR_INDEX )) {
-         EMIT_ATTR( _TNL_ATTRIB_COLOR_INDEX, EMIT_1F,
-                    attrib[FRAG_ATTRIB_CI][0] );
-      }
-
       if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG )) {
          const GLint emit = ctx->FragmentProgram._Current ? EMIT_4F : EMIT_1F;
          EMIT_ATTR( _TNL_ATTRIB_FOG, emit, attrib[FRAG_ATTRIB_FOGC]);
@@ -186,7 +184,7 @@ setup_vertex_format(GLcontext *ctx)
  * Called via tnl->Driver.Render.Start.
  */
 static void
-_swsetup_RenderStart( GLcontext *ctx )
+_swsetup_RenderStart( struct gl_context *ctx )
 {
    SScontext *swsetup = SWSETUP_CONTEXT(ctx);
    TNLcontext *tnl = TNL_CONTEXT(ctx);
@@ -219,13 +217,13 @@ _swsetup_RenderStart( GLcontext *ctx )
  * It's called when we finish rendering a vertex buffer.
  */
 static void
-_swsetup_RenderFinish( GLcontext *ctx )
+_swsetup_RenderFinish( struct gl_context *ctx )
 {
    _swrast_render_finish( ctx );
 }
 
 void
-_swsetup_InvalidateState( GLcontext *ctx, GLuint new_state )
+_swsetup_InvalidateState( struct gl_context *ctx, GLuint new_state )
 {
    SScontext *swsetup = SWSETUP_CONTEXT(ctx);
    swsetup->NewState |= new_state;
@@ -234,7 +232,7 @@ _swsetup_InvalidateState( GLcontext *ctx, GLuint new_state )
 
 
 void
-_swsetup_Wakeup( GLcontext *ctx )
+_swsetup_Wakeup( struct gl_context *ctx )
 {
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    SScontext *swsetup = SWSETUP_CONTEXT(ctx);
@@ -269,7 +267,7 @@ _swsetup_Wakeup( GLcontext *ctx )
  * Populate a swrast SWvertex from an attrib-style vertex.
  */
 void 
-_swsetup_Translate( GLcontext *ctx, const void *vertex, SWvertex *dest )
+_swsetup_Translate( struct gl_context *ctx, const void *vertex, SWvertex *dest )
 {
    const GLfloat *m = ctx->Viewport._WindowMap.m;
    GLfloat tmp[4];
@@ -291,18 +289,12 @@ _swsetup_Translate( GLcontext *ctx, const void *vertex, SWvertex *dest )
       _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_GENERIC0 + i,
                      dest->attrib[FRAG_ATTRIB_VAR0 + i] );
 
-   if (ctx->Visual.rgbMode) {
-      _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR0,
-                     dest->attrib[FRAG_ATTRIB_COL0] );
-      UNCLAMPED_FLOAT_TO_RGBA_CHAN( dest->color, tmp );
+   _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR0,
+                  dest->attrib[FRAG_ATTRIB_COL0] );
+   UNCLAMPED_FLOAT_TO_RGBA_CHAN( dest->color, tmp );
 
-      _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR1,
-                     dest->attrib[FRAG_ATTRIB_COL1]);
-   }
-   else {
-      _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR_INDEX, tmp );
-      dest->attrib[FRAG_ATTRIB_CI][0] = tmp[0];
-   }
+   _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR1,
+                  dest->attrib[FRAG_ATTRIB_COL1]);
 
    _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_FOG, tmp );
    dest->attrib[FRAG_ATTRIB_FOGC][0] = tmp[0];