androidopengl-es-2.0galaxymali

glGenerateMipmap() very slow on Samsung Galaxy SII (Mali-400 MP)


I'm currently doing some GPGPU on the Samsung Galaxy SII (ARM Mali-400 MP) with the Android NDK and OpenGL ES 2.0. For that I need to generate a mipmap from a texture that has been rendered to via a FBO. Unfortunately glGenerateMipmap() appears to be very slow on the device. It takes about 90 milliseconds to generate a mipmap for a 512x512 RGBA8888 texture. Since I also tried the same code on other Android devices, where this function works much faster (about 2 milliseconds), this slowdown really puzzles me. Am I doing something wrong or missing something here? Can anyone provide example code for this case working on a device with an ARM Mali GPU?

Here are the relevant parts of my code:

glGenTextures(1, &texId); 
glActiveTexture(GL_TEXTURE0); 
glBindTexture(GL_TEXTURE_2D, texId); 

// Allocate graphics memory.
glTexImage2D(GL_TEXTURE_2D, 0, format, cols, rows, 0, format, type, NULL); 
// Allocate memory for mipmap. 
glGenerateMipmap(GL_TEXTURE_2D); 

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 

// Create off-screen framebuffer object and attach the texture to it. 
glGenFramebuffers(1, &fboId); 
glBindFramebuffer(GL_FRAMEBUFFER, fboId); 
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texId, 0);

// Now render to that texture
...

// Generate MIP map.
glBindTexture(GL_TEXTURE_2D, texId);
glGenerateMipmap(GL_TEXTURE_2D);

Solution

  • This issue has been fixed in the drivers by ARM: https://community.arm.com/support-forums/f/graphics-gaming-and-vr-forum/2324/glgeneratemipmap-very-slow-on-samsung-galaxy-sii