29 #include "../idlib/precompiled.h"
35 static const int FRAME_MEMORY_BYTES = 0x200000;
36 static const int EXPAND_HEADERS = 1024;
48 static void R_ListVertexCache_f(
const idCmdArgs &args ) {
59 common->
Error(
"idVertexCache Free: NULL pointer" );
74 #if 0 // this isn't really necessary, it will be reused soon enough
134 return (
void *)buffer->
offset;
164 common->
Printf(
"using ARB_vertex_buffer_object memory\n" );
168 common->
Printf(
"WARNING: vertex array range in virtual memory (SLOW)\n" );
231 common->
Error(
"idVertexCache::Alloc: size = %i\n", size );
240 for (
int i = 0;
i < EXPAND_HEADERS;
i++ ) {
309 common->
Error(
"idVertexCache Touch: NULL pointer" );
374 common->
Error(
"idVertexCache::AllocFrameTemp: size = %i\n", size );
381 Alloc( data, size, &block );
391 for (
int i = 0;
i < EXPAND_HEADERS;
i++ ) {
440 int staticUseCount = 0;
441 int staticUseSize = 0;
446 staticUseSize += block->size;
450 const char *frameOverflow =
tempOverflow ?
"(OVERFLOW)" :
"";
452 common->
Printf(
"vertex dynamic:%i=%ik%s, static alloc:%i=%ik used:%i=%ik total:%i=%ik\n",
455 staticUseCount, staticUseSize/1024,
510 int deferredSpace = 0;
516 totalStatic += block->
size;
518 frameStatic += block->
size;
522 int numFreeStaticHeaders = 0;
524 numFreeStaticHeaders++;
527 int numFreeDynamicHeaders = 0;
529 numFreeDynamicHeaders++;
534 common->
Printf(
"%5i active static headers\n", numActive );
535 common->
Printf(
"%5i free static headers\n", numFreeStaticHeaders );
536 common->
Printf(
"%5i free dynamic headers\n", numFreeDynamicHeaders );
539 common->
Printf(
"Vertex cache is in ARB_vertex_buffer_object memory (FAST).\n");
541 common->
Printf(
"Vertex cache is in virtual memory (SLOW)\n" );
idBlockAlloc< vertCache_t, 1024 > headerAllocator
idCVar r_useIndexBuffers("r_useIndexBuffers","0", CVAR_RENDERER|CVAR_ARCHIVE|CVAR_INTEGER,"use ARB_vertex_buffer_object for indexes", 0, 1, idCmdSystem::ArgCompletion_Integer< 0, 1 >)
static idCVar r_showVertexCache
idCVar r_useVertexBuffers("r_useVertexBuffers","1", CVAR_RENDERER|CVAR_INTEGER,"use ARB_vertex_buffer_object for vertexes", 0, 1, idCmdSystem::ArgCompletion_Integer< 0, 1 >)
struct vertCache_s * next
#define GL_ARRAY_BUFFER_ARB
#define GL_ELEMENT_ARRAY_BUFFER_ARB
vertCache_t freeDynamicHeaders
PFNGLBUFFERSUBDATAARBPROC qglBufferSubDataARB
struct vertCache_s * prev
int dynamicCountThisFrame
PFNGLGENBUFFERSARBPROC qglGenBuffersARB
bool ARBVertexBufferObjectAvailable
void SetInteger(const int value)
GLsizei GLsizei GLenum GLenum const GLvoid * data
int GetInteger(void) const
virtual void virtual void FatalError(const char *fmt,...) id_attribute((format(printf
void Touch(vertCache_t *buffer)
PFNGLBUFFERDATAARBPROC qglBufferDataARB
vertCache_t dynamicHeaders
virtual void Printf(const char *fmt,...) id_attribute((format(printf
static idCVar r_vertexBufferMegs
vertCache_t * AllocFrameTemp(void *data, int bytes)
virtual void VPCALL Memcpy(void *dst, const void *src, const int count)=0
void ActuallyFree(vertCache_t *block)
struct vertCache_s ** user
vertCache_t * tempBuffers[NUM_VERTEX_FRAMES]
vertCache_t freeStaticHeaders
void Alloc(void *data, int bytes, vertCache_t **buffer, bool indexBuffer=false)
void * Position(vertCache_t *buffer)
const int NUM_VERTEX_FRAMES
#define GL_DYNAMIC_DRAW_ARB
PFNGLBINDBUFFERARBPROC qglBindBufferARB
int dynamicAllocThisFrame
idVertexCache vertexCache
void SetBool(const bool value)
void * Mem_Alloc(const int size)
void Free(vertCache_t *buffer)
vertCache_t staticHeaders
#define GL_STATIC_DRAW_ARB
virtual void Error(const char *fmt,...) id_attribute((format(printf
#define GL_STREAM_DRAW_ARB
virtual void AddCommand(const char *cmdName, cmdFunction_t function, int flags, const char *description, argCompletion_t argCompletion=NULL)=0
bool allocatingTempBuffer
vertCache_t deferredFreeList
idSIMDProcessor * SIMDProcessor