Allow configuring initial capacities

This commit is contained in:
Luke Benstead 2019-03-13 15:43:50 +00:00
parent d9539da841
commit 7c33f13438
4 changed files with 20 additions and 8 deletions

View File

@ -78,7 +78,10 @@ void APIENTRY glFinish() {
void APIENTRY glKosInitConfig(GLdcConfig* config) {
config->autosort_enabled = GL_FALSE;
config->initial_vbuf_capacity = 1024;
config->initial_op_capacity = 1024;
config->initial_pt_capacity = 512;
config->initial_tr_capacity = 1024;
config->initial_immediate_capacity = 1024;
config->internal_palette_format = GL_RGBA4;
}
@ -91,7 +94,7 @@ void APIENTRY glKosInitEx(GLdcConfig* config) {
_glInitAttributePointers();
_glInitContext();
_glInitLights();
_glInitImmediateMode();
_glInitImmediateMode(config->initial_immediate_capacity);
_glInitFramebuffers();
_glSetInternalPaletteFormat(config->internal_palette_format);
@ -106,9 +109,9 @@ void APIENTRY glKosInitEx(GLdcConfig* config) {
aligned_vector_init(&PT_LIST.vector, sizeof(ClipVertex));
aligned_vector_init(&TR_LIST.vector, sizeof(ClipVertex));
aligned_vector_reserve(&OP_LIST.vector, config->initial_vbuf_capacity);
aligned_vector_reserve(&PT_LIST.vector, config->initial_vbuf_capacity);
aligned_vector_reserve(&TR_LIST.vector, config->initial_vbuf_capacity);
aligned_vector_reserve(&OP_LIST.vector, config->initial_op_capacity);
aligned_vector_reserve(&PT_LIST.vector, config->initial_pt_capacity);
aligned_vector_reserve(&TR_LIST.vector, config->initial_tr_capacity);
}
void APIENTRY glKosInit() {

View File

@ -28,12 +28,18 @@ static GLfloat UV_COORD[2] = {0.0f, 0.0f};
static GLfloat ST_COORD[2] = {0.0f, 0.0f};
void _glInitImmediateMode() {
void _glInitImmediateMode(GLuint initial_size) {
aligned_vector_init(&VERTICES, sizeof(GLfloat));
aligned_vector_init(&COLOURS, sizeof(GLfloat));
aligned_vector_init(&UV_COORDS, sizeof(GLfloat));
aligned_vector_init(&ST_COORDS, sizeof(GLfloat));
aligned_vector_init(&NORMALS, sizeof(GLfloat));
aligned_vector_reserve(&VERTICES, initial_size);
aligned_vector_reserve(&COLOURS, initial_size);
aligned_vector_reserve(&UV_COORDS, initial_size);
aligned_vector_reserve(&ST_COORDS, initial_size);
aligned_vector_reserve(&NORMALS, initial_size);
}
GLubyte _glCheckImmediateModeInactive(const char* func) {

View File

@ -104,7 +104,7 @@ PolyList *_glTransparentPolyList();
void _glInitAttributePointers();
void _glInitContext();
void _glInitLights();
void _glInitImmediateMode();
void _glInitImmediateMode(GLuint initial_size);
void _glInitMatrices();
void _glInitFramebuffers();

View File

@ -46,7 +46,10 @@ typedef struct {
GLenum internal_palette_format;
/* Initial capacity of each of the OP, TR and PT lists in vertices */
GLuint initial_vbuf_capacity;
GLuint initial_op_capacity;
GLuint initial_tr_capacity;
GLuint initial_pt_capacity;
GLuint initial_immediate_capacity;
} GLdcConfig;