Hi,
I am using glDrawArraysInstanced on OSX Lion with the opengl core 3.2 profile, which works very great. I draw a lot of circles I basically use ARB_instanced_arrays glVertexAttribDivisorARB to pass a vec4 to the shader for each instance of the circle where xyz is the position and w the radius of the circle. I get a very good frame rate for up to 37364 instances, but as soon as I draw one more, it seems to fall back to software mode and about 4fps. If I batch them and call glDrawArraysInstanced twice, things work again. Is there any way to determine the maximum number of instances that can be drawn with one draw call of glDrawArraysInstanced so that the circles can be batched automatically? Here is some code:
Vertex Shader
Code :#version 150 uniform mat4 projection; uniform mat4 transform; in vec4 positionAndRadius; in vec4 vertex; void main() { vec4 p = vec4(vertex.xyz * positionAndRadius.w, 1.0); p += vec4(positionAndRadius.xyz, 0.0); gl_Position = projection * transform * p; }
this is basically how I setup the instanced vertex attribute pointer
Code :glVertexAttribPointer(loc, 4, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (char *)0); glEnableVertexAttribArray(loc); glVertexAttribDivisorARB(loc, 1);
It displays correctly, so I am pretty sure that I am hitting a hardware limitation or something. Is there any way to determine the maximum instances that glDrawArraysInstanced can handle? If not, is there a rule of thumb that I could hardcode?
Thank you!



Reply With Quote