Hi,
I’m still looking forward to a way to change independently the array buffer from the vertex layout. (GL_XXX_vertex_array_buffer_bindings :D)
A very easy way to make possible is to allows to the target GL_ARRAY_BUFFER with glBindBufferBase.
void glBindBufferBase(GLenum target, GLuint index, GLuint buffer);
void glVertexAttribPointer(
GLuint index,
GLint size,
GLenum type,
GLboolean normalized,
GLsizei stride,
const GLvoid * pointer);
Each array buffer is associated with glVertexAttribPointer vertex array format using the “index” slot.
void glBindBufferBase(GL_ARRAY_BUFFER, 0, Buffer) is equivalent to void glBindBuffer(GL_ARRAY_BUFFER, Buffer).
The current behavior and the new behavior need to co-exist for backward compatibility so that we need a way select the behavior.
One option is to reuse glEnableClientState and to create a new value to enable GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDINGS. This strategy has a precedent with glEnableClientState(GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV) from nVidia bindless graphics.
Another option is to create a new function glVertexArrayParameteri and a new boolean value GL_VERTEX_ARRAY_BUFFER_BINDINGS, default value being GL_FALSE.
It would be the occasion to bring DSA for vertex arrays into code.
Expected use:
glGenVertexArrays(1, VertexArray);
glBindVertexArrays(VertexArray);
glVertexArrayParameteri(VertexArray, GL_VERTEX_ARRAY_BUFFER_BINDINGS, GL_TRUE);
glVertexAttribPointer(
Index0,
Size0,
Type0,
GL_FALSE,
Stride0,
Offset0);
glVertexAttribPointer(
Index1,
Size1,
Type1,
GL_FALSE,
Stride1,
Offset1);
glBindVertexArrays(0);
glBindBufferBase(GL_ARRAY_BUFFER, 0, Buffer0);
glBindBufferBase(GL_ARRAY_BUFFER, 1, Buffer1);
The DSA version:
glGenVertexArrays(1, VertexArray);
glVertexArrayParameteri(VertexArray, GL_VERTEX_ARRAY_BUFFER_BINDINGS, GL_TRUE);
glVertexArrayVertexAttrib*Offset(
VertexArray,
Index0,
GLint size0,
GLenum type0,
GLsizei stride0,
GLintptr offset0);
glVertexArrayVertexAttrib*Offset(
VertexArray,
Index1,
GLint size1,
GLenum type1,
GLsizei stride1,
GLintptr offset1);
glBindBufferBase(GL_ARRAY_BUFFER, 0, Buffer0);
glBindBufferBase(GL_ARRAY_BUFFER, 1, Buffer1);
Buffer0 and Buffer1 could refer to the same buffer name.