i965: Remove BRW_WM_LOCK dirty bit, introduced to work around lack of relocs.
[mesa.git] / src / mesa / drivers / glide / fxddspan.c
index ff522522d137c2f68c12b5e8b92d5451336b69c6..d3a58a301c2c15c5f33988b9471f2688e53cd788 100644 (file)
@@ -54,6 +54,7 @@
 
 
 #define LOCAL_VARS                                                     \
+    GrBuffer_t currentFB = GR_BUFFER_BACKBUFFER;                       \
     GLuint pitch = info.strideInBytes;                                 \
     GLuint height = fxMesa->height;                                    \
     char *buf = (char *)((char *)info.lfbPtr + 0 /* x, y offset */);   \
     GrLfbInfo_t info;                                                  \
     info.size = sizeof(GrLfbInfo_t);                                   \
     if ( grLfbLock( GR_LFB_WRITE_ONLY,                                 \
-                   fxMesa->currentFB, LFB_MODE,                                \
+                   currentFB, LFB_MODE,                                        \
                   GR_ORIGIN_UPPER_LEFT, FXFALSE, &info ) ) {
 
 #define HW_WRITE_UNLOCK()                                              \
-       grLfbUnlock( GR_LFB_WRITE_ONLY, fxMesa->currentFB );            \
+       grLfbUnlock( GR_LFB_WRITE_ONLY, currentFB );                    \
     }
 
 #define HW_READ_LOCK()                                                 \
     fxMesaContext fxMesa = FX_CONTEXT(ctx);                            \
     GrLfbInfo_t info;                                                  \
     info.size = sizeof(GrLfbInfo_t);                                   \
-    if ( grLfbLock( GR_LFB_READ_ONLY, fxMesa->currentFB,               \
+    if ( grLfbLock( GR_LFB_READ_ONLY, currentFB,                       \
                     LFB_MODE, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info ) ) {
 
 #define HW_READ_UNLOCK()                                               \
-       grLfbUnlock( GR_LFB_READ_ONLY, fxMesa->currentFB );             \
+       grLfbUnlock( GR_LFB_READ_ONLY, currentFB );                     \
     }
 
 #define HW_WRITE_CLIPLOOP()                                            \
 #undef BYTESPERPIXEL
 #define BYTESPERPIXEL 2
 
+#define VALUE_TYPE GLushort
+
 #define WRITE_DEPTH( _x, _y, d )                                       \
     *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch) = d
 
 #undef BYTESPERPIXEL
 #define BYTESPERPIXEL 4
 
+#define VALUE_TYPE GLuint
+
 #define WRITE_DEPTH( _x, _y, d )                                       \
     *(GLuint *)(buf + _x*BYTESPERPIXEL + _y*pitch) = d << 8
 
  * since OpenGL says obscured pixels have undefined values.
  */
 static void fxReadRGBASpan_ARGB1555 (const GLcontext * ctx,
+                                     struct gl_renderbuffer *rb,
                                      GLuint n,
                                      GLint x, GLint y,
                                      GLubyte rgba[][4])
 {
  fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GrBuffer_t currentFB = GR_BUFFER_BACKBUFFER;
  GrLfbInfo_t info;
  info.size = sizeof(GrLfbInfo_t);
- if (grLfbLock(GR_LFB_READ_ONLY, fxMesa->currentFB,
+ if (grLfbLock(GR_LFB_READ_ONLY, currentFB,
                GR_LFBWRITEMODE_ANY, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
     const GLint winX = 0;
     const GLint winY = fxMesa->height - 1;
@@ -369,7 +376,7 @@ static void fxReadRGBASpan_ARGB1555 (const GLcontext * ctx,
        rgba[n][3] = (pixel & 0x8000) ? 255 : 0;
     }
 
-    grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
+    grLfbUnlock(GR_LFB_READ_ONLY, currentFB);
  }
 }
 
@@ -378,14 +385,16 @@ static void fxReadRGBASpan_ARGB1555 (const GLcontext * ctx,
  * since OpenGL says obscured pixels have undefined values.
  */
 static void fxReadRGBASpan_RGB565 (const GLcontext * ctx,
+                                   struct gl_renderbuffer *rb,
                                    GLuint n,
                                    GLint x, GLint y,
                                    GLubyte rgba[][4])
 {
  fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GrBuffer_t currentFB = GR_BUFFER_BACKBUFFER;
  GrLfbInfo_t info;
  info.size = sizeof(GrLfbInfo_t);
- if (grLfbLock(GR_LFB_READ_ONLY, fxMesa->currentFB,
+ if (grLfbLock(GR_LFB_READ_ONLY, currentFB,
                GR_LFBWRITEMODE_ANY, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
     const GLint winX = 0;
     const GLint winY = fxMesa->height - 1;
@@ -416,7 +425,7 @@ static void fxReadRGBASpan_RGB565 (const GLcontext * ctx,
        rgba[n][3] = 255;
     }
 
-    grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
+    grLfbUnlock(GR_LFB_READ_ONLY, currentFB);
  }
 }
 
@@ -425,13 +434,15 @@ static void fxReadRGBASpan_RGB565 (const GLcontext * ctx,
  * since OpenGL says obscured pixels have undefined values.
  */
 static void fxReadRGBASpan_ARGB8888 (const GLcontext * ctx,
+                                     struct gl_renderbuffer *rb,
                                      GLuint n,
                                      GLint x, GLint y,
                                      GLubyte rgba[][4])
 {
  fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GrBuffer_t currentFB = GR_BUFFER_BACKBUFFER;
  GLuint i;
- grLfbReadRegion(fxMesa->currentFB, x, fxMesa->height - 1 - y, n, 1, n * 4, rgba);
+ grLfbReadRegion(currentFB, x, fxMesa->height - 1 - y, n, 1, n * 4, rgba);
  for (i = 0; i < n; i++) {
      GLubyte c = rgba[i][0];
      rgba[i][0] = rgba[i][2];
@@ -445,8 +456,8 @@ static void fxReadRGBASpan_ARGB8888 (const GLcontext * ctx,
 /************************************************************************/
 
 static void
-fxReadDepthSpan_Z16(GLcontext * ctx,
-                   GLuint n, GLint x, GLint y, GLdepth depth[])
+fxReadDepthSpan_Z16(GLcontext * ctx, struct gl_renderbuffer *rb,
+                   GLuint n, GLint x, GLint y, GLuint depth[])
 {
    fxMesaContext fxMesa = FX_CONTEXT(ctx);
    GLint bottom = fxMesa->height - 1;
@@ -465,8 +476,8 @@ fxReadDepthSpan_Z16(GLcontext * ctx,
 
 
 static void
-fxReadDepthSpan_Z24(GLcontext * ctx,
-                   GLuint n, GLint x, GLint y, GLdepth depth[])
+fxReadDepthSpan_Z24(GLcontext * ctx, struct gl_renderbuffer *rb,
+                   GLuint n, GLint x, GLint y, GLuint depth[])
 {
    fxMesaContext fxMesa = FX_CONTEXT(ctx);
    GLint bottom = fxMesa->height - 1;
@@ -488,7 +499,8 @@ fxReadDepthSpan_Z24(GLcontext * ctx,
 /************************************************************************/
 
 static void
-fxWriteStencilSpan (GLcontext *ctx, GLuint n, GLint x, GLint y,
+fxWriteStencilSpan (GLcontext *ctx, struct gl_renderbuffer *rb,
+                    GLuint n, GLint x, GLint y,
                     const GLstencil stencil[], const GLubyte mask[])
 {
  /*
@@ -497,7 +509,7 @@ fxWriteStencilSpan (GLcontext *ctx, GLuint n, GLint x, GLint y,
 }
 
 static void
-fxReadStencilSpan(GLcontext * ctx,
+fxReadStencilSpan(GLcontext * ctx, struct gl_renderbuffer *rb,
                  GLuint n, GLint x, GLint y, GLstencil stencil[])
 {
    fxMesaContext fxMesa = FX_CONTEXT(ctx);
@@ -516,7 +528,7 @@ fxReadStencilSpan(GLcontext * ctx,
 }
 
 static void
-fxWriteStencilPixels (GLcontext *ctx, GLuint n,
+fxWriteStencilPixels (GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n,
                       const GLint x[], const GLint y[],
                       const GLstencil stencil[],
                       const GLubyte mask[])
@@ -527,7 +539,7 @@ fxWriteStencilPixels (GLcontext *ctx, GLuint n,
 }
 
 static void
-fxReadStencilPixels (GLcontext *ctx, GLuint n,
+fxReadStencilPixels (GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n,
                      const GLint x[], const GLint y[],
                      GLstencil stencil[])
 {
@@ -537,45 +549,12 @@ fxReadStencilPixels (GLcontext *ctx, GLuint n,
 }
 
 
-
-/*
- * 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
-fxDDSetBuffer(GLcontext * ctx, GLframebuffer * buffer, GLuint bufferBit)
-{
-   fxMesaContext fxMesa = FX_CONTEXT(ctx);
-   (void) buffer;
-
-   if (TDFX_DEBUG & VERBOSE_DRIVER) {
-      fprintf(stderr, "fxDDSetBuffer(%x)\n", (int)bufferBit);
-   }
-
-   if (bufferBit == DD_FRONT_LEFT_BIT) {
-      fxMesa->currentFB = GR_BUFFER_FRONTBUFFER;
-      grRenderBuffer(fxMesa->currentFB);
-   }
-   else if (bufferBit == DD_BACK_LEFT_BIT) {
-      fxMesa->currentFB = GR_BUFFER_BACKBUFFER;
-      grRenderBuffer(fxMesa->currentFB);
-   }
-}
-
-
-/************************************************************************/
-
-
-
 void
 fxSetupDDSpanPointers(GLcontext * ctx)
 {
    struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference( ctx );
    fxMesaContext fxMesa = FX_CONTEXT(ctx);
 
-   swdd->SetBuffer = fxDDSetBuffer;
-
    switch (fxMesa->colDepth) {
           case 15:
                swdd->WriteRGBASpan = tdfxWriteRGBASpan_ARGB1555;