SetBuffer, renderbuffer changes
authorBrian Paul <brian.paul@tungstengraphics.com>
Sat, 3 Sep 2005 16:43:02 +0000 (16:43 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Sat, 3 Sep 2005 16:43:02 +0000 (16:43 +0000)
43 files changed:
src/mesa/drivers/dri/ffb/ffb_span.c
src/mesa/drivers/dri/ffb/ffb_state.c
src/mesa/drivers/dri/ffb/ffb_xmesa.c
src/mesa/drivers/dri/i810/i810context.c
src/mesa/drivers/dri/i810/i810context.h
src/mesa/drivers/dri/i810/i810screen.c
src/mesa/drivers/dri/i810/i810span.c
src/mesa/drivers/dri/i810/i810state.c
src/mesa/drivers/dri/mach64/mach64_screen.c
src/mesa/drivers/dri/mach64/mach64_span.c
src/mesa/drivers/dri/mach64/mach64_state.c
src/mesa/drivers/dri/mga/mgaspan.c
src/mesa/drivers/dri/mga/mgastate.c
src/mesa/drivers/dri/r128/r128_context.h
src/mesa/drivers/dri/r128/r128_ioctl.c
src/mesa/drivers/dri/r128/r128_lock.c
src/mesa/drivers/dri/r128/r128_screen.c
src/mesa/drivers/dri/r128/r128_span.c
src/mesa/drivers/dri/r128/r128_state.c
src/mesa/drivers/dri/r128/r128_state.h
src/mesa/drivers/dri/s3v/s3v_context.h
src/mesa/drivers/dri/s3v/s3v_span.c
src/mesa/drivers/dri/s3v/s3v_xmesa.c
src/mesa/drivers/dri/savage/savage_xmesa.c
src/mesa/drivers/dri/savage/savagecontext.h
src/mesa/drivers/dri/savage/savageioctl.c
src/mesa/drivers/dri/savage/savagespan.c
src/mesa/drivers/dri/savage/savagestate.c
src/mesa/drivers/dri/sis/sis_context.h
src/mesa/drivers/dri/sis/sis_screen.c
src/mesa/drivers/dri/sis/sis_span.c
src/mesa/drivers/dri/sis/sis_state.c
src/mesa/drivers/dri/tdfx/tdfx_span.c
src/mesa/drivers/dri/tdfx/tdfx_state.c
src/mesa/drivers/dri/unichrome/via_context.c
src/mesa/drivers/dri/unichrome/via_context.h
src/mesa/drivers/dri/unichrome/via_fb.c
src/mesa/drivers/dri/unichrome/via_fb.h
src/mesa/drivers/dri/unichrome/via_ioctl.c
src/mesa/drivers/dri/unichrome/via_screen.c
src/mesa/drivers/dri/unichrome/via_span.c
src/mesa/drivers/dri/unichrome/via_span.h
src/mesa/drivers/dri/unichrome/via_state.c

index f4698c64e4a65104fd4938da6e6220147b0ffff7..a23f4c66f0a2120c52955a73b5229a6729d67518 100644 (file)
@@ -114,7 +114,7 @@ do {        GLuint p = *(GLuint *)(buf + ((__x)<<2) + ((__y)<<13)); \
 
 #define TAG(x) ffb##x##_888
 
-#include <spantmp.h>
+#include "spantmp.h"
 
 /**
  * Plug in the Get/Put routines for the given driRenderbuffer.
index 86df5b4bcac89b7a1ba8e5cdad5f1c1e22d9fc2d..95ff820e104e918c003fc915456a8e6b7281355a 100644 (file)
@@ -510,6 +510,13 @@ static void ffbDDReadBuffer(GLcontext *ctx, GLenum buffer)
 /*
  * Specifies buffer for sw fallbacks (spans)
  */
+#if 000
+/* XXX
+ * This function is obsolete.  It's not clear how this really effected
+ * span reading/writing above.  The span functions should use the
+ * incoming driRenderbuffer (gl_renderbuffer) pointer to determine how
+ * to read from the specified bufer.
+ */
 static void ffbDDSetBuffer(GLcontext *ctx, GLframebuffer *colorBuffer,
                           GLuint bufferBit)
 {
@@ -546,6 +553,8 @@ static void ffbDDSetBuffer(GLcontext *ctx, GLframebuffer *colorBuffer,
                FFB_MAKE_DIRTY(fmesa, FFB_STATE_FBC, 1);
        }
 }
+#endif
+
 
 static void ffbDDClearColor(GLcontext *ctx, const GLfloat color[4])
 {
@@ -1091,14 +1100,6 @@ void ffbDDInitStateFuncs(GLcontext *ctx)
        ctx->Driver.ClearIndex = 0;
        ctx->Driver.IndexMask = 0;
         */
-
-       {
-               struct swrast_device_driver *swdd = 
-                       _swrast_GetDeviceDriverReference(ctx);
-               swdd->SetBuffer = ffbDDSetBuffer;
-       }
-   
-
 }
 
 void ffbDDInitContextHwState(GLcontext *ctx)
index 530c5373a9da6163589576c5c31180419e3ed5dd..29aab4acba76d6fd267a491935d61045355303f9 100644 (file)
@@ -339,14 +339,6 @@ ffbCreateBuffer(__DRIscreenPrivate *driScrnPriv,
    } else {
       GLboolean swStencil = (mesaVis->stencilBits > 0 && 
                             mesaVis->depthBits != 24);
-#if 0
-      driDrawPriv->driverPrivate = (void *) 
-        _mesa_create_framebuffer(mesaVis,
-                                 GL_FALSE,  /* software depth buffer? */
-                                  mesaVis->stencilBits > 0,
-                                  mesaVis->accumRedBits > 0,
-                                  mesaVis->alphaBits > 0);
-#else
       struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
 
       {
@@ -385,7 +377,7 @@ ffbCreateBuffer(__DRIscreenPrivate *driScrnPriv,
                                    GL_FALSE, /* alpha */
                                    GL_FALSE /* aux */);
       driDrawPriv->driverPrivate = (void *) fb;
-#endif
+
       return (driDrawPriv->driverPrivate != NULL);
    }
 }
index fd80e7675c4ced8efca777ede09c84592e72fd03..d3445706a48507919349744949884c633c7ecb2c 100644 (file)
@@ -60,6 +60,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "i810vb.h"
 #include "i810ioctl.h"
 
+#include "drirenderbuffer.h"
 #include "utils.h"
 
 #define need_GL_ARB_multisample
@@ -489,15 +490,13 @@ i810UpdatePageFlipping( i810ContextPtr imesa )
 
    if ( imesa->sarea->pf_current_page == 1 ) 
      front ^= 1;
+
+   driFlipRenderbuffers(ctx->WinSysDrawBuffer, front);
    
    if (front) {
       imesa->BufferSetup[I810_DESTREG_DI1] = imesa->i810Screen->fbOffset | imesa->i810Screen->backPitchBits;
-      imesa->drawMap = (char *)imesa->driScreen->pFB;
-      imesa->readMap = (char *)imesa->driScreen->pFB;
    } else {
       imesa->BufferSetup[I810_DESTREG_DI1] = imesa->i810Screen->backOffset | imesa->i810Screen->backPitchBits;
-      imesa->drawMap = imesa->i810Screen->back.map;
-      imesa->readMap = imesa->i810Screen->back.map;
    }
 
    imesa->dirty |= I810_UPLOAD_BUFFERS;
index a2202e148f9dbc899cc739145ebba379aa4464be..b83500bbd0c1b33576b9153bd7906ce5e4caa55e 100644 (file)
@@ -152,8 +152,6 @@ struct i810_context_t {
 
    /* These refer to the current draw (front vs. back) buffer:
     */
-   char *drawMap;              /* draw buffer address in virtual mem */
-   char *readMap;      
    int drawX;                  /* origin of drawable in draw buffer */
    int drawY;
    GLuint numClipRects;                /* cliprects for that buffer */
index 991c7cb231650aef243a75cf0c5906b6adc1e5ce..af8e0cc08ab0c22da61598ac50ee737d02fe43d9 100644 (file)
@@ -362,6 +362,7 @@ i810CreateBuffer( __DRIscreenPrivate *driScrnPriv,
                                  /*screen->frontOffset*/0, screen->backPitch);
          i810SetSpanFunctions(frontRb, mesaVis);
          _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
+         frontRb->Base.Data = driScrnPriv->pFB;
       }
 
       if (mesaVis->doubleBufferMode) {
@@ -370,6 +371,7 @@ i810CreateBuffer( __DRIscreenPrivate *driScrnPriv,
                                  screen->backOffset, screen->backPitch);
          i810SetSpanFunctions(backRb, mesaVis);
          _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
+         backRb->Base.Data = (GLubyte *) screen->back.map;
       }
 
       if (mesaVis->depthBits == 16) {
@@ -378,6 +380,7 @@ i810CreateBuffer( __DRIscreenPrivate *driScrnPriv,
                                  screen->depthOffset, screen->backPitch);
          i810SetSpanFunctions(depthRb, mesaVis);
          _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+         depthRb->Base.Data = (GLubyte *) screen->depth.map;
       }
 
       _mesa_add_soft_renderbuffers(fb,
index 1a976048c89e1d37decd596f69df155a8fb51cee..ac9010666481a9582c7b7151cfed7e23f03da9b8 100644 (file)
 #define LOCAL_VARS                                     \
    i810ContextPtr imesa = I810_CONTEXT(ctx);           \
    __DRIdrawablePrivate *dPriv = imesa->driDrawable;   \
-   i810ScreenPrivate *i810Screen = imesa->i810Screen;  \
-   GLuint pitch = i810Screen->backPitch;               \
+   driRenderbuffer *drb = (driRenderbuffer *) rb;      \
+   GLuint pitch = drb->pitch;                          \
    GLuint height = dPriv->h;                           \
    GLushort p;                                         \
-   char *buf = (char *)(imesa->drawMap +               \
+   char *buf = (char *)(drb->flippedData +             \
                        dPriv->x * 2 +                  \
                        dPriv->y * pitch);              \
-   char *read_buf = (char *)(imesa->readMap +          \
-                            dPriv->x * 2 +             \
-                            dPriv->y * pitch);         \
+   char *read_buf = buf;                               \
    (void) read_buf; (void) buf; (void) p
 
 #define LOCAL_DEPTH_VARS                               \
    i810ContextPtr imesa = I810_CONTEXT(ctx);           \
    __DRIdrawablePrivate *dPriv = imesa->driDrawable;   \
-   i810ScreenPrivate *i810Screen = imesa->i810Screen;  \
-   GLuint pitch = i810Screen->backPitch;               \
+   driRenderbuffer *drb = (driRenderbuffer *) rb;      \
+   GLuint pitch = drb->pitch;                          \
    GLuint height = dPriv->h;                           \
-   char *buf = (char *)(i810Screen->depth.map +        \
+   char *buf = (char *)(drb->Base.Data +               \
                        dPriv->x * 2 +                  \
                        dPriv->y * pitch)
 
@@ -76,41 +74,10 @@ do {                                                                        \
 #define READ_DEPTH( d, _x, _y )        \
    d = *(GLushort *)(buf + (_x)*2 + (_y)*pitch);
 
-#define TAG(x) i810##x##_16
+#define TAG(x) i810##x##_z16
 #include "depthtmp.h"
 
 
-/*
- * This function is called to specify which buffer to read and write
- * for software rasterization (swrast) fallbacks.  This doesn't necessarily
- * correspond to glDrawBuffer() or glReadBuffer() calls.
- */
-static void i810SetBuffer(GLcontext *ctx, GLframebuffer *buffer,
-                          GLuint bufferBit )
-{
-   i810ContextPtr imesa = I810_CONTEXT(ctx);
-   (void) buffer;
-
-   switch(bufferBit) {
-    case BUFFER_BIT_FRONT_LEFT:
-      if ( imesa->sarea->pf_current_page == 1)
-        imesa->readMap = imesa->i810Screen->back.map;
-      else
-        imesa->readMap = (char*)imesa->driScreen->pFB;
-      break;
-    case BUFFER_BIT_BACK_LEFT:
-      if ( imesa->sarea->pf_current_page == 1)
-        imesa->readMap =  (char*)imesa->driScreen->pFB;
-      else
-        imesa->readMap = imesa->i810Screen->back.map;
-      break;
-    default:
-       ASSERT(0);
-       break;
-   }
-   imesa->drawMap = imesa->readMap;
-}
-
 /* Move locking out to get reasonable span performance.
  */
 void i810SpanRenderStart( GLcontext *ctx )
@@ -131,26 +98,6 @@ void i810SpanRenderFinish( GLcontext *ctx )
 void i810InitSpanFuncs( GLcontext *ctx )
 {
    struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
-
-   swdd->SetBuffer = i810SetBuffer;
-
-#if 0
-   swdd->WriteRGBASpan = i810WriteRGBASpan_565;
-   swdd->WriteRGBSpan = i810WriteRGBSpan_565;
-   swdd->WriteMonoRGBASpan = i810WriteMonoRGBASpan_565;
-   swdd->WriteRGBAPixels = i810WriteRGBAPixels_565;
-   swdd->WriteMonoRGBAPixels = i810WriteMonoRGBAPixels_565;
-   swdd->ReadRGBASpan = i810ReadRGBASpan_565;
-   swdd->ReadRGBAPixels = i810ReadRGBAPixels_565;
-#endif
-
-#if 0
-   swdd->ReadDepthSpan = i810ReadDepthSpan_16;
-   swdd->WriteDepthSpan = i810WriteDepthSpan_16;
-   swdd->ReadDepthPixels = i810ReadDepthPixels_16;
-   swdd->WriteDepthPixels = i810WriteDepthPixels_16;
-#endif
-
    swdd->SpanRenderStart = i810SpanRenderStart;
    swdd->SpanRenderFinish = i810SpanRenderFinish; 
 }
@@ -174,12 +121,7 @@ i810SetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
       drb->Base.PutMonoValues = i810WriteMonoRGBAPixels_565;
    }
    else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
-      drb->Base.GetRow        = i810ReadDepthSpan_16;
-      drb->Base.GetValues     = i810ReadDepthPixels_16;
-      drb->Base.PutRow        = i810WriteDepthSpan_16;
-      drb->Base.PutMonoRow    = i810WriteMonoDepthSpan_16;
-      drb->Base.PutValues     = i810WriteDepthPixels_16;
-      drb->Base.PutMonoValues = NULL;
+      i810InitDepthPointers_z16(&drb->Base);
    }
    else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
       /* should never get here */
index c4662e8958018b75dda17f0cbb21592339eb74ef..4a811a0d032f05caf61e8a91cee118bd18b3a437 100644 (file)
@@ -329,11 +329,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);
 }
 
 
@@ -939,14 +934,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);
    }
