On Sun, Mar 10, 2002 at 10:44:00PM +0000, Keith Whitwell wrote:
> Nice.  How kludged is kludged?

Attached.

Most of it is just uncommenting what's already there, and adding a call
(probably in the wrong place as MakeCurrent seems to be called a lot,
hence the check added to avoid enabling over and over) if
RADEON_PAGEFLIP exists.  Plus sorting out drawOffset.

I removed what I assume is either for old clients or a bogus emit_state
call in the clear stuff, and I suspect an off-by-1 error somewhere,
which I hacked by removing the -1 from the x2,y2 figures (you get a
flashing line at the bottom and right of the screen otherwise)

Lots of things are broken about it (switching to a console, the obvious
effects with windowed apps, single buffered demos that don't call
glSwapBuffers don't display anything (there don't appear to be any none
doublebuffered visuals for the tests in the driver to ever fail?)

But it seems to work fine with q3, rtcw and fullscreen stuff.

Occasionally it exits on the dark side too no doubt a call to
CloseFullScreen would help.

At the moment 1024x768 (which I expected to get the biggest benefit)
hits lack of texture space and/or maybe depth clears / lack of
hierarchical z, even with the pixmap cache set to 1 page and low
texturing - at the mo this is still only a 2 or 3 fps gain there.

-- 
Michael.
Index: lib/GL/mesa/src/drv/radeon/radeon_context.c
===================================================================
RCS file: /cvsroot/dri/xc/xc/lib/GL/mesa/src/drv/radeon/radeon_context.c,v
retrieving revision 1.7.2.11
diff -u -3 -p -r1.7.2.11 radeon_context.c
--- lib/GL/mesa/src/drv/radeon/radeon_context.c 9 Mar 2002 00:40:41 -0000       
1.7.2.11
+++ lib/GL/mesa/src/drv/radeon/radeon_context.c 10 Mar 2002 23:03:57 -0000
@@ -71,6 +71,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 int RADEON_DEBUG = (0);
 #endif
 
+static GLboolean radeonOpenFullScreen( __DRIcontextPrivate *driContextPriv );
+static GLboolean radeonCloseFullScreen( __DRIcontextPrivate *driContextPriv );
 
 
 /* Return the width and height of the current color buffer.
@@ -631,6 +633,8 @@ radeonMakeCurrent( __DRIcontextPrivate *
         _mesa_set_viewport( newRadeonCtx->glCtx, 0, 0,
                             driDrawPriv->w, driDrawPriv->h );
       }
+   if (getenv("RADEON_PAGEFLIP"))
+      radeonOpenFullScreen ( driContextPriv ); 
    } else {
       _mesa_make_current( 0, 0 );
    }
@@ -652,13 +656,13 @@ radeonUnbindContext( __DRIcontextPrivate
 static GLboolean
 radeonOpenFullScreen( __DRIcontextPrivate *driContextPriv )
 {
-#if 0
+#if 1
    radeonContextPtr rmesa = (radeonContextPtr)driContextPriv->driverPrivate;
    GLint ret;
 
    /* FIXME: Do we need to check this?
     */
-   if ( !rmesa->glCtx->Visual.doubleBufferMode )
+   if ( !rmesa->glCtx->Visual.doubleBufferMode || rmesa->doPageFlip )
       return GL_TRUE;
 
    LOCK_HARDWARE( rmesa );
@@ -666,11 +670,12 @@ radeonOpenFullScreen( __DRIcontextPrivat
 
    /* Ignore errors.  If this fails, we simply don't do page flipping.
     */
-   ret = drmRadeonFullScreen( rmesa->driFd, GL_TRUE );
+   ret = drmRadeonFullScreen( rmesa->dri.fd, GL_TRUE );
 
    UNLOCK_HARDWARE( rmesa );
 
    rmesa->doPageFlip = ( ret == 0 );
+   rmesa->currentPage = 0;
 #endif
    return GL_TRUE;
 }
