On Tue, May 14, 2002 at 01:43:43AM +0200, Dieter Nützel wrote:
> If you've got a patch for me (against the trunk) I can throw same bigger 3D 
> med apps on my V5 5500 AGP.

Ok, thanks, heres what I've been running, this is basically changing
assert() to ASSERT() across the board in texman.c and changing the
actual assert that was failing into an if that unlocks things, dumps the
current texmem contents and should cleanly exit.

The last file in the patch (tdfx_driver.c) is currently forcing the
texSize to 0.38mb, adjust to taste (lower than that and q3 does the
clean exit described above) obviously that'll change to make that the
minimum if this works.

I've left in a hack to allow export TDFX_DEBUG_TEXTURE=something to
make it easy to switch on/off texture debugging. 

Should apply against xf_4_2-branch.

-- 
Michael.
Index: lib/GL/mesa/src/drv/tdfx/tdfx_context.c
===================================================================
RCS file: /cvs/xc/lib/GL/mesa/src/drv/tdfx/tdfx_context.c,v
retrieving revision 1.6
diff -u -3 -p -r1.6 tdfx_context.c
--- lib/GL/mesa/src/drv/tdfx/tdfx_context.c     2001/12/13 00:34:21     1.6
+++ lib/GL/mesa/src/drv/tdfx/tdfx_context.c     2002/05/14 00:10:31
@@ -260,6 +260,9 @@ GLboolean tdfxCreateContext( Display *dp
    fxMesa->buffer_used = 0;
 #endif
 
+   if (getenv("TDFX_DEBUG_TEXTURE"))
+          TDFX_DEBUG |= DEBUG_VERBOSE_TEXTURE;
+
    tdfxInitState( fxMesa );
 
    driContextPriv->driverPrivate = (void *) fxMesa;
Index: lib/GL/mesa/src/drv/tdfx/tdfx_context.h
===================================================================
RCS file: /cvs/xc/lib/GL/mesa/src/drv/tdfx/tdfx_context.h,v
retrieving revision 1.3
diff -u -3 -p -r1.3 tdfx_context.h
--- lib/GL/mesa/src/drv/tdfx/tdfx_context.h     2001/10/02 11:44:13     1.3
+++ lib/GL/mesa/src/drv/tdfx/tdfx_context.h     2002/05/14 00:10:32
@@ -967,7 +967,7 @@ static __inline__ GrColor_t tdfxPackColo
   }
 }
 
-#define DO_DEBUG               0
+#define DO_DEBUG               1
 #if DO_DEBUG
 extern int TDFX_DEBUG;
 #else
