Re: [Dri-devel] [PATCH] texmem-0-0-1 branch
Attached is the patch with the modifications you suggested. --Leif On Mon, 3 Feb 2003, Ian Romanick wrote: > Leif Delgass wrote: > > > It this looks OK, I will apply it to the branch. > > I've poked around with the patch, and it looks good. There are only two > things that I would change. There should probably be a comment in > texmem.h that explains the double-duty that tObj does. I think the > meaning of t->tObj == NULL is important to document. > > I would also probably change printLocalLRU and printGlobalLRU to take a > pointer to __FUNCTION__ and log that in their printfs. I remember > making that change to the version in the r100 driver when I was first > mucking with the texmem stuff. That proved very useful when I was > trying to figure out how it all worked. :) > > Nice work! > > > > --- > This SF.NET email is sponsored by: > SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See! > http://www.vasoftware.com > ___ > Dri-devel mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/dri-devel > -- Leif Delgass http://www.retinalburn.net Index: lib/GL/mesa/src/drv/common/texmem.c === RCS file: /cvsroot/dri/xc/xc/lib/GL/mesa/src/drv/common/Attic/texmem.c,v retrieving revision 1.1.2.8 diff -u -r1.1.2.8 texmem.c --- lib/GL/mesa/src/drv/common/texmem.c 27 Jan 2003 23:43:31 - 1.1.2.8 +++ lib/GL/mesa/src/drv/common/texmem.c 4 Feb 2003 16:46:53 - @@ -119,12 +119,10 @@ static void resetGlobalLRU( driTexHeap * heap ) { - driTexRegion * list = heap->global_regions; + drmTextureRegionPtr list = heap->global_regions; unsigned sz = 1U << heap->logGranularity; unsigned i; - heap->local_age = ++heap->global_age[0]; - for (i = 0 ; (i+1) * sz <= heap->size ; i++) { list[i].prev = i-1; list[i].next = i+1; @@ -140,7 +138,76 @@ heap->global_age[0] = 0; } +/** + * Print out debugging information about the local texture LRU. + * + * \param heap Texture heap to be printed + */ +static void printLocalLRU( driTexHeap * heap, const char *callername ) +{ + driTextureObject *t; + unsigned sz = 1U << heap->logGranularity; + fprintf( stderr, "%s in %s:\nLocal LRU, heap %d:\n", + __FUNCTION__, callername, heap->heapId ); + + foreach ( t, &heap->texture_objects ) { + if (!t->memBlock) +continue; + if (!t->tObj) { +fprintf( stderr, "Placeholder (%p) %d at 0x%x sz 0x%x\n", + t, + t->memBlock->ofs / sz, + t->memBlock->ofs, + t->memBlock->size ); + } else { +fprintf( stderr, "Texture (%p) at 0x%x sz 0x%x\n", + t, + t->memBlock->ofs, + t->memBlock->size ); + } + } + foreach ( t, heap->swapped_objects ) { + if (!t->tObj) { +fprintf( stderr, "Swapped Placeholder (%p)\n", t ); + } else { +fprintf( stderr, "Swapped Texture (%p)\n", t ); + } + } + + fprintf( stderr, "\n" ); +} + +/** + * Print out debugging information about the global texture LRU. + * + * \param heap Texture heap to be printed + */ +static void printGlobalLRU( driTexHeap * heap, const char *callername ) +{ + drmTextureRegionPtr list = heap->global_regions; + int i, j; + + fprintf( stderr, "%s in %s:\nGlobal LRU, heap %d list %p:\n", + __FUNCTION__, callername, heap->heapId, list ); + + for ( i = 0, j = heap->nrRegions ; i < heap->nrRegions ; i++ ) { + fprintf( stderr, "list[%d] age %d next %d prev %d in_use %d\n", + j, list[j].age, list[j].next, list[j].prev, list[j].in_use ); + j = list[j].next; + if ( j == heap->nrRegions ) break; + } + + if ( j != heap->nrRegions ) { + fprintf( stderr, "Loop detected in global LRU\n" ); + for ( i = 0 ; i < heap->nrRegions ; i++ ) { +fprintf( stderr, "list[%d] age %d next %d prev %d in_use %d\n", + i, list[i].age, list[i].next, list[i].prev, list[i].in_use ); + } + } + + fprintf( stderr, "\n" ); +} /** @@ -152,7 +219,7 @@ void driUpdateTextureLRU( driTextureObject * t ) { driTexHeap * heap; -driTexRegion * list; +drmTextureRegionPtr list; unsigned shift; unsigned start; unsigned end; @@ -194,6 +261,12 @@ list[(unsigned)list[heap->nrRegions].next].prev = i; list[heap->nrRegions].next = i; } + + if ( 0 ) { + printGlobalLRU( heap, __FUNCTION__ ); + printLocalLRU( heap, __FUNCTION__ ); + } + } } @@ -326,7 +399,13 @@ } else { - driDestroyTextureObject( t ); +
Re: [Dri-devel] [PATCH] texmem-0-0-1 branch
Leif Delgass wrote: It this looks OK, I will apply it to the branch. I've poked around with the patch, and it looks good. There are only two things that I would change. There should probably be a comment in texmem.h that explains the double-duty that tObj does. I think the meaning of t->tObj == NULL is important to document. I would also probably change printLocalLRU and printGlobalLRU to take a pointer to __FUNCTION__ and log that in their printfs. I remember making that change to the version in the r100 driver when I was first mucking with the texmem stuff. That proved very useful when I was trying to figure out how it all worked. :) Nice work! --- This SF.NET email is sponsored by: SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See! http://www.vasoftware.com ___ Dri-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dri-devel
Re: [Dri-devel] [PATCH] texmem-0-0-1 branch
Leif Delgass wrote: Attached is a patch to the texmem branch with the changes we've been discussing. I'd still like to take a closer look at the global heap, but I've included the code to force initializing the global heap on the first lock contention for now. I've changed the drm/ddx/texmem code to use the drmTextureRegion/drm_tex_region_t struct for the SAREA and heap structures, but only for the drivers converted to the texmem interface. I also added a test to driAllocateTexture that deletes a placeholder (using t->tObj == NULL to detect a placeholder) instead of swapping it out. An explicit flag for detecting a placeholder might make the code more clear, but using t->tObj should work too. Since placeholders should never be on the swapped list now, I left in the assert for the swapped list being empty in the drivers' DestroyContext, though I added code to delete anything on the swapped list in driDestroyTextureHeap just in case that assertion would need to be removed for some reason. I've also included the optimization in driTexturesGone to keep an existing placeholder if the global region is in use and matches the size and offset of the existing placeholder. It this looks OK, I will apply it to the branch. I gave the patch a quick once-over, and it looks good so far. I'm going to study it a bit more carefully before the #dri-devel meeting. I do have a couple comments so far, but their pretty minor. I need to do some more testing on the Rage 128 driver, but so far things seem to be working except for the problem in the fire Mesa demo, which is still there. It kind of looks like a texture coordinate problem, but I'm not sure yet. Does r128 exhibit this problem on the trunk? --- This SF.NET email is sponsored by: SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See! http://www.vasoftware.com ___ Dri-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dri-devel
[Dri-devel] [PATCH] texmem-0-0-1 branch
Attached is a patch to the texmem branch with the changes we've been discussing. I'd still like to take a closer look at the global heap, but I've included the code to force initializing the global heap on the first lock contention for now. I've changed the drm/ddx/texmem code to use the drmTextureRegion/drm_tex_region_t struct for the SAREA and heap structures, but only for the drivers converted to the texmem interface. I also added a test to driAllocateTexture that deletes a placeholder (using t->tObj == NULL to detect a placeholder) instead of swapping it out. An explicit flag for detecting a placeholder might make the code more clear, but using t->tObj should work too. Since placeholders should never be on the swapped list now, I left in the assert for the swapped list being empty in the drivers' DestroyContext, though I added code to delete anything on the swapped list in driDestroyTextureHeap just in case that assertion would need to be removed for some reason. I've also included the optimization in driTexturesGone to keep an existing placeholder if the global region is in use and matches the size and offset of the existing placeholder. It this looks OK, I will apply it to the branch. I need to do some more testing on the Rage 128 driver, but so far things seem to be working except for the problem in the fire Mesa demo, which is still there. It kind of looks like a texture coordinate problem, but I'm not sure yet. -- Leif Delgass http://www.retinalburn.net Index: lib/GL/mesa/src/drv/common/texmem.c === RCS file: /cvsroot/dri/xc/xc/lib/GL/mesa/src/drv/common/Attic/texmem.c,v retrieving revision 1.1.2.8 diff -u -r1.1.2.8 texmem.c --- lib/GL/mesa/src/drv/common/texmem.c 27 Jan 2003 23:43:31 - 1.1.2.8 +++ lib/GL/mesa/src/drv/common/texmem.c 1 Feb 2003 21:39:55 - @@ -119,12 +119,10 @@ static void resetGlobalLRU( driTexHeap * heap ) { - driTexRegion * list = heap->global_regions; + drmTextureRegionPtr list = heap->global_regions; unsigned sz = 1U << heap->logGranularity; unsigned i; - heap->local_age = ++heap->global_age[0]; - for (i = 0 ; (i+1) * sz <= heap->size ; i++) { list[i].prev = i-1; list[i].next = i+1; @@ -140,7 +138,74 @@ heap->global_age[0] = 0; } +/** + * Print out debugging information about the local texture LRU. + * + * \param heap Texture heap to be printed + */ +static void printLocalLRU( driTexHeap * heap ) +{ + driTextureObject *t; + unsigned sz = 1U << heap->logGranularity; + fprintf( stderr, "Local LRU, heap %d:\n", heap->heapId ); + + foreach ( t, &heap->texture_objects ) { + if (!t->memBlock) +continue; + if (!t->tObj) { +fprintf( stderr, "Placeholder (%p) %d at 0x%x sz 0x%x\n", + t, + t->memBlock->ofs / sz, + t->memBlock->ofs, + t->memBlock->size ); + } else { +fprintf( stderr, "Texture (%p) at 0x%x sz 0x%x\n", + t, + t->memBlock->ofs, + t->memBlock->size ); + } + } + foreach ( t, heap->swapped_objects ) { + if (!t->tObj) { +fprintf( stderr, "Swapped Placeholder (%p)\n", t ); + } else { +fprintf( stderr, "Swapped Texture (%p)\n", t ); + } + } + + fprintf( stderr, "\n" ); +} + +/** + * Print out debugging information about the global texture LRU. + * + * \param heap Texture heap to be printed + */ +static void printGlobalLRU( driTexHeap * heap ) +{ + drmTextureRegionPtr list = heap->global_regions; + int i, j; + + fprintf( stderr, "Global LRU, heap %d list %p:\n", heap->heapId, list ); + + for ( i = 0, j = heap->nrRegions ; i < heap->nrRegions ; i++ ) { + fprintf( stderr, "list[%d] age %d next %d prev %d in_use %d\n", + j, list[j].age, list[j].next, list[j].prev, list[j].in_use ); + j = list[j].next; + if ( j == heap->nrRegions ) break; + } + + if ( j != heap->nrRegions ) { + fprintf( stderr, "Loop detected in global LRU\n" ); + for ( i = 0 ; i < heap->nrRegions ; i++ ) { +fprintf( stderr, "list[%d] age %d next %d prev %d in_use %d\n", + i, list[i].age, list[i].next, list[i].prev, list[i].in_use ); + } + } + + fprintf( stderr, "\n" ); +} /** @@ -152,7 +217,7 @@ void driUpdateTextureLRU( driTextureObject * t ) { driTexHeap * heap; -driTexRegion * list; +drmTextureRegionPtr list; unsigned shift; unsigned start; unsigned end; @@ -194,6 +259,12 @@ list[(unsigned)list[heap->nrRegions].next].prev = i; list[heap->nrRegions].next = i; } + + if ( 0 ) { + printGlobalLRU( heap ); + printLocalLRU( heap ); + } + } } @@ -326,7 +397,13