On Wed, 17 Jul 2002, Keith Whitwell wrote:

> Leif Delgass wrote:
> > On Wed, 17 Jul 2002, Leif Delgass wrote:
> > 
> > 
> >>On 17 Jul 2002, Michel Dänzer wrote:
> >>
> >>
> >>>On Wed, 2002-07-17 at 20:05, Keith Whitwell wrote:
> >>>
> >>>>I've fixed this for drivers that use t_dd_triemit.h -- currently only radeon 
> >>>>and r200.
> >>>>
> >>>Great job! The clipping problems I originally reported with the
> >>>xscreensaver gears hack and fsv are fixed.
> >>>
> >>I've applied this fix to the mach64 FastRenderClippedPoly function and 
> >>reverted my previous fix.
> >>
> >>I've tested the fix on r128 and it works there as well.  It looks like it 
> >>needs to be applied to all drivers with the FastRenderClippedPoly 
> >>function, but I can't test any of the other drivers.  
> >>
> >>There's another fix I made to the mach64 driver that I think needs to be
> >>applied to all drivers, and that's setting the read buffer equal to the
> >>draw buffer when switching draw buffers.  This fixes software fallbacks
> >>when drawing on the front buffer.  I've tested it on r128 and it works.  
> >>Should I try my hand at combining these into a single patch for all the
> >>drivers?
> > 
> > At any rate, the patch for r128 with the read buffer + flatshade fix is 
> > attached.  If nobody has any objections, I can commit this.  Maybe someone 
> > with access to other cards would like to try making the changes for other 
> > drivers? 
> 
> I've done all the others.  Lets see if testing was required...

So, should I commit the fix for r128?  I've tested that and it works fine.  