Index: lib/GL/mesa/src/drv/tdfx/tdfx_texman.c
===================================================================
RCS file: /cvs/xc/lib/GL/mesa/src/drv/tdfx/tdfx_texman.c,v
retrieving revision 1.4
diff -u -3 -p -r1.4 tdfx_texman.c
--- lib/GL/mesa/src/drv/tdfx/tdfx_texman.c      2001/08/18 02:51:07     1.4
+++ lib/GL/mesa/src/drv/tdfx/tdfx_texman.c      2002/05/14 00:10:33
@@ -60,16 +60,16 @@ static void tdfxTMVerifyFreeList( tdfxCo
    int totalUsed = 0;
 
    for ( block = tss->freeRanges[unit] ; block ; block = block->next ) {
-      assert( block->endAddr > 0 );
-      assert( block->startAddr <= tss->totalTexMem[unit] );
-      assert( block->endAddr <= tss->totalTexMem[unit] );
-      assert( (int) block->startAddr > prevStart );
-      assert( (int) block->startAddr >= prevEnd );
+      ASSERT( block->endAddr > 0 );
+      ASSERT( block->startAddr <= tss->totalTexMem[unit] );
+      ASSERT( block->endAddr <= tss->totalTexMem[unit] );
+      ASSERT( (int) block->startAddr > prevStart );
+      ASSERT( (int) block->startAddr >= prevEnd );
       prevStart = (int) block->startAddr;
       prevEnd = (int) block->endAddr;
       totalFree += (block->endAddr - block->startAddr);
    }
-   assert( totalFree == tss->freeTexMem[unit] );
+   ASSERT( totalFree == tss->freeTexMem[unit] );
 
    for ( texObj = ss->TexObjectList ; texObj ; texObj = texObj->Next ) {
       tdfxTexObjPtr t = TDFX_TEXTURE_DATA(texObj);
@@ -77,11 +77,11 @@ static void tdfxTMVerifyFreeList( tdfxCo
       if ( t ) {
         if ( t->isInTM ) {
            numRes++;
-           assert( t->range[0] );
+/*         ASSERT( t->range[0] ); */
            if ( t->range[unit] )
               totalUsed += (t->range[unit]->endAddr - t->range[unit]->startAddr);
         } else {
-           assert(!t->range[0]);
+           ASSERT(!t->range[0]);
         }
       }
    }
@@ -91,7 +91,7 @@ static void tdfxTMVerifyFreeList( tdfxCo
            tss->freeTexMem[unit], totalUsed, tss->totalTexMem[unit],
            numObj, numRes );
 
-   assert( totalUsed + totalFree == tss->totalTexMem[unit] );
+   ASSERT( totalUsed + totalFree == tss->totalTexMem[unit] );
 }
 
 static void tdfxTMDumpTexMem( tdfxContextPtr fxMesa )
@@ -112,7 +112,7 @@ static void tdfxTMDumpTexMem( tdfxContex
         printf( "  isInTM=%d  whichTMU=%ld  lastTimeUsed=%d\n",
                 t->isInTM, t->whichTMU, t->lastTimeUsed );
         printf( "    tm[0] = %p", t->range[0] );
-        assert( t->range[0] );
+/*      ASSERT( t->range[0] ); */
         if ( t->range[0] ) {
            printf( "  tm startAddr = %ld  endAddr = %ld",
                    t->range[0]->startAddr,
@@ -389,7 +389,11 @@ tdfxTMFindOldestObject( tdfxContextPtr f
             ( t->whichTMU == TDFX_TMU_SPLIT ) ) ) {
         GLuint age, lastTime;
 
-        assert( t->range[0] );
+/*      ASSERT( t->range[0] );*/
+        if (! t->range[unit] ) {
+               tdfxTMDumpTexMem ( fxMesa );
+               return NULL;
+        }
         lastTime = t->lastTimeUsed;
 
         if ( lastTime > bindNumber ) {
@@ -440,7 +444,7 @@ static FxU32 tdfxTMFindStartAddr( tdfxCo
    FxU32 result;
 
    if ( tss->umaTexMemory ) {
-      assert( unit == TDFX_TMU0 );
+      ASSERT( unit == TDFX_TMU0 );
    }
 
    _glthread_LOCK_MUTEX( ss->Mutex );
@@ -500,7 +504,7 @@ static void tdfxTMRemoveRangeLocked( tdf
    tdfxMemRange *block, *prev;
 
    if ( tss->umaTexMemory ) {
-      assert( unit == TDFX_TMU0 );
+      ASSERT( unit == TDFX_TMU0 );
    }
 
    if ( !range )
@@ -516,7 +520,7 @@ static void tdfxTMRemoveRangeLocked( tdf
    prev = NULL;
    block = tss->freeRanges[unit];
    while ( block ) {
-      assert( range->startAddr != block->startAddr );
+      ASSERT( range->startAddr != block->startAddr );
       if ( range->startAddr > block->startAddr ) {
         prev = block;
         block = block->next;
@@ -568,6 +572,8 @@ tdfxTMAllocTexMem( tdfxContextPtr fxMesa
       fprintf( stderr,
               "tdfxTMAllocTexMem returned NULL!  unit=%ld size=%ld\n",
               unit, size );
+      UNLOCK_HARDWARE( fxMesa );
+      exit( 1 );
    }
    return range;
 }
@@ -584,8 +590,8 @@ void tdfxTMDownloadTextureLocked( tdfxCo
    FxU32 targetTMU;
    GLint l;
 
-   assert( tObj );
-   assert( t );
+   ASSERT( tObj );
+   ASSERT( t );
 
    targetTMU = t->whichTMU;
 
@@ -833,7 +839,7 @@ void tdfxTMMoveOutTMLocked( tdfxContextP
 
    case TDFX_TMU_SPLIT:
    case TDFX_TMU_BOTH:
-      assert( !tss->umaTexMemory );
+      ASSERT( !tss->umaTexMemory );
       tdfxTMRemoveRangeLocked( fxMesa, TDFX_TMU0, t->range[TDFX_TMU0] );
       tdfxTMRemoveRangeLocked( fxMesa, TDFX_TMU1, t->range[TDFX_TMU1] );
       break;
Index: programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c
===================================================================
RCS file: /cvs/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c,v
retrieving revision 1.87
diff -u -3 -p -r1.87 tdfx_driver.c
--- programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c      2002/01/04 21:22:35    
 1.87
+++ programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c      2002/05/14 00:10:51
@@ -1971,6 +1971,8 @@ static void allocateMemory(ScrnInfoPtr p
        "\tresolution modes and/or a smaller virtual screen size\n");
   } else {
     pTDFX->texSize = pTDFX->backOffset - pTDFX->texOffset;
+    if (pTDFX->texSize > 256*256*6)
+           pTDFX->texSize = 256*256*6;
     xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Textures Memory %0.02f MB\n",
                (float)pTDFX->texSize/1024.0/1024.0);
   }

Reply via email to