@@ -680,7 +685,7 @@ radeonOpenFullScreen( __DRIcontextPrivat
 static GLboolean
 radeonCloseFullScreen( __DRIcontextPrivate *driContextPriv )
 {
-#if 0
+#if 1
    radeonContextPtr rmesa = (radeonContextPtr)driContextPriv->driverPrivate;
 
    LOCK_HARDWARE( rmesa );
@@ -688,7 +693,7 @@ radeonCloseFullScreen( __DRIcontextPriva
 
    /* Don't care if this fails, we're not page flipping anymore.
     */
-   drmRadeonFullScreen( rmesa->driFd, GL_FALSE );
+   drmRadeonFullScreen( rmesa->dri.fd, GL_FALSE );
 
    UNLOCK_HARDWARE( rmesa );
 
Index: lib/GL/mesa/src/drv/radeon/radeon_span.c
===================================================================
RCS file: /cvsroot/dri/xc/xc/lib/GL/mesa/src/drv/radeon/radeon_span.c,v
retrieving revision 1.11.2.1
diff -u -3 -p -r1.11.2.1 radeon_span.c
--- lib/GL/mesa/src/drv/radeon/radeon_span.c    20 Feb 2002 01:06:32 -0000      
1.11.2.1
+++ lib/GL/mesa/src/drv/radeon/radeon_span.c    10 Mar 2002 23:03:57 -0000
@@ -292,12 +292,22 @@ static void radeonSetReadBuffer( GLconte
 
    switch ( mode ) {
    case GL_FRONT_LEFT:
-      rmesa->state.pixel.readOffset = rmesa->radeonScreen->frontOffset;
-      rmesa->state.pixel.readPitch  = rmesa->radeonScreen->frontPitch;
+      if ( rmesa->doPageFlip && rmesa->currentPage == 0 ) {
+        rmesa->state.color.drawOffset = rmesa->radeonScreen->backOffset;
+        rmesa->state.color.drawPitch  = rmesa->radeonScreen->backPitch;
+      } else {
+       rmesa->state.color.drawOffset = rmesa->radeonScreen->frontOffset;
+       rmesa->state.color.drawPitch  = rmesa->radeonScreen->frontPitch;
+      }
       break;
    case GL_BACK_LEFT:
-      rmesa->state.pixel.readOffset = rmesa->radeonScreen->backOffset;
-      rmesa->state.pixel.readPitch  = rmesa->radeonScreen->backPitch;
+      if ( rmesa->doPageFlip && rmesa->currentPage == 1 ) {
+       rmesa->state.color.drawOffset = rmesa->radeonScreen->frontOffset;
+       rmesa->state.color.drawPitch  = rmesa->radeonScreen->frontPitch;
+      } else {
+        rmesa->state.color.drawOffset = rmesa->radeonScreen->backOffset;
+        rmesa->state.color.drawPitch  = rmesa->radeonScreen->backPitch;
+      }
       break;
    default:
       assert(0);
Index: lib/GL/mesa/src/drv/radeon/radeon_state.c
===================================================================
RCS file: /cvsroot/dri/xc/xc/lib/GL/mesa/src/drv/radeon/radeon_state.c,v
retrieving revision 1.10.2.12
diff -u -3 -p -r1.10.2.12 radeon_state.c
--- lib/GL/mesa/src/drv/radeon/radeon_state.c   10 Mar 2002 20:15:25 -0000      
1.10.2.12
+++ lib/GL/mesa/src/drv/radeon/radeon_state.c   10 Mar 2002 23:03:58 -0000
@@ -1535,14 +1535,24 @@ static GLboolean radeonSetDrawBuffer( GL
    switch ( mode ) {
    case GL_FRONT_LEFT:
       FALLBACK( rmesa, RADEON_FALLBACK_DRAW_BUFFER, GL_FALSE );
-      rmesa->state.color.drawOffset = rmesa->radeonScreen->frontOffset;
-      rmesa->state.color.drawPitch  = rmesa->radeonScreen->frontPitch;
+      if ( rmesa->doPageFlip && rmesa->currentPage == 0 ) {
+        rmesa->state.color.drawOffset = rmesa->radeonScreen->backOffset;
+        rmesa->state.color.drawPitch  = rmesa->radeonScreen->backPitch;
+      } else {
+       rmesa->state.color.drawOffset = rmesa->radeonScreen->frontOffset;
+       rmesa->state.color.drawPitch  = rmesa->radeonScreen->frontPitch;
+      }
       radeonSetCliprects( rmesa, GL_FRONT_LEFT );
       break;
    case GL_BACK_LEFT:
       FALLBACK( rmesa, RADEON_FALLBACK_DRAW_BUFFER, GL_FALSE );
-      rmesa->state.color.drawOffset = rmesa->radeonScreen->backOffset;
-      rmesa->state.color.drawPitch  = rmesa->radeonScreen->backPitch;
+      if ( rmesa->doPageFlip && rmesa->currentPage == 1 ) {
+       rmesa->state.color.drawOffset = rmesa->radeonScreen->frontOffset;
+       rmesa->state.color.drawPitch  = rmesa->radeonScreen->frontPitch;
+      } else {
+        rmesa->state.color.drawOffset = rmesa->radeonScreen->backOffset;
+        rmesa->state.color.drawPitch  = rmesa->radeonScreen->backPitch;
+      }
       radeonSetCliprects( rmesa, GL_BACK_LEFT );
       break;
    default:
Index: programs/Xserver/hw/xfree86/drivers/ati/radeon_driver.c
===================================================================
RCS file: /cvsroot/dri/xc/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_driver.c,v
retrieving revision 1.19
diff -u -3 -p -r1.19 radeon_driver.c
--- programs/Xserver/hw/xfree86/drivers/ati/radeon_driver.c     27 Jan 2002 20:05:31 
-0000      1.19
+++ programs/Xserver/hw/xfree86/drivers/ati/radeon_driver.c     10 Mar 2002 23:04:07 
+-0000
@@ -2637,7 +2637,7 @@ Bool RADEONScreenInit(int scrnIndex, Scr
         * pixmap cache.  Should be enough for a fullscreen background
         * image plus some leftovers.
         */
-       info->textureSize = info->FbMapSize - 6 * bufferSize;
+       info->textureSize = info->FbMapSize - 4 * bufferSize;
 
        /* If that gives us less than half the available memory, let's
         * be greedy and grab some more.  Sorry, I care more about 3D
Index: programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/radeon_state.c
===================================================================
RCS file: 
/cvsroot/dri/xc/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/radeon_state.c,v
retrieving revision 1.12.2.6
diff -u -3 -p -r1.12.2.6 radeon_state.c
--- programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/radeon_state.c      8 Mar 
2002 16:02:30 -0000       1.12.2.6
+++ programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/radeon_state.c      10 Mar 
+2002 23:04:15 -0000
@@ -51,7 +51,8 @@ static inline void radeon_emit_clip_rect
        OUT_RING( CP_PACKET0( RADEON_RE_TOP_LEFT, 0 ) );
        OUT_RING( (box->y1 << 16) | box->x1 );
        OUT_RING( CP_PACKET0( RADEON_RE_WIDTH_HEIGHT, 0 ) );
-       OUT_RING( ((box->y2 - 1) << 16) | (box->x2 - 1) );
+/*     OUT_RING( ((box->y2 - 1) << 16) | (box->x2 - 1) );*/
+       OUT_RING( (box->y2 << 16) | box->x2 );
        ADVANCE_RING();
 }
 
@@ -573,11 +596,12 @@ static void radeon_cp_dispatch_flip( drm
        radeon_cp_performance_boxes( dev_priv );
 #endif
 
-       BEGIN_RING( 6 );
+       BEGIN_RING( 4 );
 
        RADEON_WAIT_UNTIL_3D_IDLE();
+/*
        RADEON_WAIT_UNTIL_PAGE_FLIPPED();
-
+*/
        OUT_RING( CP_PACKET0( RADEON_CRTC_OFFSET, 0 ) );
 
        if ( dev_priv->current_page == 0 ) {
@@ -1101,6 +1125,7 @@ int radeon_cp_clear( struct inode *inode
 
        /* Needed for depth clears via triangles???
         */
+#if 0  
        if ( sarea_priv->dirty & ~RADEON_UPLOAD_CLIPRECTS ) {
                radeon_emit_state( dev_priv,
                                   &sarea_priv->context_state,
@@ -1112,7 +1137,7 @@ int radeon_cp_clear( struct inode *inode
                                       RADEON_UPLOAD_TEX2IMAGES |
                                       RADEON_REQUIRE_QUIESCENCE);
        }
-
+#endif
        radeon_cp_dispatch_clear( dev, &clear, depth_boxes );
 
        return 0;

Reply via email to