I took a look at the other drivers concerning the read buffer fix.  It
looks like mga, i810, and i830 already do this correctly.  Reading from a
separate read buffer doesn't seem to be implemented on tdfx and sis.  It
looks like ffb, gamma, r128, and radeon need the fix.  The attached patch
has fixes for all the drivers except sis (I included tdfx even though the
ReadBuffer isn't used).  I've tested the read buffer fix on mach64 and
r128 with texenv (single-buffer mode), checking to see that textures done
in software are correctly blended with the front buffer when the
background is turned off (the checker-board should show through in the
transparent areas).  You'd have to force a fallback to test this on Radeon
or other drivers without texture fallbacks.

-- 
Leif Delgass 
http://www.retinalburn.net

? current.diff
? r128/r128-drawbuffer+flatshade.diff
Index: ffb/ffb_state.c
===================================================================
RCS file: /cvsroot/dri/xc/xc/lib/GL/mesa/src/drv/ffb/ffb_state.c,v
retrieving revision 1.4
diff -u -r1.4 ffb_state.c
--- ffb/ffb_state.c     12 Jun 2002 15:50:25 -0000      1.4
+++ ffb/ffb_state.c     17 Jul 2002 20:25:24 -0000
@@ -477,20 +477,20 @@
        fprintf(stderr, "ffbDDSetDrawBuffer: mode(%s)\n",
                _mesa_lookup_enum_by_nr(buffer));
 #endif
-       fbc &= ~(FFB_FBC_WB_AB);
+       fbc &= ~(FFB_FBC_WB_AB | FFB_FBC_RB_MASK);
        switch (buffer) {
        case GL_FRONT_LEFT:
                if (fmesa->back_buffer == 0)
-                       fbc |= FFB_FBC_WB_B;
+                       fbc |= FFB_FBC_WB_B | FFB_FBC_RB_B;
                else
-                       fbc |= FFB_FBC_WB_A;
+                       fbc |= FFB_FBC_WB_A | FFB_FBC_RB_A;
                break;
 
        case GL_BACK_LEFT:
                if (fmesa->back_buffer == 0)
-                       fbc |= FFB_FBC_WB_A;
+                       fbc |= FFB_FBC_WB_A | FFB_FBC_RB_A;
                else
-                       fbc |= FFB_FBC_WB_B;
+                       fbc |= FFB_FBC_WB_B | FFB_FBC_RB_B;
                break;
 
        case GL_FRONT_AND_BACK:
Index: gamma/gamma_state.c
===================================================================
RCS file: /cvsroot/dri/xc/xc/lib/GL/mesa/src/drv/gamma/gamma_state.c,v
retrieving revision 1.2
diff -u -r1.2 gamma_state.c
--- gamma/gamma_state.c 14 Feb 2002 01:59:52 -0000      1.2
+++ gamma/gamma_state.c 17 Jul 2002 20:25:28 -0000
@@ -1047,10 +1047,10 @@
 
    switch ( mode ) {
    case GL_FRONT_LEFT:
-      gmesa->drawOffset = 0;
+      gmesa->drawOffset = gmesa->readOffset = 0;
       break;
    case GL_BACK_LEFT:
-      gmesa->drawOffset = gmesa->driScreen->fbHeight * gmesa->driScreen->fbWidth * 
gmesa->gammaScreen->cpp; 
+      gmesa->drawOffset = gmesa->readOffset = gmesa->driScreen->fbHeight * 
+gmesa->driScreen->fbWidth * gmesa->gammaScreen->cpp; 
       break;
    }
 
Index: r128/r128_state.c
===================================================================
RCS file: /cvsroot/dri/xc/xc/lib/GL/mesa/src/drv/r128/r128_state.c,v
retrieving revision 1.22
diff -u -r1.22 r128_state.c
--- r128/r128_state.c   12 Jun 2002 15:50:25 -0000      1.22
+++ r128/r128_state.c   17 Jul 2002 20:25:37 -0000
@@ -689,13 +689,13 @@
 
       switch ( mode ) {
       case GL_FRONT_LEFT:
-        rmesa->drawOffset = rmesa->r128Screen->frontOffset;
-        rmesa->drawPitch  = rmesa->r128Screen->frontPitch;
+        rmesa->drawOffset = rmesa->readOffset = rmesa->r128Screen->frontOffset;
+        rmesa->drawPitch  = rmesa->readPitch  = rmesa->r128Screen->frontPitch;
         FALLBACK( rmesa, R128_FALLBACK_DRAW_BUFFER, GL_FALSE );
         break;
       case GL_BACK_LEFT:
-        rmesa->drawOffset = rmesa->r128Screen->backOffset;
-        rmesa->drawPitch  = rmesa->r128Screen->backPitch;
+        rmesa->drawOffset = rmesa->readOffset = rmesa->r128Screen->backOffset;
+        rmesa->drawPitch  = rmesa->readPitch  = rmesa->r128Screen->backPitch;
         FALLBACK( rmesa, R128_FALLBACK_DRAW_BUFFER, GL_FALSE );
         break;
       default:
Index: r128/r128_tris.c
===================================================================
RCS file: /cvsroot/dri/xc/xc/lib/GL/mesa/src/drv/r128/r128_tris.c,v
retrieving revision 1.17
diff -u -r1.17 r128_tris.c
--- r128/r128_tris.c    2 Jun 2002 16:00:43 -0000       1.17
+++ r128/r128_tris.c    17 Jul 2002 20:25:37 -0000
@@ -501,9 +501,9 @@
    rmesa->num_verts += (n-2) * 3;
 
    for (i = 2 ; i < n ; i++) {
-      COPY_DWORDS( j, vb, vertsize, (r128VertexPtr) start );
       COPY_DWORDS( j, vb, vertsize, (r128VertexPtr) VERT(elts[i-1]) );
       COPY_DWORDS( j, vb, vertsize, (r128VertexPtr) VERT(elts[i]) );
+      COPY_DWORDS( j, vb, vertsize, (r128VertexPtr) start );
    }
 }
 
Index: radeon/radeon_state.c
===================================================================
RCS file: /cvsroot/dri/xc/xc/lib/GL/mesa/src/drv/radeon/radeon_state.c,v
retrieving revision 1.16
diff -u -r1.16 radeon_state.c
--- radeon/radeon_state.c       26 Jun 2002 08:32:31 -0000      1.16
+++ radeon/radeon_state.c       17 Jul 2002 20:25:44 -0000
@@ -1552,6 +1552,8 @@
        rmesa->state.color.drawOffset = rmesa->radeonScreen->frontOffset;
        rmesa->state.color.drawPitch  = rmesa->radeonScreen->frontPitch;
       }
+      rmesa->state.pixel.readOffset = rmesa->state.color.drawOffset;
+      rmesa->state.pixel.readPitch = rmesa->state.color.drawPitch;
       radeonSetCliprects( rmesa, GL_FRONT_LEFT );
       break;
    case GL_BACK_LEFT:
@@ -1563,6 +1565,8 @@
         rmesa->state.color.drawOffset = rmesa->radeonScreen->backOffset;
         rmesa->state.color.drawPitch  = rmesa->radeonScreen->backPitch;
       }
+      rmesa->state.pixel.readOffset = rmesa->state.color.drawOffset;
+      rmesa->state.pixel.readPitch = rmesa->state.color.drawPitch;
       radeonSetCliprects( rmesa, GL_BACK_LEFT );
       break;
    default:
Index: tdfx/tdfx_state.c
===================================================================
RCS file: /cvsroot/dri/xc/xc/lib/GL/mesa/src/drv/tdfx/tdfx_state.c,v
retrieving revision 1.14
diff -u -r1.14 tdfx_state.c
--- tdfx/tdfx_state.c   12 Jun 2002 15:50:27 -0000      1.14
+++ tdfx/tdfx_state.c   17 Jul 2002 20:25:44 -0000
@@ -1008,13 +1008,13 @@
 
    switch( mode) {
    case GL_FRONT_LEFT:
-      fxMesa->DrawBuffer = GR_BUFFER_FRONTBUFFER;
+      fxMesa->DrawBuffer = fxMesa->ReadBuffer = GR_BUFFER_FRONTBUFFER;
       fxMesa->new_state |= TDFX_NEW_RENDER;
       FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_FALSE );
       break;
 
    case GL_BACK_LEFT:
-      fxMesa->DrawBuffer = GR_BUFFER_BACKBUFFER;
+      fxMesa->DrawBuffer = fxMesa->ReadBuffer = GR_BUFFER_BACKBUFFER;
       fxMesa->new_state |= TDFX_NEW_RENDER;
       FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_FALSE );
       break;

Reply via email to