User: Password:
|
|
Subscribe / Log in / New account

GEM v. TTM

GEM v. TTM

Posted May 30, 2008 5:42 UTC (Fri) by jzbiciak (subscriber, #5246)
Parent article: GEM v. TTM

The use of anonymous memory also raises some performance concerns: a first-person shooter game will not provide the same experience if its blood-and-gore textures must be continually paged in.

Ah, you brought back some nightmaresmemories...

//
// Z_Malloc
// You can pass a NULL user if the tag is < PU_PURGELEVEL.
//
#define MINFRAGMENT             64


void*
Z_Malloc
( int           size,
  int           tag,
  void*         user )
{
    int         extra;
    memblock_t* start;
    memblock_t* rover;
    memblock_t* newblock;
    memblock_t* base;

    size = (size + 3) & ~3;

    // scan through the block list,
    // looking for the first free block
    // of sufficient size,
    // throwing out any purgable blocks along the way.

    // account for size of block header
    size += sizeof(memblock_t);

    // if there is a free block behind the rover,
    //  back up over them
    base = mainzone->rover;
....

DOOM had a zone allocator setup where you could allocate purgable blocks. If you ran out of space, it's start purging space until there was room for the new allocation. Objects would register callbacks to handle being purged. :-)

The reason I remember it is that I had to hack around it when I made an embedded version of DOOM that directly memory mapped the WAD file rather than Z_Malloc'ing it. Finding all the places where WAD elements were being explicitly managed was no walk in the park. :-)


(Log in to post comments)


Copyright © 2018, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds