[This topic was originally posted on rage3d, but I didn’t get any reply, so I’m afraid I have to ask it here again.]
Hi,
I’m running into problems with VBO on a Radeon Mobility 9000 and Cat 3.4 (modded to work with M9). I switched from VAO to VBO in my App, but the performance is not what I expected. So I decided to go for a simpler test case:
I’m getting the expected performance with VBO in most cases, but I’ve got one case where performance is disastrous.
If I use a vertex program that uses generic attributes and VBO ( glVertexAttribPointerARB) I’m getting frame rates that definitely indicate that something is going absolutely wrong. When I switch to a VP that uses conventional attributes (like vertex.position and uses glVertexPointer, glColorPointer) the performance is fine.
Here’s an excerpt of the vertex program and the code that does not work right:
!!ARBvp1.0
PARAM mvp[4] = { state.matrix.mvp };
MOV result.color,vertex.attrib[3];
DP4 result.position.x, mvp[0], vertex.attrib[0];
DP4 result.position.y, mvp[1], vertex.attrib[0];
DP4 result.position.z, mvp[2], vertex.attrib[0];
DP4 result.position.w, mvp[3], vertex.attrib[0];
END
glEnableVertexAttribArrayARB(0);
glEnableVertexAttribArrayARB(3);
glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboHandle);
glVertexAttribPointerARB(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (char*)0);
glVertexAttribPointerARB(3, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (char*)12);
glDrawElements(GL_TRIANGLES, n, GL_UNSIGNED_SHORT, &indices[0] );
glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0);
glDisableVertexAttribArrayARB(0);
glDisableVertexAttribArrayARB(3);
This code works right:
!!ARBvp1.0
PARAM mvp[4] = { state.matrix.mvp };
MOV result.color,vertex.color;
DP4 result.position.x, mvp[0], vertex.position;
DP4 result.position.y, mvp[1], vertex.position;
DP4 result.position.z, mvp[2], vertex.position;
DP4 result.position.w, mvp[3], vertex.position;
END
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboHandle);
glVertexPointer( 3,GL_FLOAT, sizeof(Vertex), (char*)0 );
glColorPointer( 3,GL_FLOAT, sizeof(Vertex), (char*)12 );
glDrawElements(GL_TRIANGLES, n, GL_UNSIGNED_SHORT, &indices[0] );
glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
For testing purposes I’ve hacked a small test program that you could (if you wanted to) download on http://home.augustakom.net/as120108/SimpleTest.zip
The console (which may be hidden behind the app window) prints the current fps and the mode used for rendering. With the space bar you can switch between standard vertex array, VBO and VAO. With ‘a’ you switch between using glVertexAttrib and standard arrays (glVertexPointer) (Keys must be pressed in the app window - not in the console).
My numbers are:
~8 fps for standard arrays and conventional attributes,
~42fps VBO for VBO and conventional attributes
~40 VAO for VAO and conventional attributes
~6 fps for standard array and generic attributes
~0.2 (!) for VBO and generic attributes
~40 for VAO and generic attributes
Any help is welcome!
Thanks,
Stefan