Search code examples
androidopengl-estexturesopengl-es-3.0

glTexSubImage2D deeply affects frame rate on gles 3.0


I have a graphics engine which for every frame writes approximately 300 bytes of data with approximately six glTexSubImage2D calls to a texture (including writing to mipmaps). The texture is a texture of unigned bytes using GL_RED and GL_R8 as format\internal format. The uploading is performed via a pixel buffer, which in itself has been written to one frame ahead.

This quite small operation have a deep impact on the framerate regardless of what else gles is drawing.

Anyone have any idea of what is causing this frame rate drop, and how I can get past it?

Update: Solidpixels answer indicates it's a synchronization issue. In this case, I would be perfectly fine even if the texture modification is not synchronized at all with the rendering. Can I just tell gles to just write the data straight into the texture memory without caring at all if just half the new data is there?

Note: It is only the glTexSubImage2D which affects the frame rate, the glSubBufferData upload does not affect at all. On some devices it seems to mather when I actually perform the glTexSubImage2D in respect to when I draw using the texture, not all devices though.


Solution

  • I'd guess on the devices which slow down you still have outstanding references to the texture in flight, so you are forcing the drivers to create a ghost allocation. In depth explanation here:

    https://community.arm.com/graphics/b/blog/posts/mali-performance-6-efficiently-updating-dynamic-resources