index bcdaea166d0e9ff3ce800e16751c8bf7f11f6fd0..62b1bc2ba527fc7b722791f22f53f9a0013280c4 100644 (file)
@@ -372,14 +372,6 @@ mach64CreateBuffer( __DRIscreenPrivate *driScrnPriv,
       return GL_FALSE; /* not implemented */
    }
    else {
-#if 0
-      driDrawPriv->driverPrivate = (void *) 
-         _mesa_create_framebuffer( mesaVis,
-                                   GL_FALSE,  /* software depth buffer? */
-                                   mesaVis->stencilBits > 0,
-                                   mesaVis->accumRedBits > 0,
-                                   mesaVis->alphaBits > 0 );
-#else
       struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
 
       {
@@ -406,6 +398,7 @@ mach64CreateBuffer( __DRIscreenPrivate *driScrnPriv,
          _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
       }
       else if (mesaVis->depthBits == 24) {
+         /* XXX I don't think 24-bit Z is supported - so this isn't used */
          driRenderbuffer *depthRb
             = driNewRenderbuffer(GL_DEPTH_COMPONENT24, screen->cpp,
                                  screen->depthOffset, screen->depthPitch);
@@ -421,7 +414,7 @@ mach64CreateBuffer( __DRIscreenPrivate *driScrnPriv,
                                    GL_FALSE, /* alpha */
                                    GL_FALSE /* aux */);
       driDrawPriv->driverPrivate = (void *) fb;
-#endif
+
       return (driDrawPriv->driverPrivate != NULL);
    }
 }
index 0ac0eeaa6043d7a9d44bda6489c7da3ef3bd5421..dc9f27caeecf0251204a062bb49599a73d7ae8ba 100644 (file)
 
 #define DBG 0
 
+#define GET_PTR(X,Y) (sPriv->pFB + drb->offset         \
+     + ((dPriv->y + (Y)) * drb->pitch + (dPriv->x + (X))) * drb->cpp)
+
 #define LOCAL_VARS                                                     \
    mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);                       \
-   mach64ScreenRec *mach64Screen = mmesa->mach64Screen;                        \
-   __DRIscreenPrivate *driScreen = mmesa->driScreen;                   \
+   __DRIscreenPrivate *sPriv = mmesa->driScreen;                       \
    __DRIdrawablePrivate *dPriv = mmesa->driDrawable;                   \
-   GLuint pitch = mmesa->drawPitch * mach64Screen->cpp;                        \
+   driRenderbuffer *drb = (driRenderbuffer *) rb;                      \
    GLuint height = dPriv->h;                                           \
-   char *buf = (char *)(driScreen->pFB +                               \
-                       mmesa->drawOffset +                             \
-                       (dPriv->x * mach64Screen->cpp) +                \
-                       (dPriv->y * pitch));                            \
-   char *read_buf = (char *)(driScreen->pFB +                          \
-                            mmesa->readOffset +                        \
-                            (dPriv->x * mach64Screen->cpp) +           \
-                            (dPriv->y * pitch));                       \
    GLushort p;                                                         \
-   (void) read_buf; (void) buf; (void) p
+   (void) p;
 
 #define LOCAL_DEPTH_VARS                                               \
    mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);                       \
-   mach64ScreenRec *mach64Screen = mmesa->mach64Screen;                        \
    __DRIdrawablePrivate *dPriv = mmesa->driDrawable;                   \
    __DRIscreenPrivate *driScreen = mmesa->driScreen;                   \
-   GLuint pitch = mach64Screen->depthPitch * 2;                                \
+   driRenderbuffer *drb = (driRenderbuffer *) rb;                      \
    GLuint height = dPriv->h;                                           \
-   char *buf = (char *)(driScreen->pFB +                               \
-                       mach64Screen->depthOffset +                     \
-                       dPriv->x * 2 +                                  \
-                       dPriv->y * pitch)
+   char *buf = (char *)(driScreen->pFB + drb->offset +                 \
+                       (dPriv->x + dPriv->y * drb->pitch) * 2)
 
 #define LOCAL_STENCIL_VARS     LOCAL_DEPTH_VARS
 
 
 #define TAG(x)    mach64##x##_RGB565
 #define TAG2(x,y) mach64##x##_RGB565##y
+#define GET_SRC_PTR(X,Y) GET_PTR(X,Y)
+#define GET_DST_PTR(X,Y) GET_SRC_PTR(X,Y)
 #include "spantmp2.h"
 
 
 
 #define TAG(x)    mach64##x##_ARGB8888
 #define TAG2(x,y) mach64##x##_ARGB8888##y
+#define GET_SRC_PTR(X,Y) GET_PTR(X,Y)
+#define GET_DST_PTR(X,Y) GET_SRC_PTR(X,Y)
 #include "spantmp2.h"
 
 
 /* 16 bit depthbuffer functions.
  */
 #define WRITE_DEPTH( _x, _y, d )                                       \
-   *(GLushort *)(buf + (_x)*2 + (_y)*pitch) = d;
+   *(GLushort *)(buf + ((_x) + (_y) * drb->pitch) * 2) = d;
 
 #define READ_DEPTH( d, _x, _y )                                                \
-   d = *(GLushort *)(buf + (_x)*2 + (_y)*pitch);
+   d = *(GLushort *)(buf + ((_x) + (_y) * drb->pitch) * 2);
 
-#define TAG(x) mach64##x##_16
+#define TAG(x) mach64##x##_z16
 #include "depthtmp.h"
 
 
-/*
- * This function is called to specify which buffer to read and write
- * for software rasterization (swrast) fallbacks.  This doesn't necessarily
- * correspond to glDrawBuffer() or glReadBuffer() calls.
- */
-static void mach64DDSetBuffer( GLcontext *ctx,
-                              GLframebuffer *colorBuffer,
-                              GLuint bufferBit )
-{
-   mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
-
-   switch ( bufferBit ) {
-   case BUFFER_BIT_FRONT_LEFT:
-      if (MACH64_DEBUG & DEBUG_VERBOSE_MSG)
-        fprintf(stderr,"%s: BUFFER_BIT_FRONT_LEFT\n", __FUNCTION__);
-      mmesa->drawOffset = mmesa->readOffset = mmesa->mach64Screen->frontOffset;
-      mmesa->drawPitch  = mmesa->readPitch  = mmesa->mach64Screen->frontPitch;
-      break;
-   case BUFFER_BIT_BACK_LEFT:
-      if (MACH64_DEBUG & DEBUG_VERBOSE_MSG)
-        fprintf(stderr,"%s: BUFFER_BIT_BACK_LEFT\n", __FUNCTION__);
-      mmesa->drawOffset = mmesa->readOffset = mmesa->mach64Screen->backOffset;
-      mmesa->drawPitch  = mmesa->readPitch  = mmesa->mach64Screen->backPitch;
-      break;
-   default:
-      break;
-   }
-}
-
 static void mach64SpanRenderStart( GLcontext *ctx )
 {
    mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
@@ -181,8 +147,6 @@ static void mach64SpanRenderFinish( GLcontext *ctx )
 void mach64DDInitSpanFuncs( GLcontext *ctx )
 {
    struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
-
-   swdd->SetBuffer = mach64DDSetBuffer;
    swdd->SpanRenderStart       = mach64SpanRenderStart;
    swdd->SpanRenderFinish      = mach64SpanRenderFinish;
 }
@@ -203,29 +167,6 @@ mach64SetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
       }
    }
    else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
-      drb->Base.GetRow        = mach64ReadDepthSpan_16;
-      drb->Base.GetValues     = mach64ReadDepthPixels_16;
-      drb->Base.PutRow        = mach64WriteDepthSpan_16;
-      drb->Base.PutMonoRow    = mach64WriteMonoDepthSpan_16;
-      drb->Base.PutValues     = mach64WriteDepthPixels_16;
-      drb->Base.PutMonoValues = NULL;
-   }
-   else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
-      /* never */
-      drb->Base.GetRow        = NULL;
-      drb->Base.GetValues     = NULL;
-      drb->Base.PutRow        = NULL;
-      drb->Base.PutMonoRow    = NULL;
-      drb->Base.PutValues     = NULL;
-      drb->Base.PutMonoValues = NULL;
-   }
-   else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
-      /* never */
-      drb->Base.GetRow        = NULL;
-      drb->Base.GetValues     = NULL;
-      drb->Base.PutRow        = NULL;
-      drb->Base.PutMonoRow    = NULL;
-      drb->Base.PutValues     = NULL;
-      drb->Base.PutMonoValues = NULL;
+      mach64InitDepthPointers_z16(&drb->Base);
    }
 }
index d9b5725a638bac018d16b7e91da2408707775d68..1eb4b6e73c29de3faf0912cb2fd5c92e5dbe39d1 100644 (file)
@@ -753,11 +753,6 @@ static void mach64DDDrawBuffer( GLcontext *ctx, GLenum mode )
       break;
    }
 
-   /* We want to update the s/w rast state too so that mach64SetBuffer()
-    * gets called.
-    */
-   _swrast_DrawBuffer(ctx, mode);
-
    mmesa->setup.dst_off_pitch = (((mmesa->drawPitch/8) << 22) |
                                 (mmesa->drawOffset >> 3));
 
index c62b1c875a2d029fc4921df9af7eac679543cb44..494d1a36b60382493510deae03a26dfcdb13217e 100644 (file)
@@ -24,7 +24,6 @@
  * Authors:
  *    Keith Whitwell <keith@tungstengraphics.com>
  */
-/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgaspan.c,v 1.11 2002/10/30 12:51:36 alanh Exp $ */
 
 #include "mtypes.h"
 #include "mgadd.h"
 #define DBG 0
 
 #define LOCAL_VARS                                     \
-   mgaContextPtr mmesa = MGA_CONTEXT(ctx);                             \
+   mgaContextPtr mmesa = MGA_CONTEXT(ctx);             \
    __DRIdrawablePrivate *dPriv = mmesa->mesa_drawable; \
-   mgaScreenPrivate *mgaScreen = mmesa->mgaScreen;     \
    __DRIscreenPrivate *sPriv = mmesa->driScreen;       \
-   GLuint pitch = mgaScreen->frontPitch;               \
+   driRenderbuffer *drb = (driRenderbuffer *) rb;      \
+   GLuint pitch = drb->pitch;                          \
    GLuint height = dPriv->h;                           \
-   char *read_buf = (char *)(sPriv->pFB +              \
-                       mmesa->readOffset +             \
-                       dPriv->x * mgaScreen->cpp +     \
-                       dPriv->y * pitch);              \
    char *buf = (char *)(sPriv->pFB +                   \
-                       mmesa->drawOffset +             \
-                       dPriv->x * mgaScreen->cpp +     \
+                       drb->offset +                   \
+                       dPriv->x * drb->cpp +           \
                        dPriv->y * pitch);              \
+   char *read_buf = buf;                               \
    GLuint p;                                           \
    (void) read_buf; (void) buf; (void) p
 
 #define LOCAL_DEPTH_VARS                                               \
    mgaContextPtr mmesa = MGA_CONTEXT(ctx);                             \
    __DRIdrawablePrivate *dPriv = mmesa->mesa_drawable;                 \
-   mgaScreenPrivate *mgaScreen = mmesa->mgaScreen;                     \
    __DRIscreenPrivate *sPriv = mmesa->driScreen;                       \
-   GLuint pitch = mgaScreen->frontPitch;                               \
+   driRenderbuffer *drb = (driRenderbuffer *) rb;                      \
+   GLuint pitch = drb->pitch;                                          \
    GLuint height = dPriv->h;                                           \
    char *buf = (char *)(sPriv->pFB +                                   \
-                       mgaScreen->depthOffset +                        \
-                       dPriv->x * mgaScreen->cpp +                     \
+                       drb->offset +                                   \
+                       dPriv->x * drb->cpp +                           \
                        dPriv->y * pitch)
 
 #define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS 
 #define READ_DEPTH( d, _x, _y )                \
    d = *(GLushort *)(buf + (_x)*2 + (_y)*pitch);
 
-#define TAG(x) mga##x##_16
+#define TAG(x) mga##x##_z16
 #include "depthtmp.h"
 
 
 #define READ_DEPTH( d, _x, _y )                \
    d = *(GLuint *)(buf + (_x)*4 + (_y)*pitch);
 
-#define TAG(x) mga##x##_32
+#define TAG(x) mga##x##_z32
 #include "depthtmp.h"
 
 
    d = (*(GLuint *)(buf + (_x)*4 + (_y)*pitch) & ~0xff) >> 8;  \
 }
 
-#define TAG(x) mga##x##_24_8
+#define TAG(x) mga##x##_z24_s8
 #include "depthtmp.h"
 
 #define WRITE_STENCIL( _x, _y, d ) {                   \
 #define READ_STENCIL( d, _x, _y )              \
    d = *(GLuint *)(buf + _x*4 + _y*pitch) & 0xff;
 
-#define TAG(x) mga##x##_24_8
+#define TAG(x) mga##x##_z24_s8
 #include "stenciltmp.h"
 
 
-
-/*
- * This function is called to specify which buffer to read and write
- * for software rasterization (swrast) fallbacks.  This doesn't necessarily
- * correspond to glDrawBuffer() or glReadBuffer() calls.
- */
-static void mgaDDSetBuffer(GLcontext *ctx, GLframebuffer *buffer,
-                           GLuint bufferBit)
-{
-   mgaContextPtr mmesa = MGA_CONTEXT(ctx);
-   unsigned int   offset;
-
-   assert((bufferBit == BUFFER_BIT_FRONT_LEFT) || (bufferBit == BUFFER_BIT_BACK_LEFT));
-
-   offset = (bufferBit == BUFFER_BIT_FRONT_LEFT)
-       ? mmesa->mgaScreen->frontOffset
-       : mmesa->mgaScreen->backOffset;
-
-   mmesa->drawOffset = offset;
-   mmesa->readOffset = offset;
-
-   assert( (buffer == mmesa->driDrawable->driverPrivate)
-          || (buffer == mmesa->driReadable->driverPrivate) );
-
-   mmesa->mesa_drawable = (buffer == mmesa->driDrawable->driverPrivate)
-       ? mmesa->driDrawable : mmesa->driReadable;
-}
-
 void mgaSpanRenderStart( GLcontext *ctx )
 {
    mgaContextPtr mmesa = MGA_CONTEXT(ctx);
@@ -219,45 +187,7 @@ void mgaSpanRenderFinish( GLcontext *ctx )
  */
 void mgaDDInitSpanFuncs( GLcontext *ctx )
 {
-   mgaContextPtr mmesa = MGA_CONTEXT(ctx);
    struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
-
-   swdd->SetBuffer = mgaDDSetBuffer;
-
-   switch (mmesa->mgaScreen->cpp) {
-   case 2:
-#if 0
-      mgaInitPointers_565( swdd );
-      swdd->ReadDepthSpan = mgaReadDepthSpan_16;
-      swdd->WriteDepthSpan = mgaWriteDepthSpan_16;
-      swdd->ReadDepthPixels = mgaReadDepthPixels_16;
-      swdd->WriteDepthPixels = mgaWriteDepthPixels_16;
-#endif
-      break;
-
-   case 4:
-#if 0
-      mgaInitPointers_8888( swdd );
-
-      if (!mmesa->hw_stencil) {
-        swdd->ReadDepthSpan = mgaReadDepthSpan_32;
-        swdd->WriteDepthSpan = mgaWriteDepthSpan_32;
-        swdd->ReadDepthPixels = mgaReadDepthPixels_32;
-        swdd->WriteDepthPixels = mgaWriteDepthPixels_32;
-      } else {
-        swdd->ReadDepthSpan = mgaReadDepthSpan_24_8;
-        swdd->WriteDepthSpan = mgaWriteDepthSpan_24_8;
-        swdd->ReadDepthPixels = mgaReadDepthPixels_24_8;
-        swdd->WriteDepthPixels = mgaWriteDepthPixels_24_8;
-
-        swdd->ReadStencilSpan = mgaReadStencilSpan_24_8;
-        swdd->WriteStencilSpan = mgaWriteStencilSpan_24_8;
-        swdd->ReadStencilPixels = mgaReadStencilPixels_24_8;
-        swdd->WriteStencilPixels = mgaWriteStencilPixels_24_8;
-      }
-#endif
-      break;
-   }
    swdd->SpanRenderStart = mgaSpanRenderStart;
    swdd->SpanRenderFinish = mgaSpanRenderFinish;
 }
@@ -278,35 +208,15 @@ mgaSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
       }
    }
    else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
