I'm trying to use
glMultiDrawArraysIndirect to render a batch of object.
In my example I have a cube and a sphere (in this order) in a
VBO and a
GL_SHADER_STORAGE_BUFFER (SSBO) that contains matrix transforms as well as a
GL_DRAW_INDIRECT_BUFFER (DIB) that contains the draw commands.
The allocation of both the
DIB are managed by a custom class.
I can currently render both objects successfully, each using their own transform. The problem I'm encountering is rendering just the sphere by specifying an offset. As per the OpenGL spec:
If a buffer is bound to the
GL_DRAW_INDIRECT_BUFFERbinding at the time of a call to glMultiDrawArraysIndirect, indirect is interpreted as an offset, in basic machine units, into that buffer and the parameter data is read from the buffer rather than from client memory.
but doing the following code to render results in nothing being rendered:
// Calculates the offset & size and calls BindBufferRange this->_indrMatrixBuffer.BindBufferRange(0, 1, 1); // A simple call to glBindBuffer, binding to GL_DRAW_INDIRECT_BUFFER this->_indrBuffer.BindBuffer(); // Render glMultiDrawArraysIndirect(GL_TRIANGLES, (void*)sizeof(DAICmd), 1, 0);
DAICmd is a struct of four
unsigned int (as per the spec)
At first I though it might be my custom class but calling
glMultiDrawArraysIndirect(GL_TRIANGLES, 0, 1, 0); and keeping the matrix buffer offset renders the cube in the spheres position!
What am I missing to get this to work?
- Both the
DIBare mapped using the flags
GL_MAP_WRITE_BIT, GL_MAP_PERSISTENT_BIT and GL_MAP_COHERENT_BITand are created with the same flags plus
- I'm using OpenGL 4.5
glMultiDrawArraysIndirect(GL_TRIANGLES, (void*)sizeof(DAICmd), 1, 0);does not produce an error when using
- Using KHR_debug produces no errors either