-
I've just checked it. Unfortunately performance stays exactly the same.
-
I've experienced the same - Though not with UBOs by normal VBOs. I had to stop using buffer mapping for that reason and only rely on subbufferdata.
What I think is happening is that the Nvidia drivers are trying to be clever (I'm guessing you're using Nvidia like me). It's my experience that Nvidia doesn't care about the buffer usage and changes type as they see fit.
My advice would be to steer clear of mapping GL buffers and handle it yourself.
-
Buffers are not designed to be updated per draw call but per frame... In your case the texture buffer will be more suitable because you won't be limited by the 64K size and the 256byte alignment.
// update matrices in TBO / UBO
glBindBuffer(GL_TEXTURE_BUFFER, tbo);
float4x4 *mats = (float4x4*)glMapBufferRange(GL_TEXTURE_BUFFER, 0, size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
float4x4 *e = mats + num_instances;
while(mats != e) {
*mats++ = compute instance matrix;
}
glUnmapBuffer(GL_TEXTURE_BUFFER);
// render meshes
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_BUFFER, tb); // bind texture buffer created by glTexBuffer
glUniform1i(your_shader_sampler_uni, 0); // set texture channel for shader sampler
for(...) {
glUniform1i(your_mesh_id_uni, id); // or use glVertexAttribI1i(15, id)
glDrawRangeElements(...);
}
// in shader
mat4 tm = mat4(
texelFetch(tb, your_mesh_id * 4),
texelFetch(tb, your_mesh_id * 4 + 1),
texelFetch(tb, your_mesh_id * 4 + 2),
texelFetch(tb, your_mesh_id * 4 + 3));
You can find more about buffers in free chapter from OpenGL Insights
http://www.seas.upenn.edu/~pcozzi/Op...rTransfers.pdf
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules