i965: Remove BRW_WM_LOCK dirty bit, introduced to work around lack of relocs.
[mesa.git] / src / mesa / drivers / glide / fxddspan.c
index 158e34e08e1650b6e08e6c794fe020be302c0727..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()                                            \
     do {                                                               \
-       int _nc = 1; /* numcliprects */                                 \
-       /* [dBorca] Hack alert: */                                      \
        /* remember, we need to flip the scissor, too */                \
        /* is it better to do it inside fxDDScissor? */                 \
-       while (_nc--) {                                                 \
-           const int minx = fxMesa->clipMinX;                          \
-           const int maxy = Y_FLIP(fxMesa->clipMinY);                  \
-           const int maxx = fxMesa->clipMaxX;                          \
-           const int miny = Y_FLIP(fxMesa->clipMaxY);
+       const int minx = fxMesa->clipMinX;                              \
+       const int maxy = Y_FLIP(fxMesa->clipMinY);                      \
+       const int maxx = fxMesa->clipMaxX;                              \
+       const int miny = Y_FLIP(fxMesa->clipMaxY);
 
 #define HW_READ_CLIPLOOP()                                             \
     do {                                                               \
-       int _nc = 1; /* numcliprects */                                 \
-       /* [dBorca] Hack alert: */                                      \
        /* remember, we need to flip the scissor, too */                \
        /* is it better to do it inside fxDDScissor? */                 \
-       while (_nc--) {                                                 \
-           const int minx = fxMesa->clipMinX;                          \
-           const int maxy = Y_FLIP(fxMesa->clipMinY);                  \
-           const int maxx = fxMesa->clipMaxX;                          \
-           const int miny = Y_FLIP(fxMesa->clipMaxY);
+       const int minx = fxMesa->clipMinX;                              \
+       const int maxy = Y_FLIP(fxMesa->clipMinY);                      \
+       const int maxx = fxMesa->clipMaxX;                              \
+       const int miny = Y_FLIP(fxMesa->clipMaxY);
 
 #define HW_ENDCLIPLOOP()                                               \
-       }                                                               \
     } while (0)
 
 
 #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;
@@ -376,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);
  }
 }
 
@@ -385,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;
@@ -423,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);
  }
 }
 
@@ -432,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];
@@ -451,9 +455,9 @@ static void fxReadRGBASpan_ARGB8888 (const GLcontext * ctx,
 /*****                    Depth functions (optimized)               *****/
 /************************************************************************/
 
-void
-fxReadDepthSpan_Z16(GLcontext * ctx,
-                   GLuint n, GLint x, GLint y, GLdepth depth[])
+static void
+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;
@@ -461,7 +465,7 @@ fxReadDepthSpan_Z16(GLcontext * ctx,
    GLuint i;
 
    if (TDFX_DEBUG & VERBOSE_DRIVER) {
-      fprintf(stderr, "%s(...)\n", __FUNCTION__);
+      fprintf(stderr, "fxReadDepthSpan_Z16(...)\n");
    }
 
    grLfbReadRegion(GR_BUFFER_AUXBUFFER, x, bottom - y, n, 1, 0, depth16);
@@ -471,16 +475,16 @@ fxReadDepthSpan_Z16(GLcontext * ctx,
 }
 
 
-void
-fxReadDepthSpan_Z24(GLcontext * ctx,
-                   GLuint n, GLint x, GLint y, GLdepth depth[])
+static void
+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;
    GLuint i;
 
    if (TDFX_DEBUG & VERBOSE_DRIVER) {
-      fprintf(stderr, "%s(...)\n", __FUNCTION__);
+      fprintf(stderr, "fxReadDepthSpan_Z24(...)\n");
    }
 
    grLfbReadRegion(GR_BUFFER_AUXBUFFER, x, bottom - y, n, 1, 0, depth);
@@ -494,16 +498,18 @@ fxReadDepthSpan_Z24(GLcontext * ctx,
 /*****                    Stencil functions (optimized)             *****/
 /************************************************************************/
 
-void fxWriteStencilSpan (GLcontext *ctx, GLuint n, GLint x, GLint y,
-                         const GLstencil stencil[], const GLubyte mask[])
+static void
+fxWriteStencilSpan (GLcontext *ctx, struct gl_renderbuffer *rb,
+                    GLuint n, GLint x, GLint y,
+                    const GLstencil stencil[], const GLubyte mask[])
 {
  /*
   * XXX todo
   */
 }
 
-void
-fxReadStencilSpan(GLcontext * ctx,
+static void
+fxReadStencilSpan(GLcontext * ctx, struct gl_renderbuffer *rb,
                  GLuint n, GLint x, GLint y, GLstencil stencil[])
 {
    fxMesaContext fxMesa = FX_CONTEXT(ctx);
@@ -512,7 +518,7 @@ fxReadStencilSpan(GLcontext * ctx,
    GLuint i;
 
    if (TDFX_DEBUG & VERBOSE_DRIVER) {
-      fprintf(stderr, "%s(...)\n", __FUNCTION__);
+      fprintf(stderr, "fxReadStencilSpan(...)\n");
    }
 
    grLfbReadRegion(GR_BUFFER_AUXBUFFER, x, bottom - y, n, 1, 0, zs32);
@@ -521,19 +527,21 @@ fxReadStencilSpan(GLcontext * ctx,
    }
 }
 
-void fxWriteStencilPixels (GLcontext *ctx, GLuint n,
-                           const GLint x[], const GLint y[],
-                           const GLstencil stencil[],
-                           const GLubyte mask[])
+static void
+fxWriteStencilPixels (GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n,
+                      const GLint x[], const GLint y[],
+                      const GLstencil stencil[],
+                      const GLubyte mask[])
 {
  /*
   * XXX todo
   */
 }
 
-void fxReadStencilPixels (GLcontext *ctx, GLuint n,
-                          const GLint x[], const GLint y[],
-                          GLstencil stencil[])
+static void
+fxReadStencilPixels (GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n,
+                     const GLint x[], const GLint y[],
+                     GLstencil stencil[])
 {
  /*
   * XXX todo
@@ -541,45 +549,12 @@ void 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, "%s(%x)\n", __FUNCTION__, (int)bufferBit);
-   }
-
-   if (bufferBit == FRONT_LEFT_BIT) {
-      fxMesa->currentFB = GR_BUFFER_FRONTBUFFER;
-      grRenderBuffer(fxMesa->currentFB);
-   }
-   else if (bufferBit == 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;