Note that there are some explanatory texts on larger screens.

plurals
  1. POOpenGL ES iOS drawing performance a lot slower with VBOs than without
    primarykey
    data
    text
    <p>I've recently changed drawing in my current project from standard drawing from a memory array to VBOs. To my surprise the framerate dropped significantly from 60fps to 30fps drawing a model with 1200verts 8 times. Doing further profiling showed that glDrawElements took 10 times as long when using VBOs compared to drawing from memory.</p> <p>I am really puzzled why this is happening. Does anyone know what could be the cause for a performance decrease?</p> <p>I am testing on an iPhone 5 running iOS 6.1.2.</p> <p>I've isolated my VBO handling into a single function where I create the vertex/index buffer once statically at the top of the function. I can switch between normal and VBO rendering with an #ifdef USE_VBO</p> <pre><code>- (void)drawDuck:(Toy*)toy reflection:(BOOL)reflection { ModelOBJ* model = _duck[0].model; int stride = sizeof(ModelOBJ::Vertex); #define USE_VBO #ifdef USE_VBO static bool vboInitialized = false; static unsigned int vbo, ibo; if (!vboInitialized) { vboInitialized = true; // Generate VBO glGenBuffers(1, &amp;vbo); int numVertices = model-&gt;getNumberOfVertices(); glBindBuffer(GL_ARRAY_BUFFER, vbo); glBufferData(GL_ARRAY_BUFFER, stride*numVertices, model-&gt;getVertexBuffer(), GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); // Generate index buffer glGenBuffers(1, &amp;ibo); int numIndices = model-&gt;getNumberOfIndices(); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(unsigned short)*numIndices, model-&gt;getIndexBuffer(), GL_STATIC_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); } #endif [self setupDuck:toy reflection:reflection]; #ifdef USE_VBO // Draw with VBO glBindBuffer(GL_ARRAY_BUFFER, vbo); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo); glEnableVertexAttribArray(GC_SHADER_ATTRIB_POSITION); glEnableVertexAttribArray(GC_SHADER_ATTRIB_NORMAL); glEnableVertexAttribArray(GC_SHADER_ATTRIB_TEX_COORD); glVertexAttribPointer(GC_SHADER_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, stride, (void*)offsetof(ModelOBJ::Vertex, position)); glVertexAttribPointer(GC_SHADER_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, stride, (void*)offsetof(ModelOBJ::Vertex, texCoord)); glVertexAttribPointer(GC_SHADER_ATTRIB_NORMAL, 3, GL_FLOAT, GL_FALSE, stride, (void*)offsetof(ModelOBJ::Vertex, normal)); glDrawElements(GL_TRIANGLES, model-&gt;getNumberOfIndices(), GL_UNSIGNED_SHORT, 0); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); #else // Draw with array glEnableVertexAttribArray(GC_SHADER_ATTRIB_POSITION); glEnableVertexAttribArray(GC_SHADER_ATTRIB_NORMAL); glEnableVertexAttribArray(GC_SHADER_ATTRIB_TEX_COORD); glVertexAttribPointer(GC_SHADER_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, stride, model-&gt;getVertexBuffer()-&gt;position); glVertexAttribPointer(GC_SHADER_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, stride, model-&gt;getVertexBuffer()-&gt;texCoord); glVertexAttribPointer(GC_SHADER_ATTRIB_NORMAL, 3, GL_FLOAT, GL_FALSE, stride, model-&gt;getVertexBuffer()-&gt;normal); glDrawElements(GL_TRIANGLES, model-&gt;getNumberOfIndices(), GL_UNSIGNED_SHORT, model-&gt;getIndexBuffer()); #endif } </code></pre> <p>ModelOBJ::Vertex is just 3,2,3 float for pos, texcoord, normal. Indices are ushort.</p> <p><strong>UPDATE:</strong> I've now wrapped the draw setup (ie. the attrib binding calls) into an VAO and now performance is ok, even slightly better than drawing from main memory. So my conclusion is that VBO support without VAOs is broken on iOS. Is that assumption correct?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload