Pull locking out of HW_LOCK/UNLOCK and into SpanRenderStart/Finish. Also do
authorEric Anholt <anholt@FreeBSD.org>
Tue, 31 May 2005 05:31:43 +0000 (05:31 +0000)
committerEric Anholt <anholt@FreeBSD.org>
Tue, 31 May 2005 05:31:43 +0000 (05:31 +0000)
some cleanups on the span macros.  This does not deal with the brokenness of
depth spans, but makes the code more readable.

src/mesa/drivers/dri/r128/r128_span.c
src/mesa/drivers/dri/r128/r128_tris.c

index b59706118e451c0cf8c277fb6278e8e1c5e9001a..7b02fc60a19373890d1cc120aac2431dda844582 100644 (file)
@@ -93,11 +93,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define Y_FLIP( _y )           (height - _y - 1)
 
 
-#define HW_LOCK()                                                      \
-   r128ContextPtr rmesa = R128_CONTEXT(ctx);                           \
-   FLUSH_BATCH( rmesa );                                               \
-   LOCK_HARDWARE( rmesa );                                             \
-   r128WaitForIdleLocked( rmesa );
+#define HW_LOCK()
 
 #define HW_CLIPLOOP()                                                  \
    do {                                                                        \
@@ -114,8 +110,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
       }                                                                        \
    } while (0)
 
-#define HW_UNLOCK()                                                    \
-   UNLOCK_HARDWARE( rmesa )
+#define HW_UNLOCK()
 
 
 
@@ -153,8 +148,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 /* 16-bit depth buffer functions
  */
-#define READ_DEPTH(d, _x, _y)                                           \
-    d = *(GLushort *)(buf + (_x)*2 + (_y)*pitch)
 
 #define WRITE_DEPTH_SPAN()                                             \
    r128WriteDepthSpanLocked( rmesa, n,                                 \
@@ -168,8 +161,6 @@ do {                                                                        \
    GLint oy[MAX_WIDTH];                                                        \
    for ( i = 0 ; i < n ; i++ ) {                                       \
       ox[i] = x[i] + dPriv->x;                                         \
-   }                                                                   \
-   for ( i = 0 ; i < n ; i++ ) {                                       \
       oy[i] = Y_FLIP( y[i] ) + dPriv->y;                               \
    }                                                                   \
    r128WriteDepthPixelsLocked( rmesa, n, ox, oy, depth, mask );                \
@@ -198,8 +189,8 @@ do {                                                                        \
    GLint i, remaining = n;                                             \
                                                                        \
    while ( remaining > 0 ) {                                           \
-      GLint ox[MAX_WIDTH];                                             \
-      GLint oy[MAX_WIDTH];                                             \
+      GLint ox[128];                                                   \
+      GLint oy[128];                                                   \
       GLint count;                                                     \
                                                                        \
       if ( remaining <= 128 ) {                                                \
@@ -209,8 +200,6 @@ do {                                                                        \
       }                                                                        \
       for ( i = 0 ; i < count ; i++ ) {                                        \
         ox[i] = x[i] + dPriv->x;                                       \
-      }                                                                        \
-      for ( i = 0 ; i < count ; i++ ) {                                        \
         oy[i] = Y_FLIP( y[i] ) + dPriv->y;                             \
       }                                                                        \
                                                                        \
@@ -245,8 +234,6 @@ do {                                                                        \
    GLint oy[MAX_WIDTH];                                                        \
    for ( i = 0 ; i < n ; i++ ) {                                       \
       ox[i] = x[i] + dPriv->x;                                         \
-   }                                                                   \
-   for ( i = 0 ; i < n ; i++ ) {                                       \
       oy[i] = Y_FLIP( y[i] ) + dPriv->y;                               \
    }                                                                   \
    r128WriteDepthPixelsLocked( rmesa, n, ox, oy, depth, mask );                \
@@ -275,8 +262,8 @@ do {                                                                        \
    GLint i, remaining = n;                                             \
                                                                        \
    while ( remaining > 0 ) {                                           \
-      GLint ox[MAX_WIDTH];                                             \
-      GLint oy[MAX_WIDTH];                                             \
+      GLint ox[128];                                                   \
+      GLint oy[128];                                                   \
       GLint count;                                                     \
                                                                        \
       if ( remaining <= 128 ) {                                                \
@@ -286,8 +273,6 @@ do {                                                                        \
       }                                                                        \
       for ( i = 0 ; i < count ; i++ ) {                                        \
         ox[i] = x[i] + dPriv->x;                                       \
-      }                                                                        \
-      for ( i = 0 ; i < count ; i++ ) {                                        \
         oy[i] = Y_FLIP( y[i] ) + dPriv->y;                             \
       }                                                                        \
                                                                        \
@@ -316,13 +301,6 @@ do {                                                                       \
 /* FIXME: Add support for hardware stencil buffers.
  */
 
-
-/* 32 bit depthbuffer functions */
-#define WRITE_DEPTH(_x, _y, d)                                                \
-    *(GLuint *)(buf + _x*4 + _y*pitch) = d
-
-
-
 /*
  * This function is called to specify which buffer to read and write
  * for software rasterization (swrast) fallbacks.  This doesn't necessarily
@@ -358,6 +336,20 @@ static void r128DDSetBuffer( GLcontext *ctx,
    }
 }
 
+void r128SpanRenderStart( GLcontext *ctx )
+{
+   r128ContextPtr rmesa = R128_CONTEXT(ctx);
+   FLUSH_BATCH(rmesa);
+   LOCK_HARDWARE(rmesa);
+   r128WaitForIdleLocked( rmesa );
+}
+
+void r128SpanRenderFinish( GLcontext *ctx )
+{
+   r128ContextPtr rmesa = R128_CONTEXT(ctx);
+   _swrast_flush( ctx );
+   UNLOCK_HARDWARE( rmesa );
+}
 
 void r128DDInitSpanFuncs( GLcontext *ctx )
 {
@@ -413,6 +405,8 @@ void r128DDInitSpanFuncs( GLcontext *ctx )
    swdd->WriteMonoCIPixels     = NULL;
    swdd->ReadCI32Span          = NULL;
    swdd->ReadCI32Pixels                = NULL;
+   swdd->SpanRenderStart       = r128SpanRenderStart;
+   swdd->SpanRenderFinish      = r128SpanRenderFinish;
 }
 
 
index 4a1015b9e4cf135db4ba9d57f6ee000b855e5086..c12ad0ccb0b8e7d9b914eb515b0f944ea62c24c2 100644 (file)
@@ -349,7 +349,6 @@ r128_fallback_tri( r128ContextPtr rmesa,
    _swsetup_Translate( ctx, v0, &v[0] );
    _swsetup_Translate( ctx, v1, &v[1] );
    _swsetup_Translate( ctx, v2, &v[2] );
-   /* XXX: SpanRenderStart */
    _swrast_Triangle( ctx, &v[0], &v[1], &v[2] );
 }