-      drb->Base.GetRow        = mgaReadDepthSpan_16;
-      drb->Base.GetValues     = mgaReadDepthPixels_16;
-      drb->Base.PutRow        = mgaWriteDepthSpan_16;
-      drb->Base.PutMonoRow    = mgaWriteMonoDepthSpan_16;
-      drb->Base.PutValues     = mgaWriteDepthPixels_16;
-      drb->Base.PutMonoValues = NULL;
+      mgaInitDepthPointers_z16(&drb->Base);
    }
    else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
-      drb->Base.GetRow        = mgaReadDepthSpan_24_8;
-      drb->Base.GetValues     = mgaReadDepthPixels_24_8;
-      drb->Base.PutRow        = mgaWriteDepthSpan_24_8;
-      drb->Base.PutMonoRow    = mgaWriteMonoDepthSpan_24_8;
-      drb->Base.PutValues     = mgaWriteDepthPixels_24_8;
-      drb->Base.PutMonoValues = NULL;
+      mgaInitDepthPointers_z24_s8(&drb->Base);
    }
    else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT32) {
-      drb->Base.GetRow        = mgaReadDepthSpan_32;
-      drb->Base.GetValues     = mgaReadDepthPixels_32;
-      drb->Base.PutRow        = mgaWriteDepthSpan_32;
-      drb->Base.PutMonoRow    = mgaWriteMonoDepthSpan_32;
-      drb->Base.PutValues     = mgaWriteDepthPixels_32;
-      drb->Base.PutMonoValues = NULL;
+      mgaInitDepthPointers_z32(&drb->Base);
    }
    else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
-      drb->Base.GetRow        = mgaReadStencilSpan_24_8;
-      drb->Base.GetValues     = mgaReadStencilPixels_24_8;
-      drb->Base.PutRow        = mgaWriteStencilSpan_24_8;
-      drb->Base.PutMonoRow    = mgaWriteMonoStencilSpan_24_8;
-      drb->Base.PutValues     = mgaWriteStencilPixels_24_8;
-      drb->Base.PutMonoValues = NULL;
+      mgaInitStencilPointers_z24_s8(&drb->Base);
    }
 }
index 72d5c9fb0829675e0d689f13815e380f87151e03..7ba3cdb776c86ed5f52981ec0de23da1b1d9067c 100644 (file)
@@ -845,11 +845,6 @@ static void mgaDDDrawBuffer(GLcontext *ctx, GLenum mode )
       FALLBACK( ctx, MGA_FALLBACK_DRAW_BUFFER, GL_TRUE );
       return;
    }
-
-   /* We want to update the s/w rast state too so that r200SetBuffer()
-    * gets called.
-    */
-   _swrast_DrawBuffer(ctx, mode);
 }
 
 
index e91257f7fc8fa40e2223263cdf45de72fe04063e..b3552ac763923aee9ae2cd20d677e1b6bcf02287 100644 (file)
@@ -177,11 +177,8 @@ struct r128_context {
     */
    GLuint doPageFlip;
 
-   /* Drawable, cliprect and scissor information
+   /* Cliprect and scissor information
     */
-   GLint drawOffset, drawPitch;
-   GLint readOffset, readPitch;
-
    GLuint numClipRects;                        /* Cliprects for the draw buffer */
    drm_clip_rect_t *pClipRects;
 
index fc017329ca2527a5b4075a654d6d7abd1860d840..150d62577ed1ae07132831bd6cd4590f560e6bad 100644 (file)
@@ -44,6 +44,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include "vblank.h"
 #include "mmio.h"
+#include "drirenderbuffer.h"
 
 #define R128_TIMEOUT        2048
 #define R128_IDLE_RETRY       32
@@ -373,16 +374,12 @@ void r128PageFlip( const __DRIdrawablePrivate *dPriv )
       exit( 1 );
    }
 
-   if ( rmesa->sarea->pfCurrentPage == 1 ) {
-        rmesa->drawOffset = rmesa->r128Screen->frontOffset;
-        rmesa->drawPitch  = rmesa->r128Screen->frontPitch;
-   } else {
-        rmesa->drawOffset = rmesa->r128Screen->backOffset;
-        rmesa->drawPitch  = rmesa->r128Screen->backPitch;
-   }
+   /* Get ready for drawing next frame.  Update the renderbuffers'
+    * flippedOffset/Pitch fields so we draw into the right place.
+    */
+   driFlipRenderbuffers(rmesa->glCtx->WinSysDrawBuffer,
+                        rmesa->sarea->pfCurrentPage);
 
-   rmesa->setup.dst_pitch_offset_c = (((rmesa->drawPitch/8) << 21) |
-                                     (rmesa->drawOffset >> 5));
    rmesa->new_state |= R128_NEW_WINDOW;
 
    /* FIXME: Do we need this anymore? */
index ea4ccfb2ec95b410b60f0f546709871dd7212c1e..ff11eb68480c19594745dba8628e65ecf81fee6b 100644 (file)
@@ -37,6 +37,9 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "r128_tex.h"
 #include "r128_state.h"
 
+#include "drirenderbuffer.h"
+
+
 #if DEBUG_LOCKING
 char *prevLockFile = NULL;
 int prevLockLine = 0;
@@ -48,28 +51,11 @@ int prevLockLine = 0;
 static void
 r128UpdatePageFlipping( r128ContextPtr rmesa )
 {
-   int use_back;
-
    rmesa->doPageFlip = rmesa->sarea->pfAllowPageFlip;
-
-   use_back = (rmesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_BACK_LEFT);
-   use_back ^= (rmesa->sarea->pfCurrentPage == 1);
-
-   if ( R128_DEBUG & DEBUG_VERBOSE_API )
-      fprintf(stderr, "%s allow %d current %d\n", __FUNCTION__, 
-             rmesa->doPageFlip,
-             rmesa->sarea->pfCurrentPage );
-
-   if ( use_back ) {
-        rmesa->drawOffset = rmesa->r128Screen->backOffset;
-        rmesa->drawPitch  = rmesa->r128Screen->backPitch;
-   } else {
-        rmesa->drawOffset = rmesa->r128Screen->frontOffset;
-        rmesa->drawPitch  = rmesa->r128Screen->frontPitch;
+   if (!rmesa->doPageFlip) {
+      driFlipRenderbuffers(rmesa->glCtx->WinSysDrawBuffer, GL_FALSE);
    }
 
-   rmesa->setup.dst_pitch_offset_c = (((rmesa->drawPitch/8) << 21) |
-                                      (rmesa->drawOffset >> 5));
    rmesa->new_state |= R128_NEW_WINDOW;
 }
 
index c6c598cc3b8b2ab37f16a87fad0c1dbe34a99d17..442eb6b9ecf54b1ce5c5d095d2813086417aa884 100644 (file)
@@ -271,14 +271,6 @@ r128CreateBuffer( __DRIscreenPrivate *driScrnPriv,
       return GL_FALSE; /* not implemented */
    }
    else {
-#if 0
-      driDrawPriv->driverPrivate = (void *) 
-         _mesa_create_framebuffer( mesaVis,
-                                   GL_FALSE,  /* software depth buffer? */
-                                   mesaVis->stencilBits > 0,
-                                   mesaVis->accumRedBits > 0,
-                                   mesaVis->alphaBits > 0 );
-#else
       struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
 
       {
@@ -320,7 +312,7 @@ r128CreateBuffer( __DRIscreenPrivate *driScrnPriv,
                                    GL_FALSE, /* alpha */
                                    GL_FALSE /* aux */);
       driDrawPriv->driverPrivate = (void *) fb;
-#endif
+
       return (driDrawPriv->driverPrivate != NULL);
    }
 }
index fd4722b3b36d170aa4e3fa86bb4957c8abf12e3a..e64282b8a7538df4e7b2cbbd4b75ac95b592aa23 100644 (file)
@@ -44,26 +44,20 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #define DBG 0
 
+#define GET_PTR(X,Y) (sPriv->pFB + drb->flippedOffset          \
+     + ((dPriv->y + (Y)) * drb->flippedPitch + (dPriv->x + (X))) * drb->cpp)
+
 #define HAVE_HW_DEPTH_SPANS    1
 #define HAVE_HW_DEPTH_PIXELS   1
 
 #define LOCAL_VARS                                                     \
    r128ContextPtr rmesa = R128_CONTEXT(ctx);                           \
-   r128ScreenPtr r128scrn = rmesa->r128Screen;                         \
    __DRIscreenPrivate *sPriv = rmesa->driScreen;                       \
    __DRIdrawablePrivate *dPriv = rmesa->driDrawable;                   \
-   GLuint pitch = r128scrn->frontPitch * r128scrn->cpp;                        \
+   driRenderbuffer *drb = (driRenderbuffer *) rb;                      \
    GLuint height = dPriv->h;                                           \
-   char *buf = (char *)(sPriv->pFB +                                   \
-                       rmesa->drawOffset +                             \
-                       (dPriv->x * r128scrn->cpp) +                    \
-                       (dPriv->y * pitch));                            \
-   char *read_buf = (char *)(sPriv->pFB +                              \
-                            rmesa->readOffset +                        \
-                            (dPriv->x * r128scrn->cpp) +               \
-                            (dPriv->y * pitch));                       \
    GLuint p;                                                           \
-   (void) read_buf; (void) buf; (void) p
+   (void) p;
 
 #define LOCAL_DEPTH_VARS                                               \
    r128ContextPtr rmesa = R128_CONTEXT(ctx);                           \
@@ -94,6 +88,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #define TAG(x)    r128##x##_RGB565
 #define TAG2(x,y) r128##x##_RGB565##y
+#define GET_SRC_PTR(X,Y) GET_PTR(X,Y)
+#define GET_DST_PTR(X,Y) GET_PTR(X,Y)
 #include "spantmp2.h"
 
 
@@ -104,6 +100,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #define TAG(x)    r128##x##_ARGB8888
 #define TAG2(x,y) r128##x##_ARGB8888##y
+#define GET_SRC_PTR(X,Y) GET_PTR(X,Y)
+#define GET_DST_PTR(X,Y) GET_PTR(X,Y)
 #include "spantmp2.h"
 
 
@@ -181,7 +179,7 @@ do {                                                                        \
    }                                                                   \
 } while (0)
 
-#define TAG(x) r128##x##_16
+#define TAG(x) r128##x##_z16
 #include "depthtmp.h"
 
 
@@ -254,7 +252,7 @@ do {                                                                        \
    }                                                                   \
 } while (0)
 
-#define TAG(x) r128##x##_24_8
+#define TAG(x) r128##x##_z24_s8
 #include "depthtmp.h"
 
 
@@ -266,41 +264,6 @@ do {                                                                       \
 /* FIXME: Add support for hardware stencil buffers.
  */
 
-/*
- * This function is called to specify which buffer to read and write
- * for software rasterization (swrast) fallbacks.  This doesn't necessarily
- * correspond to glDrawBuffer() or glReadBuffer() calls.
- */
-static void r128DDSetBuffer( GLcontext *ctx,
-                             GLframebuffer *colorBuffer,
-                             GLuint bufferBit )
-{
-   r128ContextPtr rmesa = R128_CONTEXT(ctx);
-
-   switch ( bufferBit ) {
-   case BUFFER_BIT_FRONT_LEFT:
-      if ( rmesa->sarea->pfCurrentPage == 1 ) {
-         rmesa->drawOffset = rmesa->readOffset = rmesa->r128Screen->backOffset;
-         rmesa->drawPitch  = rmesa->readPitch  = rmesa->r128Screen->backPitch;
-      } else {
-         rmesa->drawOffset = rmesa->readOffset = rmesa->r128Screen->frontOffset;
-         rmesa->drawPitch  = rmesa->readPitch  = rmesa->r128Screen->frontPitch;
-      }
-      break;
-   case BUFFER_BIT_BACK_LEFT:
-      if ( rmesa->sarea->pfCurrentPage == 1 ) {
-         rmesa->drawOffset = rmesa->readOffset = rmesa->r128Screen->frontOffset;
-         rmesa->drawPitch  = rmesa->readPitch  = rmesa->r128Screen->frontPitch;
-      } else {
-         rmesa->drawOffset = rmesa->readOffset = rmesa->r128Screen->backOffset;
-         rmesa->drawPitch  = rmesa->readPitch  = rmesa->r128Screen->backPitch;
-      }
-      break;
-   default:
-      break;
-   }
-}
-
 void r128SpanRenderStart( GLcontext *ctx )
 {
    r128ContextPtr rmesa = R128_CONTEXT(ctx);
@@ -318,10 +281,7 @@ void r128SpanRenderFinish( GLcontext *ctx )
 
 void r128DDInitSpanFuncs( GLcontext *ctx )
 {
-   r128ContextPtr rmesa = R128_CONTEXT(ctx);
    struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
-
-   swdd->SetBuffer = r128DDSetBuffer;
    swdd->SpanRenderStart       = r128SpanRenderStart;
    swdd->SpanRenderFinish      = r128SpanRenderFinish;
 }
@@ -342,27 +302,9 @@ r128SetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
       }
    }
    else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
-      drb->Base.GetRow        = r128ReadDepthSpan_16;
-      drb->Base.GetValues     = r128ReadDepthPixels_16;
-      drb->Base.PutRow        = r128WriteDepthSpan_16;
-      drb->Base.PutMonoRow    = r128WriteMonoDepthSpan_16;
-      drb->Base.PutValues     = r128WriteDepthPixels_16;
-      drb->Base.PutMonoValues = NULL;
+      r128InitDepthPointers_z16(&drb->Base);
    }
    else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
