-
Notifications
You must be signed in to change notification settings - Fork 63
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
base: master
Are you sure you want to change the base?
Conversation
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.
There was a problem hiding this 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, |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Do we really care about 2.x compatibility? |
Is VAO an extension? |
It's core functionality. |
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. |
Mesa implements 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; |
There was a problem hiding this comment.
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.
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.