glBindVertexArray going crazy [solved: OS / Driver issue]

Started by obi, January 03, 2014, 08:01:12

Previous topic - Next topic

obi

I'm just wondering if someone might have a clue to why glBindVertexArray can behave like this? Can I have initialized one or more of the VAOs in a bad way?

My case:

I am generating 3D terrain where every chunk is a mesh and has one VAO. The only difference between the profiling cases is that I have rendered one extra row of terrain chunks. For some reason glBindVertexArray goes crazy.


Fool Running

Your initialization and rendering code (maybe just the code that binds the buffer) would help.
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

obi

Debuging my lib gives:


17:35:01 [main] DEBUG obigl.lwjgl.OGL - GL15.glGenBuffers() => 7
17:35:01 [main] DEBUG obigl.lwjgl.OGL - GL15.glBindBuffer( ELEMENT_ARRAY_BUFFER, 7 )
17:35:01 [main] DEBUG obigl.lwjgl.OGL - GL15.glBufferData( ELEMENT_ARRAY_BUFFER, 80000, DYNAMIC_DRAW )
17:35:01 [main] DEBUG obigl.lwjgl.OGL - GL15.glBufferSubData( ELEMENT_ARRAY_BUFFER, 0, java.nio.DirectByteBufferR[pos=0 lim=2352 cap=80000] )
17:35:01 [main] DEBUG obigl.lwjgl.OGL - GL15.glBindBuffer( ELEMENT_ARRAY_BUFFER, 0 )
17:35:01 [main] DEBUG obigl.lwjgl.OGL - GL15.glGenBuffers() => 8
17:35:01 [main] DEBUG obigl.lwjgl.OGL - GL15.glBindBuffer( ARRAY_BUFFER, 8 )
17:35:01 [main] DEBUG obigl.lwjgl.OGL - GL15.glBufferData( ARRAY_BUFFER, 108000, DYNAMIC_DRAW )
17:35:01 [main] DEBUG obigl.lwjgl.OGL - GL15.glBufferSubData( ARRAY_BUFFER, 0, java.nio.DirectByteBuffer[pos=0 lim=19104 cap=108000] )
17:35:01 [main] DEBUG obigl.lwjgl.OGL - GL15.glBindBuffer( ARRAY_BUFFER, 0 )

17:35:01 [main] DEBUG obigl.lwjgl.OGL - GL30.glGenVertexArrays() => 3
17:35:01 [main] DEBUG obigl.lwjgl.OGL - GL30.glBindVertexArray( 3 )
17:35:01 [main] DEBUG obigl.lwjgl.OGL - GL15.glBindBuffer( ELEMENT_ARRAY_BUFFER, 7 )
17:35:01 [main] DEBUG obigl.lwjgl.OGL - GL15.glBindBuffer( ARRAY_BUFFER, 8 )
17:35:01 [main] DEBUG obigl.lwjgl.OGL - GL20.glVertexAttribPointer( 0, 3, 5126, false, 24, 0 )
17:35:01 [main] DEBUG obigl.lwjgl.OGL - GL20.glEnableVertexAttribArray( 0 )
17:35:01 [main] DEBUG obigl.lwjgl.OGL - GL20.glVertexAttribPointer( 4, 3, 5126, false, 24, 12 )
17:35:01 [main] DEBUG obigl.lwjgl.OGL - GL20.glEnableVertexAttribArray( 4 )
17:35:01 [main] DEBUG obigl.lwjgl.OGL - GL11.glDrawArrays( TRIANGLES, 1176, UNSIGNED_SHORT, 0 )
17:35:01 [main] DEBUG obigl.lwjgl.OGL - GL30.glBindVertexArray( 0 )


any calls to draw terrain meshes after the initialization is simply this


17:35:01 [main] DEBUG obigl.lwjgl.OGL - GL30.glBindVertexArray( 3 )
17:35:01 [main] DEBUG obigl.lwjgl.OGL - GL11.glDrawArrays( TRIANGLES, 1176, UNSIGNED_SHORT, 0 )
17:35:01 [main] DEBUG obigl.lwjgl.OGL - GL30.glBindVertexArray( 0 )

obi

There is some very weird correlations to this issue arising when I have more than 255 meshes / VAOs visible during a frame.
I have to investigate further but right now it seems to weird to be a coincidence.

The thing is I know I have rendered with more than 255 VAOs every frame without problems so maybe it has to do with how many VAOs I can initialize during a single frame and not how many I display. Just speculation for now.

Edit: I have a 8800GTS with 512MB memory

obi

Yes it seems that as soon as I bind a VAO with an id bigger than 0xff(255) the glBindVertexArray call will spend more than 50-60% of all cpu time in kernel code. eg. red cpu usage in windows xp.

The thing is that I can use a lot of VAOs without any visual issues rendering. I know I have tried 1500 without problems.
On rare occasions I can render with 1000+ VAOs without spending most cpu time in kernel code. I have had this happen, that suddenly my app stops spending so much time in glBindVertexArray and my application runs smooth like a sport car! But this is pretty rare occasions.

I must figure out why so much time is spent in kernel code when running glBindVertexArray. Any suggestions how to debug this?

obi

I just upgraded to Windows 7 x64 from Windows XP x32.

This issue went away completely and the performance is awesome! It's actually so great I didn't expect to render realtime procedural terrain this fast on my old computer.

LWJGL really whips the llama's ass!  ;D