-      drb->Base.GetRow        = r128ReadDepthSpan_24_8;
-      drb->Base.GetValues     = r128ReadDepthPixels_24_8;
-      drb->Base.PutRow        = r128WriteDepthSpan_24_8;
-      drb->Base.PutMonoRow    = r128WriteMonoDepthSpan_24_8;
-      drb->Base.PutValues     = r128WriteDepthPixels_24_8;
-      drb->Base.PutMonoValues = NULL;
-   }
-   else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
-      drb->Base.GetRow        = NULL;
-      drb->Base.GetValues     = NULL;
-      drb->Base.PutRow        = NULL;
-      drb->Base.PutMonoRow    = NULL;
-      drb->Base.PutValues     = NULL;
-      drb->Base.PutMonoValues = NULL;
+      r128InitDepthPointers_z24_s8(&drb->Base);
    }
 }
index 29f490da89d984898b5de64d58887738595fec77..a1cb6aafeb23fb801555c19af910fd5f0c55f37c 100644 (file)
@@ -51,6 +51,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include "tnl/t_pipeline.h"
 
+#include "drirenderbuffer.h"
+
 
 /* =============================================================
  * Alpha blending
@@ -628,23 +630,29 @@ static void r128DDShadeModel( GLcontext *ctx, GLenum mode )
  * Window position
  */
 
-void r128UpdateWindow( GLcontext *ctx )
+static void r128UpdateWindow( GLcontext *ctx )
 {
    r128ContextPtr rmesa = R128_CONTEXT(ctx);
    int x = rmesa->driDrawable->x;
    int y = rmesa->driDrawable->y;
+   struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0][0];
+   driRenderbuffer *drb = (driRenderbuffer *) rb;
 
    rmesa->setup.window_xy_offset = ((y << R128_WINDOW_Y_SHIFT) |
                                    (x << R128_WINDOW_X_SHIFT));
 
+   rmesa->setup.dst_pitch_offset_c = (((drb->flippedPitch/8) << 21) |
+                                      (drb->flippedOffset >> 5));
+
+
    rmesa->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_WINDOW;
 }
 
+
 /* =============================================================
  * Viewport
  */
 
-
 static void r128CalcViewport( GLcontext *ctx )
 {
    r128ContextPtr rmesa = R128_CONTEXT(ctx);
@@ -729,13 +737,6 @@ static void r128DDDrawBuffer( GLcontext *ctx, GLenum mode )
       break;
    }
 
-   /* We want to update the s/w rast state too so that r128DDSetBuffer()
-    * gets called.
-    */
-   _swrast_DrawBuffer(ctx, mode);
-
-   rmesa->setup.dst_pitch_offset_c = (((rmesa->drawPitch/8) << 21) |
-                                      (rmesa->drawOffset >> 5));
    rmesa->new_state |= R128_NEW_WINDOW;
 }
 
@@ -1094,19 +1095,8 @@ void r128DDInitState( r128ContextPtr rmesa )
 
    rmesa->Fallback = 0;
 
-   if ( rmesa->glCtx->Visual.doubleBufferMode && rmesa->sarea->pfCurrentPage == 0 ) {
-      rmesa->drawOffset = rmesa->readOffset = rmesa->r128Screen->backOffset;
-      rmesa->drawPitch  = rmesa->readPitch  = rmesa->r128Screen->backPitch;
-   } else {
-      rmesa->drawOffset = rmesa->readOffset = rmesa->r128Screen->frontOffset;
-      rmesa->drawPitch  = rmesa->readPitch  = rmesa->r128Screen->frontPitch;
-   }
-
-   /* Harware state:
+   /* Hardware state:
     */
-   rmesa->setup.dst_pitch_offset_c = (((rmesa->drawPitch/8) << 21) |
-                                     (rmesa->drawOffset >> 5));
-
    rmesa->setup.dp_gui_master_cntl_c = (R128_GMC_DST_PITCH_OFFSET_CNTL |
                                        R128_GMC_DST_CLIPPING |
                                        R128_GMC_BRUSH_SOLID_COLOR |
index ac33853b167705f296b03aaa132fcd77dfecc738..6f0a6a6557348e1c9a6ace32e399dd0bd370c655 100644 (file)
@@ -44,8 +44,6 @@ extern void r128DDInitStateFuncs( GLcontext *ctx );
 extern void r128DDUpdateState( GLcontext *ctx );
 extern void r128DDUpdateHWState( GLcontext *ctx );
 
-extern void r128UpdateWindow( GLcontext *ctx );
-
 extern void r128EmitHwStateLocked( r128ContextPtr rmesa );
 
 #endif
index b94fee6a8eebc31aad88493b727e776b5e9cb7fb..4b409fbf374722666ade0d8b584bd8064f69aef5 100644 (file)
@@ -162,7 +162,6 @@ void s3vEmitHwState( s3vContextPtr vmesa );
 void s3vGetLock( s3vContextPtr vmesa, GLuint flags );
 void s3vInitExtensions( GLcontext *ctx );
 void s3vInitDriverFuncs( GLcontext *ctx );
-void s3vInitSpanFuncs( GLcontext *ctx );
 void s3vSetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis);
 void s3vInitState( s3vContextPtr vmesa );
 void s3vInitHW( s3vContextPtr vmesa );
index 49135a9c3ffe78c8b13986f14fb8b943b2a6eebc..b8ebd5f30ec3226e51bbe4e47e40a66eaf93a75a 100644 (file)
 #define DBG 0
 
 #define LOCAL_VARS \
-       s3vContextPtr vmesa = S3V_CONTEXT(ctx); \
-       s3vScreenPtr s3vscrn = vmesa->s3vScreen; \
-       __DRIscreenPrivate *sPriv = vmesa->driScreen; \
-       __DRIdrawablePrivate *dPriv = vmesa->driDrawable; \
-       GLuint pitch = ( (vmesa->Flags & S3V_BACK_BUFFER) ? \
-                       ((dPriv->w+31)&~31) * s3vscrn->cpp \
-                       : sPriv->fbWidth * s3vscrn->cpp); \
-       GLuint height = dPriv->h; \
-       char *buf = ( (vmesa->Flags & S3V_BACK_BUFFER) ? \
-                       (char *)(sPriv->pFB + vmesa->drawOffset) \
-                       : (char *)(sPriv->pFB + vmesa->drawOffset \
-                         + dPriv->x * s3vscrn->cpp + dPriv->y * pitch) ); \
-       char *read_buf = ( (vmesa->Flags & S3V_BACK_BUFFER) ? \
-                       (char *)(sPriv->pFB + vmesa->drawOffset) \
-                       : (char *)(sPriv->pFB + vmesa->drawOffset \
-                         + dPriv->x * s3vscrn->cpp + dPriv->y * pitch) ); \
+       s3vContextPtr vmesa = S3V_CONTEXT(ctx);                         \
+       __DRIscreenPrivate *sPriv = vmesa->driScreen;                   \
+       __DRIdrawablePrivate *dPriv = vmesa->driDrawable;               \
+       driRenderbuffer *drb = (driRenderbuffer *) rb;                  \
+       GLuint cpp = drb->cpp;                                          \
+       GLuint pitch = ( (drb->backBuffer) ?                            \
+                       ((dPriv->w+31)&~31) * cpp                       \
+                       : sPriv->fbWidth * cpp);                        \
+       GLuint height = dPriv->h;                                       \
+       char *buf = (char *)(sPriv->pFB + drb->offset                   \
+          + (drb->backBuffer ? 0 : dPriv->x * cpp + dPriv->y * pitch));\
+       char *read_buf = buf;                                           \
        GLuint p; \
        (void) read_buf; (void) buf; (void) p; (void) pitch
 
 /* FIXME! Depth/Stencil read/writes don't work ! */
-#define LOCAL_DEPTH_VARS \
-       s3vScreenPtr s3vscrn = vmesa->s3vScreen; \
-       __DRIdrawablePrivate *dPriv = vmesa->driDrawable; \
-       __DRIscreenPrivate *sPriv = vmesa->driScreen; \
-       GLuint pitch = s3vscrn->depthPitch; \
-       GLuint height = dPriv->h; \
-       char *buf = (char *)(sPriv->pFB + \
-                       s3vscrn->depthOffset); /* + \   
-                       dPriv->x * s3vscrn->cpp + \
-                       dPriv->y * pitch)*/ \
+#define LOCAL_DEPTH_VARS                                       \
+       __DRIdrawablePrivate *dPriv = vmesa->driDrawable;       \
+       __DRIscreenPrivate *sPriv = vmesa->driScreen;           \
+       driRenderbuffer *drb = (driRenderbuffer *) rb;          \
+       GLuint pitch = drb->pitch;                              \
+       GLuint height = dPriv->h;                               \
+       char *buf = (char *)(sPriv->pFB + drb->offset);         \
        (void) pitch
 
 #define LOCAL_STENCIL_VARS     LOCAL_DEPTH_VARS
@@ -81,8 +74,8 @@ do { \
    *(GLushort *)(buf + _x*2 + _y*pitch) = ((((int)r & 0xf8) << 7) | \
                                           (((int)g & 0xf8) << 2) | \
                                           (((int)b & 0xf8) >> 3)); \
-   DEBUG(("buf=0x%x drawOffset=0x%x dPriv->x=%i s3vscrn->cpp=%i dPriv->y=%i pitch=%i\n", \
-       sPriv->pFB, vmesa->drawOffset, dPriv->x, s3vscrn->cpp, dPriv->y, pitch)); \
+   DEBUG(("buf=0x%x drawOffset=0x%x dPriv->x=%i drb->cpp=%i dPriv->y=%i pitch=%i\n", \
+       sPriv->pFB, vmesa->drawOffset, dPriv->x, drb->cpp, dPriv->y, pitch)); \
    DEBUG(("dPriv->w = %i\n", dPriv->w)); \
 } while(0)
 
@@ -142,7 +135,7 @@ do { \
 #define READ_DEPTH( d, _x, _y ) \
    d = *(GLushort *)(buf + _x*2 + _y*dPriv->w*2);
 
-#define TAG(x) s3v##x##_16
+#define TAG(x) s3v##x##_z16
 #include "depthtmp.h"
 
 
@@ -194,92 +187,6 @@ do { \
 
 #endif
 
-static void s3vSetBuffer( GLcontext *ctx, GLframebuffer *colorBuffer,
-                         GLuint bufferBit )
-{
-   s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-
-   switch ( bufferBit ) {
-   case BUFFER_BIT_FRONT_LEFT:
-      vmesa->drawOffset = vmesa->readOffset = 0;
-      break;
-   case BUFFER_BIT_BACK_LEFT:
-      vmesa->drawOffset = vmesa->readOffset = vmesa->driScreen->fbHeight *
-                                              vmesa->driScreen->fbWidth *
-                                              vmesa->s3vScreen->cpp; 
-      break;
-   }
-}
-
-
-void s3vInitSpanFuncs( GLcontext *ctx )
-{
-   s3vContextPtr vmesa = S3V_CONTEXT(ctx);
-   struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
-
-   swdd->SetBuffer = s3vSetBuffer;
-
-#if 0
-   switch ( vmesa->s3vScreen->cpp ) {
-   case 2:
-      swdd->WriteRGBASpan      = s3vWriteRGBASpan_RGB555;
-      swdd->WriteRGBSpan       = s3vWriteRGBSpan_RGB555;
-      swdd->WriteMonoRGBASpan  = s3vWriteMonoRGBASpan_RGB555;
-      swdd->WriteRGBAPixels    = s3vWriteRGBAPixels_RGB555;
-      swdd->WriteMonoRGBAPixels        = s3vWriteMonoRGBAPixels_RGB555;
-      swdd->ReadRGBASpan       = s3vReadRGBASpan_RGB555;
-      swdd->ReadRGBAPixels      = s3vReadRGBAPixels_RGB555;
-      break;
-
-   case 4:
-      swdd->WriteRGBASpan      = s3vWriteRGBASpan_ARGB8888;
-      swdd->WriteRGBSpan       = s3vWriteRGBSpan_ARGB8888;
-      swdd->WriteMonoRGBASpan   = s3vWriteMonoRGBASpan_ARGB8888;
-      swdd->WriteRGBAPixels     = s3vWriteRGBAPixels_ARGB8888;
-      swdd->WriteMonoRGBAPixels = s3vWriteMonoRGBAPixels_ARGB8888;
-#if 1
-      swdd->ReadRGBASpan    = s3vReadRGBASpan_ARGB8888;
-#else
-      swdd->ReadRGBASpan    = s3vReadRGBASpan8888;
-#endif
-      swdd->ReadRGBAPixels  = s3vReadRGBAPixels_ARGB8888;
-      break;
-
-   default:
-      break;
-   }
-#endif
-
-   switch ( vmesa->glCtx->Visual.depthBits ) {
-   case 15:
-   case 16:
-#if 0
-      swdd->ReadDepthSpan      = s3vReadDepthSpan_16;
-      swdd->WriteDepthSpan     = s3vWriteDepthSpan_16;
-      swdd->ReadDepthPixels    = s3vReadDepthPixels_16;
-      swdd->WriteDepthPixels   = s3vWriteDepthPixels_16;
-#endif
-      break;
-
-#if 0
-   case 24:
-      swdd->ReadDepthSpan      = s3vReadDepthSpan_24_8;
-      swdd->WriteDepthSpan     = s3vWriteDepthSpan_24_8;
-      swdd->ReadDepthPixels    = s3vReadDepthPixels_24_8;
-      swdd->WriteDepthPixels   = s3vWriteDepthPixels_24_8;
-
-      swdd->ReadStencilSpan    = s3vReadStencilSpan_24_8;
-      swdd->WriteStencilSpan   = s3vWriteStencilSpan_24_8;
-      swdd->ReadStencilPixels  = s3vReadStencilPixels_24_8;
-      swdd->WriteStencilPixels = s3vWriteStencilPixels_24_8;
-      break;
-#endif
-
-   default:
-      break;
-   }
-}
-
 
 /**
  * Plug in the Get/Put routines for the given driRenderbuffer.
@@ -308,27 +215,12 @@ s3vSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
       }
    }
    else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
-      drb->Base.GetRow        = s3vReadDepthSpan_16;
-      drb->Base.GetValues     = s3vReadDepthPixels_16;
-      drb->Base.PutRow        = s3vWriteDepthSpan_16;
-      drb->Base.PutMonoRow    = s3vWriteMonoDepthSpan_16;
-      drb->Base.PutValues     = s3vWriteDepthPixels_16;
-      drb->Base.PutMonoValues = NULL;
+      s3vInitDepthPointers_z16(&drb->Base);
    }
    else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
-      drb->Base.GetRow = NULL;
-      drb->Base.GetValues = NULL;
-      drb->Base.PutRow = NULL;
-      drb->Base.PutMonoRow = NULL;
-      drb->Base.PutValues = NULL;
-      drb->Base.PutMonoValues = NULL;
+      /* not done yet */
    }
    else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
-      drb->Base.GetRow = NULL;
-      drb->Base.GetValues = NULL;
-      drb->Base.PutRow = NULL;
-      drb->Base.PutMonoRow = NULL;
-      drb->Base.PutValues = NULL;
-      drb->Base.PutMonoValues = NULL;
+      /* not done yet */
    }
 }
index 4cdda1b58714e9612d89c3df36cfca8edfa2844e..603c4168b503d33d8bc517184a83f252dfdaf305 100644 (file)
@@ -90,6 +90,7 @@ s3vCreateBuffer( __DRIscreenPrivate *driScrnPriv,
                                  screen->backOffset, screen->backPitch);
          s3vSetSpanFunctions(backRb, mesaVis);
          _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
+         backRb->backBuffer = GL_TRUE;
       }
 
       if (mesaVis->depthBits == 16) {
index 12cf78535ad286c966dceab4d881188c6c730617..477564cad3b13f427cda9fe108951c317439d4e5 100644 (file)
@@ -634,6 +634,8 @@ savageCreateBuffer( __DRIscreenPrivate *driScrnPriv,
                                  screen->frontOffset, screen->aperturePitch);
          savageSetSpanFunctions(frontRb, mesaVis, float_depth);
          _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
+         frontRb->Base.Data = frontRb->flippedData
+            = (GLubyte *) screen->aperture.map + 0x01000000 * TARGET_FRONT;
       }
 
       if (mesaVis->doubleBufferMode) {
@@ -642,26 +644,32 @@ savageCreateBuffer( __DRIscreenPrivate *driScrnPriv,
                                  screen->backOffset, screen->aperturePitch);
          savageSetSpanFunctions(backRb, mesaVis, float_depth);
          _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
+         backRb->Base.Data = backRb->flippedData
+            = (GLubyte *) screen->aperture.map + 0x01000000 * TARGET_BACK;
       }
 
       if (mesaVis->depthBits == 16) {
          driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT16, screen->cpp,
+            = driNewRenderbuffer(GL_DEPTH_COMPONENT16, screen->zpp,
                                  screen->depthOffset, screen->aperturePitch);
          savageSetSpanFunctions(depthRb, mesaVis, float_depth);
          _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+         depthRb->Base.Data = depthRb->flippedData
+            = (GLubyte *) screen->aperture.map + 0x01000000 * TARGET_DEPTH;
       }
       else if (mesaVis->depthBits == 24) {
          driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT24, screen->cpp,
+            = driNewRenderbuffer(GL_DEPTH_COMPONENT24, screen->zpp,
                                  screen->depthOffset, screen->aperturePitch);
          savageSetSpanFunctions(depthRb, mesaVis, float_depth);
          _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+         depthRb->Base.Data = depthRb->flippedData
+            = (GLubyte *) screen->aperture.map + 0x01000000 * TARGET_DEPTH;
       }
 
       if (mesaVis->stencilBits > 0 && !swStencil) {
          driRenderbuffer *stencilRb
-            = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT, screen->cpp,
+            = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT, screen->zpp,
                                  screen->depthOffset, screen->aperturePitch);
          savageSetSpanFunctions(stencilRb, mesaVis, float_depth);
          _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);
@@ -805,16 +813,25 @@ savageMakeCurrent(__DRIcontextPrivate *driContextPriv,
                  __DRIdrawablePrivate *driReadPriv)
 {
    if (driContextPriv) {
-      savageContextPtr imesa = (savageContextPtr) driContextPriv->driverPrivate;
-      
+      savageContextPtr imesa
+         = (savageContextPtr) driContextPriv->driverPrivate;
+      struct gl_framebuffer *drawBuffer
+         = (GLframebuffer *) driDrawPriv->driverPrivate;
+      struct gl_framebuffer *readBuffer
+         = (GLframebuffer *) driReadPriv->driverPrivate;
+      driRenderbuffer *frontRb = (driRenderbuffer *)
+         drawBuffer->Attachment[BUFFER_FRONT_LEFT].Renderbuffer;
+      driRenderbuffer *backRb = (driRenderbuffer *)
+         drawBuffer->Attachment[BUFFER_BACK_LEFT].Renderbuffer;
+
+      assert(frontRb->Base.Data);
+      assert(backRb->Base.Data);
+
       imesa->driReadable = driReadPriv;
       imesa->driDrawable = driDrawPriv;
-      imesa->mesa_drawable = driDrawPriv;
       imesa->dirty = ~0;
       
-      _mesa_make_current(imesa->glCtx,
-                         (GLframebuffer *) driDrawPriv->driverPrivate,
-                         (GLframebuffer *) driReadPriv->driverPrivate);
+      _mesa_make_current(imesa->glCtx, drawBuffer, readBuffer);
       
       savageXMesaWindowMoved( imesa );
    }
index 4c0959968518cf9bbc6cacfe3dcd62a9b00707a6..c4573b0da41aa45f13ef25f1bed2a331b18a9bc5 100644 (file)
@@ -236,8 +236,6 @@ struct savage_context_t {
 
     /* These refer to the current draw (front vs. back) buffer:
      */
-    GLubyte *drawMap;          /* draw buffer address in virtual mem */
-    GLubyte *readMap;  
     int drawX;                 /* origin of drawable in draw buffer */
     int drawY;
     GLuint numClipRects;               /* cliprects for that buffer */
@@ -277,13 +275,6 @@ struct savage_context_t {
     __DRIdrawablePrivate *driDrawable;
     __DRIdrawablePrivate *driReadable;
 
-    /**
-     * Drawable used by Mesa for software fallbacks for reading and
-     * writing.  It is set by Mesa's \c SetBuffer callback, and will always be
-     * either \c mga_context_t::driDrawable or \c mga_context_t::driReadable.
-     */
-    __DRIdrawablePrivate *mesa_drawable;
-
     __DRIscreenPrivate *driScreen;
     savageScreenPrivate *savageScreen; 
     drm_savage_sarea_t *sarea;
index 30d008e1be883d2d837f50f5d69aa031f7177487..1906c78cc345e0de79928fc3abb755487481dae6 100644 (file)
@@ -254,9 +254,9 @@ static void savage_BCI_swap(savageContextPtr imesa)
         else
             imesa->toggle = TARGET_BACK; 
         
-        imesa->drawMap = (char *)imesa->apertureBase[imesa->toggle];
-        imesa->readMap = (char *)imesa->apertureBase[imesa->toggle];
-        
+        driFlipRenderbuffers(imesa->glCtx->DrawBuffer,
+                             imesa->toggle != TARGET_FRONT);
+
         imesa->regs.s4.destCtrl.ni.offset = imesa->savageScreen->backOffset>>11;
         imesa->dirty |= SAVAGE_UPLOAD_GLOBAL;
         bciptr = SAVAGE_GET_BCI_POINTER(imesa,3);
index 2158391c103e2fd43be91635b5cb418ece6e0355..6396332794fd6525ecbd25ce3c30013c127bcde4 100644 (file)
 
 #define DBG 0
 
-#define LOCAL_VARS                                     \
-   savageContextPtr imesa = SAVAGE_CONTEXT(ctx);       \
-   __DRIdrawablePrivate *dPriv = imesa->mesa_drawable; \
-   savageScreenPrivate *savageScreen = imesa->savageScreen;    \
-   GLuint cpp   = savageScreen->cpp;                   \
-   GLuint pitch = imesa->aperturePitch;                        \
-   GLuint height = dPriv->h;                           \
-   GLubyte *buf = map +                                        \
-                 dPriv->x * cpp +                      \
-                 dPriv->y * pitch;                     \
-   GLubyte *read_buf = buf;                            \
-   GLuint p;                                           \
+#define LOCAL_VARS                                             \
+   savageContextPtr imesa = SAVAGE_CONTEXT(ctx);               \
+   __DRIdrawablePrivate *dPriv = imesa->driDrawable;           \
+   driRenderbuffer *drb = (driRenderbuffer *) rb;              \
+   GLuint cpp   = drb->cpp;                                    \
+   GLuint pitch = drb->pitch;                                  \
+   GLuint height = dPriv->h;                                   \
+   GLubyte *buf = drb->Base.Data + dPriv->x * cpp + dPriv->y * pitch;  \
+   GLubyte *read_buf = buf;                                    \
+   GLuint p;                                                   \
    (void) p; (void) read_buf;
 
-#define LOCAL_DEPTH_VARS                               \
-   savageContextPtr imesa = SAVAGE_CONTEXT(ctx);       \
-   __DRIdrawablePrivate *dPriv = imesa->mesa_drawable; \
-   savageScreenPrivate *savageScreen = imesa->savageScreen;    \
-   GLuint zpp   = savageScreen->zpp;                   \
-   GLuint pitch = imesa->aperturePitch;                        \
-   GLuint height = dPriv->h;                           \
-   GLubyte *buf = imesa->apertureBase[TARGET_DEPTH] +  \
-                 dPriv->x * zpp +                      \
-                 dPriv->y * pitch
+#define LOCAL_DEPTH_VARS                                       \
+   savageContextPtr imesa = SAVAGE_CONTEXT(ctx);               \
+   __DRIdrawablePrivate *dPriv = imesa->driDrawable;           \
+   driRenderbuffer *drb = (driRenderbuffer *) rb;              \
+   GLuint zpp   = drb->cpp;                                    \
+   GLuint pitch = drb->pitch;                                  \
+   GLuint height = dPriv->h;                                   \
+   GLubyte *buf = drb->Base.Data + dPriv->x * zpp + dPriv->y * pitch;
 
 #define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
 
 
 #define HW_UNLOCK()
 
-#define HW_WRITE_LOCK()                                        \
-       savageContextPtr imesa = SAVAGE_CONTEXT(ctx);   \
-       GLubyte *map = imesa->drawMap;
+#define HW_WRITE_LOCK()
 
-#define HW_READ_LOCK()                                 \
-       savageContextPtr imesa = SAVAGE_CONTEXT(ctx);   \
-       GLubyte *map = imesa->readMap;
+#define HW_READ_LOCK()
 
 
 /* 16 bit, 565 rgb color spanline and pixel functions
 #define READ_DEPTH( d, _x, _y ) \
     d = 0xFFFF - *(GLushort *)(buf + ((_x)<<1) + (_y)*pitch)
 
-#define TAG(x) savage##x##_16
+#define TAG(x) savage##x##_z16
 #include "depthtmp.h"
 
 
         savageDecodeFloat16( *(GLushort *)(buf + ((_x)<<1) + (_y)*pitch) ) * \
        65535.0
 
-#define TAG(x) savage##x##_16f
+#define TAG(x) savage##x##_z16f
 #include "depthtmp.h"
 
 
 #define READ_DEPTH( d, _x, _y )        \
    d = 0x00FFFFFF - (*(GLuint *)(buf + ((_x)<<2) + (_y)*pitch) & 0x00FFFFFF)
 
-#define TAG(x) savage##x##_8_24
+#define TAG(x) savage##x##_s8_z24
 #include "depthtmp.h"
 
 
        *(GLuint *)(buf + ((_x)<<2) + (_y)*pitch) & 0x00FFFFFF) \
        * 16777215.0
 
-#define TAG(x) savage##x##_8_24f
+#define TAG(x) savage##x##_s8_z24f
 #include "depthtmp.h"
 
 
 #define READ_STENCIL( d, _x, _y ) \
    d = (GLstencil)((*(GLuint *)(buf + ((_x)<<2) + (_y)*pitch) & 0xFF000000) >> 24)
 
-#define TAG(x) savage##x##_8_24
+#define TAG(x) savage##x##_s8_z24
 #include "stenciltmp.h"
 
 
-/*
- * This function is called to specify which buffer to read and write
- * for software rasterization (swrast) fallbacks.  This doesn't necessarily
- * correspond to glDrawBuffer() or glReadBuffer() calls.
- */
-static void savageDDSetBuffer(GLcontext *ctx, GLframebuffer *buffer,
-                             GLuint bufferBit)
-{
-   savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
-   GLubyte *map;
-
-   assert((bufferBit == BUFFER_BIT_FRONT_LEFT) || (bufferBit == BUFFER_BIT_BACK_LEFT));
-
-   map = (bufferBit == BUFFER_BIT_FRONT_LEFT)
-       ? imesa->apertureBase[TARGET_FRONT]
-       : imesa->apertureBase[TARGET_BACK];
-
-   imesa->drawMap = map;
-   imesa->readMap = map;
-
-   assert( (buffer == imesa->driDrawable->driverPrivate)
-          || (buffer == imesa->driReadable->driverPrivate) );
-
-   imesa->mesa_drawable = (buffer == imesa->driDrawable->driverPrivate)
-       ? imesa->driDrawable : imesa->driReadable;
-}
 
 /*
  * Wrappers around _swrast_Copy/Draw/ReadPixels that make sure all
@@ -267,8 +233,6 @@ static void savageSpanRenderStart( GLcontext *ctx )
 void savageDDInitSpanFuncs( GLcontext *ctx )
 {
    struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
-
-   swdd->SetBuffer = savageDDSetBuffer;
    swdd->SpanRenderStart = savageSpanRenderStart;
 
    /* Pixel path fallbacks.
@@ -299,44 +263,21 @@ savageSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis,
    }
    else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
       if (float_depth) {
-         drb->Base.GetRow        = savageReadDepthSpan_16f;
-         drb->Base.GetValues     = savageReadDepthPixels_16f;
-         drb->Base.PutRow        = savageWriteDepthSpan_16f;
-         drb->Base.PutMonoRow    = savageWriteMonoDepthSpan_16f;
-         drb->Base.PutValues     = savageWriteDepthPixels_16f;
+         savageInitDepthPointers_z16f(&drb->Base);
       }
       else {
-         drb->Base.GetRow        = savageReadDepthSpan_16;
-         drb->Base.GetValues     = savageReadDepthPixels_16;
-         drb->Base.PutRow        = savageWriteDepthSpan_16;
-         drb->Base.PutMonoRow    = savageWriteMonoDepthSpan_16;
-         drb->Base.PutValues     = savageWriteDepthPixels_16;
+         savageInitDepthPointers_z16(&drb->Base);
       }
-      drb->Base.PutMonoValues = NULL;
    }
    else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
       if (float_depth) {
-         drb->Base.GetRow        = savageReadDepthSpan_8_24f;
-         drb->Base.GetValues     = savageReadDepthPixels_8_24f;
-         drb->Base.PutRow        = savageWriteDepthSpan_8_24f;
-         drb->Base.PutMonoRow    = savageWriteMonoDepthSpan_8_24f;
-         drb->Base.PutValues     = savageWriteDepthPixels_8_24f;
+         savageInitDepthPointers_s8_z24f(&drb->Base);
       }
       else {
-         drb->Base.GetRow        = savageReadDepthSpan_8_24;
-         drb->Base.GetValues     = savageReadDepthPixels_8_24;
-         drb->Base.PutRow        = savageWriteDepthSpan_8_24;
-         drb->Base.PutMonoRow    = savageWriteMonoDepthSpan_8_24;
-         drb->Base.PutValues     = savageWriteDepthPixels_8_24;
+         savageInitDepthPointers_s8_z24(&drb->Base);
       }
-      drb->Base.PutMonoValues = NULL;
    }
    else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
-      drb->Base.GetRow        = savageReadStencilSpan_8_24;
-      drb->Base.GetValues     = savageReadStencilPixels_8_24;
-      drb->Base.PutRow        = savageWriteStencilSpan_8_24;
-      drb->Base.PutMonoRow    = savageWriteMonoStencilSpan_8_24;
-      drb->Base.PutValues     = savageWriteStencilPixels_8_24;
-      drb->Base.PutMonoValues = NULL;
+      savageInitStencilPointers_s8_z24(&drb->Base);
    }
 }
index 996d5b917177338a7a7fa778faa4d087a54d9cea..4affe8799b960f13bea1910a9dc553c69bcb12fb 100644 (file)
@@ -665,11 +665,6 @@ static void savageDDDrawBuffer(GLcontext *ctx, GLenum mode )
        return;
     }
     
-    /* We want to update the s/w rast state too so that r200SetBuffer() (?)
-     * gets called.
-     */
-    _swrast_DrawBuffer(ctx, mode);
-
     if (destCtrl != imesa->regs.s4.destCtrl.ui)
         imesa->dirty |= SAVAGE_UPLOAD_GLOBAL;
 }
@@ -1663,8 +1658,6 @@ void savageDDInitState( savageContextPtr imesa ) {
         imesa->regs.s4.destCtrl.ni.dstWidthInTile =
             (imesa->savageScreen->width+31)>>5;
     }
-    imesa->drawMap = imesa->apertureBase[imesa->toggle];
-    imesa->readMap = imesa->apertureBase[imesa->toggle];
     imesa->NotFirstFrame = GL_FALSE;
 
     imesa->regs.s4.zBufOffset.ni.offset=imesa->savageScreen->depthOffset>>11;
index 36754022215dc174da2bfdedff0db4facaec596f..fee8f6ead11c7ad3222a3297860c93755dbed544 100644 (file)
@@ -345,7 +345,6 @@ struct sis_context
   /* Drawable, cliprect and scissor information
    */
   GLint drawOffset, drawPitch;
-  GLint readOffset, readPitch;
 
   /* Mirrors of some DRI state
    */
index 8815d0e83266bb7e1cbadaf3fa85bb1ae0072026..dcbf62640b8952e9d27d6dfa987dc371aeee01ae 100644 (file)
@@ -209,14 +209,7 @@ sisCreateBuffer( __DRIscreenPrivate *driScrnPriv,
    if (isPixmap)
       return GL_FALSE; /* not implemented */
 
-#if 0
-   driDrawPriv->driverPrivate = (void *)_mesa_create_framebuffer(
-                                mesaVis,
-                                GL_FALSE,  /* software depth buffer? */
-                                mesaVis->stencilBits > 0,
-                                mesaVis->accumRedBits > 0,
-                                mesaVis->alphaBits > 0 ); /* XXX */
-#else
+   {
       struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
 
       /* XXX double-check the Offset/Pitch parameters! */
@@ -275,7 +268,7 @@ sisCreateBuffer( __DRIscreenPrivate *driScrnPriv,
                                    GL_FALSE, /* alpha */
                                    GL_FALSE /* aux */);
       driDrawPriv->driverPrivate = (void *) fb;
-#endif
+   }
 
    return (driDrawPriv->driverPrivate != NULL);
 }
index f0cf771d6161774e0b29cda014f8a00a81de395a..5e3d7b9e4e881b89c64e57ab5ed460f294183005 100644 (file)
@@ -44,9 +44,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define LOCAL_VARS                                                     \
    sisContextPtr smesa = SIS_CONTEXT(ctx);                             \
    __DRIdrawablePrivate *dPriv = smesa->driDrawable;                   \
-   GLuint pitch = smesa->drawPitch;                                    \
-   char *buf = (char *)(smesa->FbBase + smesa->drawOffset);            \
-   char *read_buf = (char *)(smesa->FbBase + smesa->readOffset);       \
+   driRenderbuffer *drb = (driRenderbuffer *) rb;                      \
+   GLuint pitch = drb->pitch;                                          \
+   char *buf = (char *)(smesa->FbBase + drb->offset);                  \
+   char *read_buf = buf;                                               \
    GLuint p;                                                           \
    (void) read_buf; (void) buf; (void) p
 
@@ -89,7 +90,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define READ_DEPTH( d, _x, _y )                \
    d = *(GLushort *)(buf + (_x)*2 + (_y)*smesa->depthPitch);
 
-#define TAG(x) sis##x##_16
+#define TAG(x) sis##x##_z16
 #include "depthtmp.h"
 
 
@@ -101,7 +102,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define READ_DEPTH( d, _x, _y )                \
    d = *(GLuint *)(buf + (_x)*4 + (_y)*smesa->depthPitch);
 
-#define TAG(x) sis##x##_32
+#define TAG(x) sis##x##_z32
 #include "depthtmp.h"
 
 
@@ -118,7 +119,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
    d = *(GLuint *)(buf + (_x)*4 + (_y)*smesa->depthPitch) & 0x00ffffff; \
 }
 
-#define TAG(x) sis##x##_24_8
+#define TAG(x) sis##x##_z24_s8
 #include "depthtmp.h"
 
 #define WRITE_STENCIL( _x, _y, d ) {                           \
@@ -131,33 +132,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define READ_STENCIL( d, _x, _y )                      \
    d = (*(GLuint *)(buf + (_x)*4 + (_y)*smesa->depthPitch) & 0xff000000) >> 24;
 
-#define TAG(x) sis##x##_24_8
+#define TAG(x) sis##x##_z24_s8
 #include "stenciltmp.h"
 
-/*
- * This function is called to specify which buffer to read and write
- * for software rasterization (swrast) fallbacks.  This doesn't necessarily
- * correspond to glDrawBuffer() or glReadBuffer() calls.
- */
-static void sisDDSetBuffer( GLcontext *ctx,
-                            GLframebuffer *colorBuffer,
-                            GLuint bufferBit )
-{
-   sisContextPtr smesa = SIS_CONTEXT(ctx);
 
-   switch ( bufferBit ) {
-   case BUFFER_BIT_FRONT_LEFT:
-      smesa->drawOffset = smesa->readOffset = smesa->frontOffset;
-      smesa->drawPitch  = smesa->readPitch  = smesa->frontPitch;
-      break;
-   case BUFFER_BIT_BACK_LEFT:
-      smesa->drawOffset = smesa->readOffset = smesa->backOffset;
-      smesa->drawPitch  = smesa->readPitch  = smesa->backPitch;
-      break;
-   default:
-      break;
-   }
-}
 
 void sisSpanRenderStart( GLcontext *ctx )
 {
@@ -180,8 +158,6 @@ void
 sisDDInitSpanFuncs( GLcontext *ctx )
 {
    struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
-
-   swdd->SetBuffer = sisDDSetBuffer;
    swdd->SpanRenderStart   = sisSpanRenderStart;
    swdd->SpanRenderFinish  = sisSpanRenderFinish; 
 }
@@ -203,35 +179,15 @@ sisSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
       }
    }
    else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
