Browse Source
Made polygon building faster by checking ahead of time if we have enough primitive buffer space, instead of checking it per polygon.
Made polygon building faster by checking ahead of time if we have enough primitive buffer space, instead of checking it per polygon.
Also the primitive buffer management is now all done through inline functions.tess_experiment
3 changed files with 36 additions and 47 deletions
@ -1,38 +1,14 @@ |
|||||
#include "common.h" |
#include "common.h" |
||||
#include "memory.h" |
#include "memory.h" |
||||
|
|
||||
#define PRIMBUFLEN 131072 // TODO: optimize this for a typical scene |
|
||||
|
|
||||
static char primbuff[2][PRIMBUFLEN]; // Primitive buffer, just a raw buffer of bytes to use as a pool for primitives |
static char primbuff[2][PRIMBUFLEN]; // Primitive buffer, just a raw buffer of bytes to use as a pool for primitives |
||||
static char *nextpri; |
|
||||
static char *primbuff_bounds; |
|
||||
|
char *nextprim; |
||||
|
char *primbuf_bounds; |
||||
|
|
||||
u_char* const scratchpad = (char*)0x1F800000; |
u_char* const scratchpad = (char*)0x1F800000; |
||||
|
|
||||
void *mem_scratch(char **scratch_offset, unsigned short size) |
|
||||
{ |
|
||||
#if _DEBUG |
|
||||
if (*scratch_offset + size > scratchpad + 1024) |
|
||||
return NULL; |
|
||||
#endif |
|
||||
|
|
||||
void *result = *scratch_offset; |
|
||||
*scratch_offset += size; |
|
||||
return result; |
|
||||
} |
|
||||
|
|
||||
void mem_prim_reset(int db) |
void mem_prim_reset(int db) |
||||
{ |
{ |
||||
nextpri = primbuff[db]; |
|
||||
primbuff_bounds = nextpri + PRIMBUFLEN; |
|
||||
} |
|
||||
|
|
||||
void *mem_prim(size_t size) |
|
||||
{ |
|
||||
if (nextpri + size > primbuff_bounds) |
|
||||
return NULL; // TODO: report error |
|
||||
|
|
||||
void *prim = nextpri; |
|
||||
nextpri += size; |
|
||||
return prim; |
|
||||
|
nextprim = primbuff[db]; |
||||
|
primbuf_bounds = nextprim + PRIMBUFLEN; |
||||
} |
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue