If that made no sense and you need more detail, I’m trying out Rob Barris’ “Streaming VBO” technique described here in this thread (VBOs strangely slow?).
So, in code:
Init:
const unsigned STREAM_VBO_SIZE = 1*(1<<20) // i.e. 0x100000
glGenBuffers( 1, &vbo )
glBindBuffer( GL_ARRAY_BUFFER , vbo )
glBufferData( GL_ARRAY_BUFFER , STREAM_VBO_SIZE, 0, GL_DYNAMIC_DRAW )
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, vbo )
Draw Batch:
glBindBuffer ( GL_ARRAY_BUFFER , vbo )
glMapBufferRange( GL_ARRAY_BUFFER, 0xFFF80, 128,
( GL_MAP_WRITE_BIT |
GL_MAP_UNSYNCHRONIZED_BIT |
GL_MAP_INVALIDATE_RANGE_BIT ) )
<< fill buffer >>
glUnmapBuffer ( GL_ARRAY_BUFFER )
glVertexAttribPointer( 0, 3, GL_FLOAT, FALSE, 23, 0xFFF80 )
glVertexAttribPointer( 2, 3, GL_BYTE , TRUE , 23, 0xFFF8C )
glVertexAttribPointer( 8, 2, GL_FLOAT, FALSE, 23, 0xFFF8F )
glBindBuffer ( GL_ELEMENT_ARRAY_BUFFER, vbo )
glMapBufferRange( GL_ELEMENT_ARRAY_BUFFER, 0, 64,
( GL_MAP_WRITE_BIT |
GL_MAP_INVALIDATE_BUFFER_BIT ) )
<< fill buffer >>
glUnmapBuffer ( GL_ELEMENT_ARRAY_BUFFER )
glDrawRangeElements( GL_TRIANGLES, 0, 4, 6, GL_UNSIGNED_SHORT, 0x0 )
(Redundant glBindBuffer calls added to the Draw Batch code just for illustration clarity.)
As you can see, to force the scenario in question, I’ve carefully uploaded the vertex attrib block to the end of the VBO and latched the attribs from there. So now the VBO is “full” and we have to orphan. Then we upload the indices to the beginning of the fresh VBO and latch them with a draw call.
As I said, this results in a bonkers draw on NVidia (doesn’t crash, but yields garbage vertex positions/attribs). But if I don’t separate the vtx attribs and indices by an orphan, it works.
Anybody see something I’m missing here? My bug? NVidias? Or are we off in “unspecified behavior” land?