-      drb->Base.GetRow        = sisReadDepthSpan_16;
-      drb->Base.GetValues     = sisReadDepthPixels_16;
-      drb->Base.PutRow        = sisWriteDepthSpan_16;
-      drb->Base.PutMonoRow    = sisWriteMonoDepthSpan_16;
-      drb->Base.PutValues     = sisWriteDepthPixels_16;
-      drb->Base.PutMonoValues = NULL;
+      sisInitDepthPointers_z16(&drb->Base);
    }
    else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
-      drb->Base.GetRow        = sisReadDepthSpan_24_8;
-      drb->Base.GetValues     = sisReadDepthPixels_24_8;
-      drb->Base.PutRow        = sisWriteDepthSpan_24_8;
-      drb->Base.PutMonoRow    = sisWriteMonoDepthSpan_24_8;
-      drb->Base.PutValues     = sisWriteDepthPixels_24_8;
-      drb->Base.PutMonoValues = NULL;
+      sisInitDepthPointers_z24_s8(&drb->Base);
    }
    else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT32) {
-      drb->Base.GetRow        = sisReadDepthSpan_32;
-      drb->Base.GetValues     = sisReadDepthPixels_32;
-      drb->Base.PutRow        = sisWriteDepthSpan_32;
-      drb->Base.PutMonoRow    = sisWriteMonoDepthSpan_32;
-      drb->Base.PutValues     = sisWriteDepthPixels_32;
-      drb->Base.PutMonoValues = NULL;
+      sisInitDepthPointers_z32(&drb->Base);
    }
    else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
-      drb->Base.GetRow        = sisReadStencilSpan_24_8;
-      drb->Base.GetValues     = sisReadStencilPixels_24_8;
-      drb->Base.PutRow        = sisWriteStencilSpan_24_8;
-      drb->Base.PutMonoRow    = sisWriteMonoStencilSpan_24_8;
-      drb->Base.PutValues     = sisWriteStencilPixels_24_8;
-      drb->Base.PutMonoValues = NULL;
+      sisInitStencilPointers_z24_s8(&drb->Base);
    }
 }
index db58e9090bca64430140ef02903fc216c391d9d8..50c45b63ed562b90d6b2e2bcc092b2e8b53657d2 100644 (file)
@@ -522,17 +522,21 @@ sisDDLogicOpCode( GLcontext *ctx, GLenum opcode )
 void sisDDDrawBuffer( GLcontext *ctx, GLenum mode )
 {
    sisContextPtr smesa = SIS_CONTEXT(ctx);
-
    __GLSiSHardware *prev = &smesa->prev;
    __GLSiSHardware *current = &smesa->current;
+   int pitch;
 
    /*
     * _DrawDestMask is easier to cope with than <mode>.
     */
    switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) {
    case BUFFER_BIT_FRONT_LEFT:
+      FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_FALSE );
+      pitch = smesa->frontPitch;
+      break;
    case BUFFER_BIT_BACK_LEFT:
       FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_FALSE );
+      pitch = smesa->backPitch;
       break;
    default:
       /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */
@@ -540,14 +544,9 @@ void sisDDDrawBuffer( GLcontext *ctx, GLenum mode )
       return;
    }
 
-   /* We want to update the s/w rast state too so that sisDDSetBuffer()
-    * gets called.
-    */
-   _swrast_DrawBuffer(ctx, mode);
-
    current->hwOffsetDest = (smesa->drawOffset) >> 1;
    current->hwDstSet &= ~MASK_DstBufferPitch;
-   current->hwDstSet |= smesa->drawPitch >> 2;
+   current->hwDstSet |= pitch >> 2;
 
    if (current->hwDstSet != prev->hwDstSet) {
       prev->hwDstSet = current->hwDstSet;
index b00b7ad8dbaf0bb9f798f17aadfd8183320796f7..142beb404fce630cdff6822df94d9b24f66ea587 100644 (file)
 #define LOCAL_VARS                                                     \
    __DRIdrawablePrivate *dPriv = fxMesa->driDrawable;                  \
    tdfxScreenPrivate *fxPriv = fxMesa->fxScreen;                       \
-   GLuint pitch = (fxMesa->glCtx->Color.DrawBuffer[0] == GL_FRONT)         \
-               ? (fxMesa->screen_width * BYTESPERPIXEL) :               \
-               (info.strideInBytes);                                    \
+   GLboolean isFront = (ctx->DrawBuffer->_ColorDrawBufferMask[0]       \
+                      == BUFFER_BIT_FRONT_LEFT);                       \
+   GLuint pitch = isFront ? (fxMesa->screen_width * BYTESPERPIXEL)     \
+                          : info.strideInBytes;                                \
    GLuint height = fxMesa->height;                                     \
    char *buf = (char *)((char *)info.lfbPtr +                          \
                         dPriv->x * fxPriv->cpp +                       \
@@ -1334,25 +1335,6 @@ static void tdfxSpanRenderFinish( GLcontext *ctx )
    UNLOCK_HARDWARE(fxMesa);
 }
 
-/* Set the buffer used for reading */
-static void tdfxDDSetBuffer( GLcontext *ctx,
-                             GLframebuffer *buffer, GLuint bufferBit )
-{
-   tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
-   (void) buffer;
-
-   switch ( bufferBit ) {
-   case BUFFER_BIT_FRONT_LEFT:
-      fxMesa->DrawBuffer = fxMesa->ReadBuffer = GR_BUFFER_FRONTBUFFER;
-      break;
-   case BUFFER_BIT_BACK_LEFT:
-      fxMesa->DrawBuffer = fxMesa->ReadBuffer = GR_BUFFER_BACKBUFFER;
-      break;
-   default:
-      break;
-   }
-}
-
 /**********************************************************************/
 /*                    Initialize swrast device driver                 */
 /**********************************************************************/
@@ -1360,7 +1342,6 @@ static void tdfxDDSetBuffer( GLcontext *ctx,
 void tdfxDDInitSpanFuncs( GLcontext *ctx )
 {
    struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference( ctx );
-   swdd->SetBuffer = tdfxDDSetBuffer;
    swdd->SpanRenderStart          = tdfxSpanRenderStart;
    swdd->SpanRenderFinish         = tdfxSpanRenderFinish; 
 }
index 85d99bb05e7984f12361ebae4b5aadc7fb3d9020..73dad6e086ad6d015397ef371f7d0cd6634f447e 100644 (file)
@@ -1055,11 +1055,6 @@ static void tdfxDDDrawBuffer( GLcontext *ctx, GLenum mode )
       FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_TRUE );
       break;
    }
-
-   /* We want to update the s/w rast state too so that tdfxDDSetBuffer()
-    * gets called.
-    */
-   _swrast_DrawBuffer(ctx, mode);
 }
 
 
index abcdcd70a5e5e2250d0562b692fcfbd19280ba37..0dd787e989776043f500443b5c39c0c5ef189daf 100644 (file)
@@ -37,6 +37,7 @@
 #include "simple_list.h"
 #include "extensions.h"
 #include "framebuffer.h"
+#include "renderbuffer.h"
 
 #include "swrast/swrast.h"
 #include "swrast_setup/swrast_setup.h"
@@ -127,6 +128,53 @@ buffer_align( unsigned width )
 }
 
 
+static void
+nop_delete_renderbuffer(struct gl_renderbuffer *rb)
+{
+   /* Don't free() since we're contained in via_context struct. */
+}
+
+
+static void
+viaInitRenderbuffer(struct gl_renderbuffer *rb, GLenum format)
+{
+   const GLuint name = 0;
+
+   _mesa_init_renderbuffer(rb, name);
+
+   /* Make sure we're using a null-valued GetPointer routine */
+   assert(rb->GetPointer(NULL, rb, 0, 0) == NULL);
+
+   rb->InternalFormat = format;
+
+   if (format == GL_RGBA) {
+      /* Color */
+      rb->_BaseFormat = GL_RGBA;
+      rb->DataType = GL_UNSIGNED_BYTE;
+   }
+   else if (format == GL_DEPTH_COMPONENT16) {
+      /* Depth */
+      rb->_BaseFormat = GL_DEPTH_COMPONENT;
+      /* we always Get/Put 32-bit Z values */
+      rb->DataType = GL_UNSIGNED_INT;
+   }
+   else if (format == GL_DEPTH_COMPONENT24) {
+      /* Depth */
+      rb->_BaseFormat = GL_DEPTH_COMPONENT;
+      /* we always Get/Put 32-bit Z values */
+      rb->DataType = GL_UNSIGNED_INT;
+   }
+   else {
+      /* Stencil */
+      ASSERT(format == GL_STENCIL_INDEX8);
+      rb->_BaseFormat = GL_STENCIL_INDEX;
+      rb->DataType = GL_UNSIGNED_BYTE;
+   }
+
+   rb->Delete = nop_delete_renderbuffer;
+}
+
+
 /**
  * Calculate the framebuffer parameters for all buffers (front, back, depth,
  * and stencil) associated with the specified context.
@@ -138,20 +186,47 @@ buffer_align( unsigned width )
  * \sa AllocateBuffer
  */
 static GLboolean
