Merge branch 'FasterImmediate' into 'master'

Immediate mode: Only update attribute pointers at end instead of per vertex

See merge request simulant/GLdc!121
This commit is contained in:
Luke Benstead 2024-08-11 11:14:54 +00:00
commit e6ecfe64ba

View File

@ -171,13 +171,6 @@ void APIENTRY glVertex3f(GLfloat x, GLfloat y, GLfloat z) {
IMVertex* vert = aligned_vector_extend(&VERTICES, 1);
/* Resizing could've invalidated the pointers */
IM_ATTRIBS.vertex.ptr = VERTICES.data;
IM_ATTRIBS.uv.ptr = IM_ATTRIBS.vertex.ptr + 12;
IM_ATTRIBS.st.ptr = IM_ATTRIBS.uv.ptr + 8;
IM_ATTRIBS.colour.ptr = IM_ATTRIBS.st.ptr + 8;
IM_ATTRIBS.normal.ptr = IM_ATTRIBS.colour.ptr + 4;
punned_t dest = { .flt = &vert->x };
*(dest.flt++) = x;
*(dest.flt++) = y;
@ -262,6 +255,13 @@ void APIENTRY glNormal3fv(const GLfloat* v) {
void APIENTRY glEnd() {
IMMEDIATE_MODE_ACTIVE = GL_FALSE;
/* Resizing could've invalidated the pointers */
IM_ATTRIBS.vertex.ptr = VERTICES.data;
IM_ATTRIBS.uv.ptr = IM_ATTRIBS.vertex.ptr + 12;
IM_ATTRIBS.st.ptr = IM_ATTRIBS.uv.ptr + 8;
IM_ATTRIBS.colour.ptr = IM_ATTRIBS.st.ptr + 8;
IM_ATTRIBS.normal.ptr = IM_ATTRIBS.colour.ptr + 4;
GLuint* attrs = &ENABLED_VERTEX_ATTRIBUTES;
/* Redirect attrib pointers */