Horrific uniform buffers bug on NVidia drivers

Is anyone else experiencing errors with instanced rendering on NVidia drivers with OpenGL 2.1? I have objects randomly dancing around the screen, as if the matrix data in the uniform buffer is not being updated from the last batch. I tried an old application of mine that was working fine a year ago, and it displays the same error. The driver is 190.62 (the latest).

What kind of instancing are you using?

glDrawElementsInstancedARB() and using uniform buffers for storing the matrices.

I think this is a uniform buffer bug because it does not occur when I store the data in a float texture.

Smells like data layout problem. Check if you 're updating your uniform buffer correctly.

The same program worked perfectly with older drivers. It’s just an array of matrices, and the shader uses gl_Instance_ID for the index of the matrix:

bindable uniform mat4 instancematrix[ MAX_PASS_SIZE ];

Is anyone using bindable uniforms in OpenGL 2.1 with success?

Here is my code:

At startup create one uniform buffer and allocate the size:

glgetIntegerv GL_MAX_BINDABLE_UNIFORM_SIZE_EXT,Varptr TBatch.MaxPassSize' get max uniform buffer size
TBatch.MaxPassSize=Floor(TBatch.MaxPassSize/64)' divide by 64 for max number of instances
glgenbuffersarb 1,Varptr InstancingMatrixBuffer' create a buffer
glBindBufferARB GL_TEXTURE_BUFFER_EXT,InstancingMatrixBuffer' bind the buffer to the texture buffer slot
glBindBufferARB GL_UNIFORM_BUFFER_EXT,InstancingMatrixBuffer' bind the buffer to the uniform buffer slot
glBufferDataARB GL_UNIFORM_BUFFER_EXT,TBatch.MaxPassSize*64,Null,GL_STATIC_READ' set the buffer size

When each shader is loaded, set the uniform buffer:

glUniformBufferEXT program,uniform_InstanceMatrix.index,TWorld.InstancingMatrixBuffer

In the batch rendering routine, send the data to the uniform buffer:

glBufferDataARB GL_UNIFORM_BUFFER_EXT,count*64,Varptr instancematrix[n*MaxPassSize*16],GL_STATIC_READ

In the vertex shader, get the instance matrix:

mat=instancematrix[ gl_InstanceID ];

JoshKlint, can you provide me with some more details? you said it worked with older drivers. Do you know which version? A repro case with source code would be ideal so that we can debug this.

Thanks!
Barthold
(with my NVIDIA hat on)

Download the engine’s evaluation kit:
http://www.leadwerks.com/ccount/click.php?id=64

Open the SDK browser and click the “Demo Launcher” link. Run either scene with any settings.

JoshKlint,

Thanks for the pointer to the engine. We found the bug and are working on a fix.

regards,
Barthold
(with my NVIDIA hat on)

Thanks! Sorry I didn’t have time to produce a smaller example.