-calculate_buffer_parameters( struct via_context *vmesa )
+calculate_buffer_parameters( struct via_context *vmesa,
+                             struct gl_framebuffer *fb )
 {
    const unsigned shift = vmesa->viaScreen->bitsPerPixel / 16;
    const unsigned extra = 32;
    unsigned w;
    unsigned h;
 
+   /* Normally, the renderbuffer would be added to the framebuffer just once
+    * when the framebuffer was created.  The VIA driver is a bit funny
+    * though in that the front/back/depth renderbuffers are in the per-context
+    * state!
+    * That should be fixed someday.
+    */
+   _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &vmesa->front.Base);
+   _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &vmesa->back.Base);
+   _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &vmesa->depth.Base);
+   _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &vmesa->stencil.Base);
+
+   if (!vmesa->front.Base.InternalFormat) {
+      /* do one-time init for the renderbuffers */
+      viaInitRenderbuffer(&vmesa->front.Base, GL_RGBA);
+      viaInitRenderbuffer(&vmesa->back.Base, GL_RGBA);
+      if (vmesa->glCtx->Visual.depthBits > 0) {
+         viaInitRenderbuffer(&vmesa->depth.Base, 
+                             (vmesa->glCtx->Visual.depthBits == 16
+                              ? GL_DEPTH_COMPONENT16 : GL_DEPTH_COMPONENT24));
+      }
+      if (vmesa->glCtx->Visual.stencilBits > 0) {
+         viaInitRenderbuffer(&vmesa->stencil.Base, GL_STENCIL_INDEX8_EXT);
+      }
+   }
+
+
    /* Allocate front-buffer */
    if (vmesa->drawType == GLX_PBUFFER_BIT) {
       w = vmesa->driDrawable->w;
       h = vmesa->driDrawable->h;
 
       vmesa->front.bpp = vmesa->viaScreen->bitsPerPixel;
-      vmesa->front.pitch = buffer_align( w ) << shift;
+      vmesa->front.pitch = buffer_align( w ) << shift; /* bytes, not pixels */
       vmesa->front.size = vmesa->front.pitch * h;
 
       if (vmesa->front.map)
@@ -164,7 +239,7 @@ calculate_buffer_parameters( struct via_context *vmesa )
       h = vmesa->viaScreen->height;
 
       vmesa->front.bpp = vmesa->viaScreen->bitsPerPixel;
-      vmesa->front.pitch = buffer_align( w ) << shift;
+      vmesa->front.pitch = buffer_align( w ) << shift; /* bytes, not pixels */
       vmesa->front.size = vmesa->front.pitch * h;
       if (getenv("ALTERNATE_SCREEN")) 
         vmesa->front.offset = vmesa->front.size;
@@ -215,6 +290,17 @@ calculate_buffer_parameters( struct via_context *vmesa )
       (void) memset( & vmesa->depth, 0, sizeof( vmesa->depth ) );
    }
 
