http://20030214.vip.sina.com/VBOSpeed.rar
Run VBOSpeed_r.exe, or compile it in VC7. You can see the result.
I tested it on Geforce4Max, Geforce3, Geforce FX5200, GeforceFx5800, ATI 7500,ATI 9200,ATI 9600,ATI 9700,ATI 9800se .
CPU is from P3 1G to P4 2.4G . Intel and AMD.
Reault is: when filling dynamic vertices less then 10000 .Software VB HAS THE TOP SPEED!
Here we go :
1)Software Vertex Buffer
float vertex[10003]
unsigned int index[10003]
…write something to vertex buffer
…write something to index buffer
glVertexPointer(3,GL_FLOAT,0,vertex);
glDrawElements(GL_TRIANGLES,1000,GL_UNSIGNED_INT,index);
2)Hardware Vertex Buffer with mapping
glBindBufferARB(GL_ARRAY_BUFFER_ARB,nVB);
float* vb = (float*)glMapBufferARB(GL_ARRAY_BUFFER_ARB,GL_WRITE_ONLY_ARB);
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB,nEB);
unsigned int* eb = (uint*)glMapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB,GL_WRITE_ONLY_ARB);
…write something to vb
…write something to eb
glVertexPointer(3,GL_FLOAT,0,0);
glDrawElements(GL_TRIANGLES,1000,GL_UNSIGNED_INT,0);
3)Hardware Vertex Buffer with SubData
float vertex[10003]
unsigned int index[10003]
glBindBufferARB(GL_ARRAY_BUFFER_ARB,nVB);
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB,nEB);
…write something to vertex
…write something to index
glBufferSubDataARB(GL_ARRAY_BUFFER_ARB,0,10003sizeof(float),vertex);
glBufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB,0,10003sizeof(unsigned int),index);
glVertexPointer(3,GL_FLOAT,0,0);
glDrawElements(GL_TRIANGLES,1000,GL_UNSIGNED_INT,0);
On all cards, hardware buffer with mapping is absolutely slower than software buffer.
The fastest is software buffer. 2nd is HW VBO with SubData!
If anyone can beat me, I am soooo glad cos I have to modify my codes to use software vb to render terrain, skeleton without VP ,and particle system. Please check my code.
My email is :
20030214@sina.com