mesa/main: Add more OpenGL ES types to glheader.h.
[mesa.git] / src / mesa / drivers / dri / i810 / i810state.c
index c4662e8958018b75dda17f0cbb21592339eb74ef..1e7a6cfe471b073aacc8e4a09f59af7a7cc826da 100644 (file)
@@ -1,14 +1,16 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810state.c,v 1.9 2002/10/30 12:51:33 alanh Exp $ */
 
 #include <stdio.h>
 
-#include "glheader.h"
-#include "buffers.h"
-#include "context.h"
-#include "macros.h"
-#include "enums.h"
-#include "dd.h"
-#include "colormac.h"
+#include "main/glheader.h"
+#include "main/context.h"
+#include "main/macros.h"
+#include "main/dd.h"
+#include "main/colormac.h"
+#include "swrast/swrast.h"
+#include "tnl/tnl.h"
+#include "tnl/t_pipeline.h"
+#include "vbo/vbo.h"
+#include "swrast_setup/swrast_setup.h"
 
 #include "texmem.h"
 
 #include "i810tris.h"
 #include "i810ioctl.h"
 
-#include "swrast/swrast.h"
-#include "array_cache/acache.h"
-#include "tnl/tnl.h"
-#include "swrast_setup/swrast_setup.h"
-
-#include "tnl/t_pipeline.h"
 
-static __inline__ GLuint i810PackColor(GLuint format,
+static INLINE GLuint i810PackColor(GLuint format,
                                       GLubyte r, GLubyte g,
                                       GLubyte b, GLubyte a)
 {
@@ -294,18 +290,20 @@ void i810DrawBuffer(GLcontext *ctx, GLenum mode )
    i810ContextPtr imesa = I810_CONTEXT(ctx);
    int front = 0;
   
-   /*
-    * _DrawDestMask is easier to cope with than <mode>.
-    */
-   switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0]) {
-   case BUFFER_BIT_FRONT_LEFT:
+   if (ctx->DrawBuffer->_NumColorDrawBuffers != 1) {
+      /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */
+      FALLBACK( imesa, I810_FALLBACK_DRAW_BUFFER, GL_TRUE );
+      return;
+   }
+
+   switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0]) {
+   case BUFFER_FRONT_LEFT:
      front = 1;
      break;
-   case BUFFER_BIT_BACK_LEFT:
+   case BUFFER_BACK_LEFT:
      front = 0;
      break;
    default:
-      /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */
       FALLBACK( imesa, I810_FALLBACK_DRAW_BUFFER, GL_TRUE );
       return;
    }
@@ -329,11 +327,6 @@ void i810DrawBuffer(GLcontext *ctx, GLenum mode )
                                             imesa->i810Screen->backPitchBits);
      i810XMesaSetBackClipRects( imesa );
    }
-
-   /* We want to update the s/w rast state too so that r200SetBuffer()
-    * gets called.
-    */
-   _swrast_DrawBuffer(ctx, mode);
 }
 
 
@@ -387,7 +380,10 @@ static void i810CullFaceFrontFace(GLcontext *ctx, GLenum unused)
 static void i810LineWidth( GLcontext *ctx, GLfloat widthf )
 {
    i810ContextPtr imesa = I810_CONTEXT( ctx );
-   int width = (int)ctx->Line._Width;
+   /* AA, non-AA limits are same */
+   const int width = (int) CLAMP(ctx->Line.Width,
+                                 ctx->Const.MinLineWidth,
+                                 ctx->Const.MaxLineWidth);
 
    imesa->LcsLineWidth = 0;
    if (width & 1) imesa->LcsLineWidth |= LCS_LINEWIDTH_1_0;
@@ -403,7 +399,10 @@ static void i810LineWidth( GLcontext *ctx, GLfloat widthf )
 static void i810PointSize( GLcontext *ctx, GLfloat sz )
 {
    i810ContextPtr imesa = I810_CONTEXT( ctx );
-   int size = (int)ctx->Point._Size;
+   /* AA, non-AA limits are same */
+   const int size = (int) CLAMP(ctx->Point.Size,
+                                ctx->Const.MinPointSize,
+                                ctx->Const.MaxPointSize);
 
    imesa->LcsPointSize = 0;
    if (size & 1) imesa->LcsPointSize |= LCS_LINEWIDTH_1_0;
@@ -604,6 +603,7 @@ static void i810Enable(GLcontext *ctx, GLenum cap, GLboolean state)
         imesa->Setup[I810_CTXREG_LCS] |= LCS_CULL_DISABLE;
       break;
    case GL_TEXTURE_2D:
+   case GL_TEXTURE_RECTANGLE_NV:
       I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
       if (ctx->Texture.CurrentUnit == 0) {
         imesa->Setup[I810_CTXREG_MT] &= ~MT_TEXEL0_ENABLE;
@@ -695,8 +695,6 @@ static void i810Viewport( GLcontext *ctx,
                          GLint x, GLint y,
                          GLsizei width, GLsizei height )
 {
-   /* update size of Mesa/software ancillary buffers */
-   _mesa_ResizeBuffersMESA();
    i810CalcViewport( ctx );
 }
 
@@ -939,14 +937,10 @@ void i810InitState( GLcontext *ctx )
 
    if (imesa->glCtx->Visual.doubleBufferMode && imesa->sarea->pf_current_page == 0) {
       /* use back buffer by default */
-      imesa->drawMap = i810Screen->back.map;
-      imesa->readMap = i810Screen->back.map;
       imesa->BufferSetup[I810_DESTREG_DI1] = (i810Screen->backOffset |
                                              i810Screen->backPitchBits);
    } else {
       /* use front buffer by default */
-      imesa->drawMap = (char *)imesa->driScreen->pFB;
-      imesa->readMap = (char *)imesa->driScreen->pFB;
       imesa->BufferSetup[I810_DESTREG_DI1] = (i810Screen->fbOffset |
                                              i810Screen->backPitchBits);
    }
@@ -965,7 +959,7 @@ static void i810InvalidateState( GLcontext *ctx, GLuint new_state )
 {
    _swrast_InvalidateState( ctx, new_state );
    _swsetup_InvalidateState( ctx, new_state );
-   _ac_InvalidateState( ctx, new_state );
+   _vbo_InvalidateState( ctx, new_state );
    _tnl_InvalidateState( ctx, new_state );
    I810_CONTEXT(ctx)->new_state |= new_state;
 }
@@ -1007,19 +1001,4 @@ void i810InitStateFuncs(GLcontext *ctx)
    } else {
       ctx->Driver.LightModelfv = i810LightModelfv;
    }
-
-   /* Pixel path fallbacks.
-    */
-   ctx->Driver.Accum = _swrast_Accum;
-   ctx->Driver.Bitmap = _swrast_Bitmap;
-   ctx->Driver.CopyPixels = _swrast_CopyPixels;
-   ctx->Driver.DrawPixels = _swrast_DrawPixels;
-   ctx->Driver.ReadPixels = _swrast_ReadPixels;
-
-   /* Swrast hooks for imaging extensions:
-    */
-   ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
-   ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
-   ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
-   ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
 }