+   /* stencil buffer is same as depth buffer */
+   vmesa->stencil.handle = vmesa->depth.handle;
+   vmesa->stencil.size = vmesa->depth.size;
+   vmesa->stencil.offset = vmesa->depth.offset;
+   vmesa->stencil.index = vmesa->depth.index;
+   vmesa->stencil.pitch = vmesa->depth.pitch;
+   vmesa->stencil.bpp = vmesa->depth.bpp;
+   vmesa->stencil.map = vmesa->depth.map;
+   vmesa->stencil.orig = vmesa->depth.orig;
+   vmesa->stencil.origMap = vmesa->depth.origMap;
+
    if( vmesa->viaScreen->width == vmesa->driDrawable->w && 
        vmesa->viaScreen->height == vmesa->driDrawable->h ) {
       vmesa->doPageFlip = vmesa->allowPageFlip;
@@ -238,7 +324,7 @@ void viaReAllocateBuffers(GLcontext *ctx, GLframebuffer *drawbuffer,
     _mesa_resize_framebuffer(ctx, drawbuffer, width, height);
 #endif
 
-    calculate_buffer_parameters( vmesa );
+    calculate_buffer_parameters( vmesa, drawbuffer );
 }
 
 static void viaBufferSize(GLframebuffer *buffer, GLuint *width, GLuint *height)
@@ -646,7 +732,7 @@ void viaXMesaWindowMoved(struct via_context *vmesa)
 
    if (vmesa->drawW != dPriv->w ||
        vmesa->drawH != dPriv->h) 
-      calculate_buffer_parameters( vmesa );
+      calculate_buffer_parameters( vmesa, vmesa->glCtx->DrawBuffer );
 
    vmesa->drawXoff = (GLuint)(((dPriv->x * bytePerPixel) & 0x1f) / 
                              bytePerPixel);  
@@ -692,19 +778,20 @@ viaMakeCurrent(__DRIcontextPrivate *driContextPriv,
         struct via_context *vmesa = 
           (struct via_context *)driContextPriv->driverPrivate;
        GLcontext *ctx = vmesa->glCtx;
+        struct gl_framebuffer *drawBuffer, *readBuffer;
+
+        drawBuffer = (GLframebuffer *)driDrawPriv->driverPrivate;
+        readBuffer = (GLframebuffer *)driReadPriv->driverPrivate;
 
        if ( vmesa->driDrawable != driDrawPriv ) {
           driDrawableInitVBlank( driDrawPriv, vmesa->vblank_flags );
           vmesa->driDrawable = driDrawPriv;
-          if ( ! calculate_buffer_parameters( vmesa ) ) {
+          if ( ! calculate_buffer_parameters( vmesa, drawBuffer ) ) {
              return GL_FALSE;
           }
        }
 
-        _mesa_make_current(vmesa->glCtx,
-                           (GLframebuffer *)driDrawPriv->driverPrivate,
-                           (GLframebuffer *)driReadPriv->driverPrivate);
-       
+        _mesa_make_current(vmesa->glCtx, drawBuffer, readBuffer);
 
        ctx->Driver.DrawBuffer( ctx, ctx->Color.DrawBuffer[0] );
           
index a4b1afc02bb89bd43375d7f0408061bb25f84438..4ee56515b9cdcc1b89efedce1b2e9ab8ac9d23ff 100644 (file)
@@ -82,7 +82,11 @@ typedef void (*via_tri_func)(struct via_context *, viaVertex *, viaVertex *,
 typedef void (*via_line_func)(struct via_context *, viaVertex *, viaVertex *);
 typedef void (*via_point_func)(struct via_context *, viaVertex *);
 
-struct via_buffer {
+/**
+ * Derived from gl_renderbuffer.
+ */
+struct via_renderbuffer {
+   struct gl_renderbuffer Base;  /* must be first! */
    drm_handle_t handle;
    drmSize size;
    GLuint offset;
@@ -144,10 +148,12 @@ struct via_context {
    GLcontext *glCtx;
    GLcontext *shareCtx;
 
-   struct via_buffer front;
-   struct via_buffer back;
-   struct via_buffer depth;
-   struct via_buffer breadcrumb;
+   /* XXX These don't belong here.  They should be per-drawable state. */
+   struct via_renderbuffer front;
+   struct via_renderbuffer back;
+   struct via_renderbuffer depth;
+   struct via_renderbuffer stencil; /* mirrors depth */
+   struct via_renderbuffer breadcrumb;
 
    GLboolean hasBack;
    GLboolean hasDepth;
@@ -264,8 +270,7 @@ struct via_context {
     */
    GLboolean doPageFlip;
 
-   struct via_buffer *drawBuffer;
-   struct via_buffer *readBuffer;
+   struct via_renderbuffer *drawBuffer;
 
    int drawX;                   /* origin of drawable in draw buffer */
    int drawY;    
index e07c200b3210e5b381e5929c84bf9fe9a764c81e..9ac98d1445c99a79dbb88a62381761cef6517588 100644 (file)
@@ -33,7 +33,7 @@
 #include <sys/ioctl.h>
 
 GLboolean
-via_alloc_draw_buffer(struct via_context *vmesa, struct via_buffer *buf)
+via_alloc_draw_buffer(struct via_context *vmesa, struct via_renderbuffer *buf)
 {
    drm_via_mem_t mem;
    mem.context = vmesa->hHWContext;
@@ -53,7 +53,7 @@ via_alloc_draw_buffer(struct via_context *vmesa, struct via_buffer *buf)
 }
 
 void
-via_free_draw_buffer(struct via_context *vmesa, struct via_buffer *buf)
+via_free_draw_buffer(struct via_context *vmesa, struct via_renderbuffer *buf)
 {
    drm_via_mem_t mem;
 
index 7ee153f474fed9734b7e5a879bceef32345bb581..2d329ac2a7d0ac86db979e4174a51d2eb3da794b 100644 (file)
@@ -27,7 +27,7 @@
 
 #include "via_context.h"
 
-extern GLboolean via_alloc_draw_buffer(struct via_context *vmesa, struct via_buffer *buf);
+extern GLboolean via_alloc_draw_buffer(struct via_context *vmesa, struct via_renderbuffer *buf);
 extern GLboolean via_alloc_dma_buffer(struct via_context *vmesa);
 
 struct via_tex_buffer *
@@ -35,7 +35,7 @@ via_alloc_texture(struct via_context *vmesa,
                  GLuint size,
                  GLuint memType);
 
-extern void via_free_draw_buffer(struct via_context *vmesa, struct via_buffer *buf);
+extern void via_free_draw_buffer(struct via_context *vmesa, struct via_renderbuffer *buf);
 extern void via_free_dma_buffer(struct via_context *vmesa);
 extern void via_free_texture(struct via_context *vmesa, struct via_tex_buffer *t);
 void via_release_pending_textures( struct via_context *vmesa );
index 435fd20f778006f0406048f813de435de106db98..db178c134d0dcc84a24b9480494d840c74ac776d 100644 (file)
@@ -172,7 +172,7 @@ static void viaBlit(struct via_context *vmesa, GLuint bpp,
 }
 
 static void viaFillBuffer(struct via_context *vmesa,
-                         struct via_buffer *buffer,
+                         struct via_renderbuffer *buffer,
                          drm_clip_rect_t *pbox,
                          int nboxes,
                          GLuint pixel,
@@ -339,8 +339,8 @@ static void viaDoSwapBuffers(struct via_context *vmesa,
                             GLuint nbox)
 {    
    GLuint bytePerPixel = vmesa->viaScreen->bitsPerPixel >> 3;
-   struct via_buffer *front = &vmesa->front;
-   struct via_buffer *back = &vmesa->back;
+   struct via_renderbuffer *front = &vmesa->front;
+   struct via_renderbuffer *back = &vmesa->back;
    GLuint i;
         
    for (i = 0; i < nbox; i++, b++) {        
@@ -366,7 +366,7 @@ static void viaDoSwapBuffers(struct via_context *vmesa,
 
 static void viaEmitBreadcrumbLocked( struct via_context *vmesa )
 {
-   struct via_buffer *buffer = &vmesa->breadcrumb;
+   struct via_renderbuffer *buffer = &vmesa->breadcrumb;
    GLuint value = vmesa->lastBreadcrumbWrite + 1;
 
    if (VIA_DEBUG & DEBUG_IOCTL) 
@@ -562,10 +562,10 @@ void viaResetPageFlippingLocked(struct via_context *vmesa)
    viaDoPageFlipLocked( vmesa, 0 );
 
    if (vmesa->front.offset != 0) {
-      struct via_buffer buffer_tmp;
-      memcpy(&buffer_tmp, &vmesa->back, sizeof(struct via_buffer));
-      memcpy(&vmesa->back, &vmesa->front, sizeof(struct via_buffer));
-      memcpy(&vmesa->front, &buffer_tmp, sizeof(struct via_buffer));
+      struct via_renderbuffer buffer_tmp;
+      memcpy(&buffer_tmp, &vmesa->back, sizeof(struct via_renderbuffer));
+      memcpy(&vmesa->back, &vmesa->front, sizeof(struct via_renderbuffer));
+      memcpy(&vmesa->front, &buffer_tmp, sizeof(struct via_renderbuffer));
    }
 
    assert(vmesa->front.offset == 0);
@@ -623,7 +623,7 @@ void viaPageFlip(const __DRIdrawablePrivate *dPriv)
 {
     struct via_context *vmesa = 
        (struct via_context *)dPriv->driContextPriv->driverPrivate;
-    struct via_buffer buffer_tmp;
+    struct via_renderbuffer buffer_tmp;
 
     VIA_FLUSH_DMA(vmesa);
    if (vmesa->vblank_flags == VBLANK_FLAG_SYNC &&
@@ -645,9 +645,9 @@ void viaPageFlip(const __DRIdrawablePrivate *dPriv)
     /* KW: FIXME: When buffers are freed, could free frontbuffer by
      * accident:
      */
-    memcpy(&buffer_tmp, &vmesa->back, sizeof(struct via_buffer));
-    memcpy(&vmesa->back, &vmesa->front, sizeof(struct via_buffer));
-    memcpy(&vmesa->front, &buffer_tmp, sizeof(struct via_buffer));
+    memcpy(&buffer_tmp, &vmesa->back, sizeof(struct via_renderbuffer));
+    memcpy(&vmesa->back, &vmesa->front, sizeof(struct via_renderbuffer));
+    memcpy(&vmesa->front, &buffer_tmp, sizeof(struct via_renderbuffer));
 }
 
 
@@ -724,7 +724,7 @@ static int fire_buffer(struct via_context *vmesa)
 static void via_emit_cliprect(struct via_context *vmesa,
                              drm_clip_rect_t *b) 
 {
-   struct via_buffer *buffer = vmesa->drawBuffer;
+   struct via_renderbuffer *buffer = vmesa->drawBuffer;
    GLuint *vb = (GLuint *)(vmesa->dma + vmesa->dmaCliprectAddr);
 
    GLuint format = (vmesa->viaScreen->bitsPerPixel == 0x20 
index 1b2e22ef299b4730ad2ef0ac6c1b5a2c479bd088..ddd360cc240d6885a4f6b23de28f58ee50c36132 100644 (file)
@@ -214,7 +214,7 @@ viaCreateBuffer(__DRIscreenPrivate *driScrnPriv,
 
     GLboolean swStencil = (mesaVis->stencilBits > 0 && 
                           mesaVis->depthBits != 24);
-
+    GLboolean swAccum = mesaVis->accumRedBits > 0;
 
     if (isPixmap) {
        /* KW: This needs work, disabled for now:
@@ -232,16 +232,14 @@ viaCreateBuffer(__DRIscreenPrivate *driScrnPriv,
        return GL_FALSE;
     }
     else {
-#if 0
-        driDrawPriv->driverPrivate = (void *)
-            _mesa_create_framebuffer(mesaVis,
-                                     GL_FALSE, /* software depth buffer? */
-                                     swStencil,
-                                     mesaVis->accumRedBits > 0,
-                                     GL_FALSE  /* s/w alpha planes */);
-#else
       struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
 
+      /* The front color, back color and depth renderbuffers are
+       * set up later in calculate_buffer_parameters().
+       * Only create/connect software-based buffers here.
+       */
+
+#if 000
       /* XXX check/fix the offset/pitch parameters! */
       {
          driRenderbuffer *frontRb
@@ -288,17 +286,18 @@ viaCreateBuffer(__DRIscreenPrivate *driScrnPriv,
          viaSetSpanFunctions(stencilRb, mesaVis);
          _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);
       }
+#endif
 
       _mesa_add_soft_renderbuffers(fb,
                                    GL_FALSE, /* color */
                                    GL_FALSE, /* depth */
                                    swStencil,
-                                   mesaVis->accumRedBits > 0,
+                                   swAccum,
                                    GL_FALSE, /* alpha */
                                    GL_FALSE /* aux */);
       driDrawPriv->driverPrivate = (void *) fb;
-#endif
-        return (driDrawPriv->driverPrivate != NULL);
+
+      return (driDrawPriv->driverPrivate != NULL);
    }
 }
 
index 16a1aa8b367a2131468e870b8cf4f186dda01a7d..5bffade9408995bb87da1e7498a9c14fce1f64d5 100644 (file)
 #define LOCAL_VARS                                                     \
     struct via_context *vmesa = VIA_CONTEXT(ctx);                      \
     __DRIdrawablePrivate *dPriv = vmesa->driDrawable;                  \
-    GLuint draw_pitch = vmesa->drawBuffer->pitch;                       \
-    GLuint read_pitch = vmesa->readBuffer->pitch;                       \
+    struct via_renderbuffer *vrb = (struct via_renderbuffer *) rb;     \
+    GLuint pitch = vrb->pitch;                                          \
     GLuint height = dPriv->h;                                          \
     GLint p = 0;                                                       \
-    char *buf = (char *)(vmesa->drawBuffer->origMap + vmesa->drawXoff * vmesa->viaScreen->bytesPerPixel); \
-    char *read_buf = (char *)(vmesa->readBuffer->origMap + vmesa->drawXoff * vmesa->viaScreen->bytesPerPixel); \
-    (void) (read_pitch && draw_pitch && buf && read_buf && p);
+    char *buf = (char *)(vrb->origMap + vmesa->drawXoff * vrb->bpp);    \
+    (void) p;
 
 /* ================================================================
  * Color buffer
@@ -57,8 +56,8 @@
 
 /* 16 bit, RGB565 color spanline and pixel functions
  */
-#define GET_SRC_PTR(_x, _y) (read_buf + (_x) * 2 + (_y) * read_pitch)
-#define GET_DST_PTR(_x, _y) (     buf + (_x) * 2 + (_y) * draw_pitch)
+#define GET_SRC_PTR(_x, _y) (buf + (_x) * 2 + (_y) * pitch)
+#define GET_DST_PTR(_x, _y) GET_SRC_PTR(_x, _y);
 #define SPANTMP_PIXEL_FMT GL_RGB
 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5
 
@@ -69,8 +68,8 @@
 
 /* 32 bit, ARGB8888 color spanline and pixel functions
  */
-#define GET_SRC_PTR(_x, _y) (read_buf + (_x) * 4 + (_y) * read_pitch)
-#define GET_DST_PTR(_x, _y) (     buf + (_x) * 4 + (_y) * draw_pitch)
+#define GET_SRC_PTR(_x, _y) (buf + (_x) * 4 + (_y) * pitch)
+#define GET_DST_PTR(_x, _y) GET_SRC_PTR(_x, _y);
 #define SPANTMP_PIXEL_FMT GL_BGRA
 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
 
 
 /* 16 bit depthbuffer functions.
  */
-#define LOCAL_DEPTH_VARS                                \
-    struct via_context *vmesa = VIA_CONTEXT(ctx);             \
-    __DRIdrawablePrivate *dPriv = vmesa->driDrawable;   \
-    GLuint depth_pitch = vmesa->depth.pitch;                  \
-    GLuint height = dPriv->h;                           \
-    char *buf = (char *)(vmesa->depth.map + (vmesa->drawXoff * vmesa->depth.bpp/8))
+#define LOCAL_DEPTH_VARS                                            \
+    struct via_context *vmesa = VIA_CONTEXT(ctx);                   \
+    __DRIdrawablePrivate *dPriv = vmesa->driDrawable;               \
+    struct via_renderbuffer *vrb = (struct via_renderbuffer *) rb;  \
+    GLuint depth_pitch = vrb->pitch;                                \
+    GLuint height = dPriv->h;                                       \
+    char *buf = (char *)(vrb->map + (vmesa->drawXoff * vrb->bpp/8))
 
 #define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS 
 
@@ -97,7 +97,7 @@
 #define READ_DEPTH(d, _x, _y)                       \
     d = *(volatile GLushort *)(buf + (_x) * 2 + (_y) * depth_pitch);
 
-#define TAG(x) via##x##_16
+#define TAG(x) via##x##_z16
 #include "depthtmp.h"
 
 /* 32 bit depthbuffer functions.
 #define READ_DEPTH(d, _x, _y)                       \
     d = *(volatile GLuint *)(buf + (_x) * 4 + (_y) * depth_pitch);
 
-#define TAG(x) via##x##_32
+#define TAG(x) via##x##_z32
 #include "depthtmp.h"
 
 
    d = (*(GLuint *)(buf + (_x)*4 + (_y)*depth_pitch)) >> 8;
 
 
-#define TAG(x) via##x##_24_8
+#define TAG(x) via##x##_z24_s8
 #include "depthtmp.h"
 
 #define WRITE_STENCIL( _x, _y, d ) {                   \
 #define READ_STENCIL( d, _x, _y )                      \
    d = *(GLuint *)(buf + (_x)*4 + (_y)*depth_pitch) & 0xff;
 
-#define TAG(x) via##x##_24_8
+#define TAG(x) via##x##_z24_s8
 #include "stenciltmp.h"
 
 
 
-static void viaSetBuffer(GLcontext *ctx, GLframebuffer *colorBuffer,
-                      GLuint bufferBit)
-{
-    struct via_context *vmesa = VIA_CONTEXT(ctx);
-
-    if (bufferBit == BUFFER_BIT_FRONT_LEFT) {
-       vmesa->drawBuffer = vmesa->readBuffer = &vmesa->front;
-    }
-    else if (bufferBit == BUFFER_BIT_BACK_LEFT) {
-       vmesa->drawBuffer = vmesa->readBuffer = &vmesa->back;
-    }
-    else {
-        ASSERT(0);
-    }
-}
 
 /* Move locking out to get reasonable span performance.
  */
@@ -178,64 +163,9 @@ void viaSpanRenderFinish( GLcontext *ctx )
 
 void viaInitSpanFuncs(GLcontext *ctx)
 {
-#if 0
-    struct via_context *vmesa = VIA_CONTEXT(ctx);
-#endif
     struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
-
-    swdd->SetBuffer = viaSetBuffer;
-#if 0
-    if (vmesa->viaScreen->bitsPerPixel == 16) {
-       viaInitPointers_565( swdd );
-    }
-    else if (vmesa->viaScreen->bitsPerPixel == 32) {
-       viaInitPointers_8888( swdd );
-    }
-    else {
-       assert(0);
-    }
-#endif
-#if 0
-    if (vmesa->glCtx->Visual.depthBits == 16) {
-       swdd->ReadDepthSpan = viaReadDepthSpan_16;
-       swdd->WriteDepthSpan = viaWriteDepthSpan_16;
-       swdd->WriteMonoDepthSpan = viaWriteMonoDepthSpan_16;
-       swdd->ReadDepthPixels = viaReadDepthPixels_16;
-       swdd->WriteDepthPixels = viaWriteDepthPixels_16;
-    }
-    else if (vmesa->glCtx->Visual.depthBits == 24) {
-        swdd->ReadDepthSpan = viaReadDepthSpan_24_8;
-       swdd->WriteDepthSpan = viaWriteDepthSpan_24_8;
-       swdd->WriteMonoDepthSpan = viaWriteMonoDepthSpan_24_8;
-       swdd->ReadDepthPixels = viaReadDepthPixels_24_8;
-       swdd->WriteDepthPixels = viaWriteDepthPixels_24_8;
-
-       swdd->WriteStencilSpan = viaWriteStencilSpan_24_8;
-       swdd->ReadStencilSpan = viaReadStencilSpan_24_8;
-       swdd->WriteStencilPixels = viaWriteStencilPixels_24_8;
-       swdd->ReadStencilPixels = viaReadStencilPixels_24_8;
-    }
-    else if (vmesa->glCtx->Visual.depthBits == 32) {
-       swdd->ReadDepthSpan = viaReadDepthSpan_32;
-       swdd->WriteDepthSpan = viaWriteDepthSpan_32;
-       swdd->WriteMonoDepthSpan = viaWriteMonoDepthSpan_32;
-       swdd->ReadDepthPixels = viaReadDepthPixels_32;
-       swdd->WriteDepthPixels = viaWriteDepthPixels_32;
-    }
-#endif
-
     swdd->SpanRenderStart = viaSpanRenderStart;
     swdd->SpanRenderFinish = viaSpanRenderFinish; 
-
-#if 0
-    swdd->WriteCI8Span = NULL;
-    swdd->WriteCI32Span = NULL;
-    swdd->WriteMonoCISpan = NULL;
-    swdd->WriteCI32Pixels = NULL;
-    swdd->WriteMonoCIPixels = NULL;
-    swdd->ReadCI32Span = NULL;
-    swdd->ReadCI32Pixels = NULL;       
-#endif
 }
 
 
@@ -244,46 +174,26 @@ void viaInitSpanFuncs(GLcontext *ctx)
  * Plug in the Get/Put routines for the given driRenderbuffer.
  */
 void
-viaSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
+viaSetSpanFunctions(struct via_renderbuffer *vrb, const GLvisual *vis)
 {
-   if (drb->Base.InternalFormat == GL_RGBA) {
+   if (vrb->Base.InternalFormat == GL_RGBA) {
       if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
-         viaInitPointers_565(&drb->Base);
+         viaInitPointers_565(&vrb->Base);
       }
       else {
-         viaInitPointers_8888(&drb->Base);
+         viaInitPointers_8888(&vrb->Base);
       }
    }
-   else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
-      drb->Base.GetRow        = viaReadDepthSpan_16;
-      drb->Base.GetValues     = viaReadDepthPixels_16;
-      drb->Base.PutRow        = viaWriteDepthSpan_16;
-      drb->Base.PutMonoRow    = viaWriteMonoDepthSpan_16;
-      drb->Base.PutValues     = viaWriteDepthPixels_16;
-      drb->Base.PutMonoValues = NULL;
+   else if (vrb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+      viaInitDepthPointers_z16(&vrb->Base);
    }
-   else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
-      drb->Base.GetRow        = viaReadDepthSpan_24_8;
-      drb->Base.GetValues     = viaReadDepthPixels_24_8;
-      drb->Base.PutRow        = viaWriteDepthSpan_24_8;
-      drb->Base.PutMonoRow    = viaWriteMonoDepthSpan_24_8;
-      drb->Base.PutValues     = viaWriteDepthPixels_24_8;
-      drb->Base.PutMonoValues = NULL;
+   else if (vrb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+      viaInitDepthPointers_z24_s8(&vrb->Base);
    }
-   else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT32) {
-      drb->Base.GetRow        = viaReadDepthSpan_32;
-      drb->Base.GetValues     = viaReadDepthPixels_32;
-      drb->Base.PutRow        = viaWriteDepthSpan_32;
-      drb->Base.PutMonoRow    = viaWriteMonoDepthSpan_32;
-      drb->Base.PutValues     = viaWriteDepthPixels_32;
-      drb->Base.PutMonoValues = NULL;
+   else if (vrb->Base.InternalFormat == GL_DEPTH_COMPONENT32) {
+      viaInitDepthPointers_z32(&vrb->Base);
    }
-   else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
-      drb->Base.GetRow        = viaReadStencilSpan_24_8;
-      drb->Base.GetValues     = viaReadStencilPixels_24_8;
-      drb->Base.PutRow        = viaWriteStencilSpan_24_8;
-      drb->Base.PutMonoRow    = viaWriteMonoStencilSpan_24_8;
-      drb->Base.PutValues     = viaWriteStencilPixels_24_8;
-      drb->Base.PutMonoValues = NULL;
+   else if (vrb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+      viaInitStencilPointers_z24_s8(&vrb->Base);
    }
 }
index c3bd24b0e78bf9505d35de83ca3fa65535631f5e..3dca0d566196b26de40a2f12c197c616bf38b933 100644 (file)
 #ifndef _VIA_SPAN_H
 #define _VIA_SPAN_H
 
-#include "drirenderbuffer.h"
-
 extern void viaInitSpanFuncs(GLcontext *ctx);
 extern void viaSpanRenderStart( GLcontext *ctx );
 extern void viaSpanRenderFinish( GLcontext *ctx );
 
 extern void
-viaSetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis);
+viaSetSpanFunctions(struct via_renderbuffer *vrb, const GLvisual *vis);
 
 #endif
index 4037d14fff947f7fc5e9fdca6a8ad9b0af03ca4e..324c72b46ab4fba8b3f72d3c490e8038d08ba889 100644 (file)
@@ -659,12 +659,12 @@ static void viaDrawBuffer(GLcontext *ctx, GLenum mode)
    switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) {
    case BUFFER_BIT_FRONT_LEFT:
       VIA_FLUSH_DMA(vmesa);
-      vmesa->drawBuffer = vmesa->readBuffer = &vmesa->front;
+      vmesa->drawBuffer = &vmesa->front;
       FALLBACK(vmesa, VIA_FALLBACK_DRAW_BUFFER, GL_FALSE);
       break;
    case BUFFER_BIT_BACK_LEFT:
       VIA_FLUSH_DMA(vmesa);
-      vmesa->drawBuffer = vmesa->readBuffer = &vmesa->back;
+      vmesa->drawBuffer = &vmesa->back;
       FALLBACK(vmesa, VIA_FALLBACK_DRAW_BUFFER, GL_FALSE);
       break;
    default:
@@ -674,11 +674,6 @@ static void viaDrawBuffer(GLcontext *ctx, GLenum mode)
 
 
    viaXMesaWindowMoved(vmesa);
-
-   /* We want to update the s/w rast state too so that viaSetBuffer()
-    * gets called.
-    */
-   _swrast_DrawBuffer(ctx, mode);
 }
 
 static void viaClearColor(GLcontext *ctx, const GLfloat color[4])