Just a side comment on Ian's excellent summary...
On Tue, Feb 12, 2002 at 11:45:58AM -0800, Ian Romanick wrote:
| - If an allocation (via the memHeap_t) fails when texture space is allocated
| (radeonUploadTexImages in lib/GL/mesa/src/drv/radeon/radeon_texmem.c),
| blocks at the end of the texList queue are freed until the allocation can
| succeed. This may be an area where the algorithm could be improved. For
| example, it might be better to find the largest free block (in the
| memHeap_t) and release memory around that block in LRU or least-often-used
| fashion until the allocation can succeed.
I spent some time last year looking into memory management issues for
OpenGL. One of the things I noticed was that most apps render the
primitives in a scene in roughly the same order from frame to frame.
Consequently textures are referenced in roughly the same order each time
a frame is drawn: T0, T1, T2, ...; T0, T1, T2, ... and so on.
If texture memory is overcommitted, then an LRU strategy yields a
pattern of memory management operations something like this:
Frame 0:
Load T0
Use T0
Load T1
Use T1
Unload T0 to generate free space for T2
Load T2
Use T2
Frame 1:
Unload T1 to generate free space for T0
Load T0
Use T0
Unload T2 to generate free space for T1
Load T1
Use T1
Unload T0 to generate free space for T2
Load T2
Use T2
All subsequent frames follow the pattern set by Frame 1. You need to
unload one or more textures each time you want to use new ones.
On the other hand, a LIFO strategy yields a pattern like this:
Frame 0:
Load T0
Use T0
Load T1
Use T1
Unload T1 to generate free space for T2
Load T2
Use T2
Frame 1:
(T0 is still loaded)
Use T0
Unload T2 to generate free space for T1
Load T1
Use T1
Unload T1 to generate free space for T2
Load T2
Use T2
Subsequent frames follow the pattern for Frame 1.
In this case LIFO saves one unload and one load per frame. In practice
the actual savings depend on the relative sizes of textures, the total
memory load, and memory fragmentation, of course. But in general, if
textures are re-used sequentially on each frame, LIFO is a better
strategy than LRU.
OpenGL needs mechanisms to provide better control over memory
allocation. There wasn't enough interest on the part of the vendors to
come to agreement on an extension for OpenGL 1.X, but the OpenGL 2.0
proposal does include new features for memory management.
Allen
_______________________________________________
Dri-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dri-devel