Skip to content

Use VAOs for most vertex specification #1690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

VReaperV
Copy link
Contributor

Adds VAOs to VBO_t, most of the drawcalls will now set up their vertex format with one API call to bind the correct VAO. The exceptions are the default VAO (there are a bunch of places where different vertex state is set for it), and md3 models because the vertex animation requires respecifying the vertex format.

VReaperV added 3 commits June 30, 2025 13:27
Avoid circular dependencies when adding GLVAOs.
Use `R_CreateStaticIBO()` instead.
Faster since all of the required VAOs are prerecorded into each `VBO_t`. The exceptions are the default VAO, which switches its vertex arrays on/off, and md3 VAOs, because they require respecifying vertex attributes when animation frames change.
Copy link
Member

@slipher slipher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VAOs are said to require OpenGL 3.0 so do we need some feature test for 2.x compatibility?

@@ -445,6 +445,25 @@ IBO_t *R_CreateStaticIBO( const char *name, glIndex_t *indexes, int numIndexes )
return ibo;
}

void SetupVAOBuffers( VBO_t* VBO, const IBO_t* IBO, const uint32_t stateBits,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: SetUp - it's two words

@@ -706,6 +733,9 @@ void R_InitVBOs()
tess.ibo = R_CreateDynamicIBO( "tessVertexArray_IBO", SHADER_MAX_INDEXES );
}

SetupVAOBuffers( tess.vbo, tess.ibo, attribs, &tess.vbo->VAO );
tess.vbo->dynamicVAO = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any benefit to using the VAO if you are going to set all the vertex attributes every time anyway?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not every time IIRC.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean for the dynamicVAO = true case where it is every time AFAICT.

@VReaperV
Copy link
Contributor Author

VReaperV commented Jul 3, 2025

VAOs are said to require OpenGL 3.0 so do we need some feature test for 2.x compatibility?

Do we really care about 2.x compatibility?

@illwieckz
Copy link
Member

Is VAO an extension?

@VReaperV
Copy link
Contributor Author

VReaperV commented Jul 4, 2025

Is VAO an extension?

It's core functionality.

@illwieckz
Copy link
Member

Sorry, my question was ambiguous, I meant: is VAO available as an extension when core isn't there?

@VReaperV
Copy link
Contributor Author

VReaperV commented Jul 5, 2025

Sorry, my question was ambiguous, I meant: is VAO available as an extension when core isn't there?

Yes, there is GL_ARB_vertex_array_object.

@illwieckz
Copy link
Member

Mesa implements GL_ARB_vertex_array_object for all 2.1 devices I have looked for (Intel, Nvidia, ATI, Broadcom…), so we can fully go the VAO way. I guess such feature is just API implementation in the driver.

We don't need to deal with VAO being missing, we can assume it's there, and doing so even doesn't break our GL 2.1 compatibility.

We may just add the usual extension check for the VAO one to be there when GL is older than core, just for logging purpose.


R_BindVBO( VBO );

tess.settingUpVAO = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be an argument to GL_VertexAttribsState instead of a global variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants