Imagination PowerVR SDK Blog

Bug in glGenerateMipmap() for SGX 540 ?

pvrtrace

#1

Hello,



I noticed on a Kindle Fire HD 7" (PowerVR SGX 540) that glGenerateMipmap() generates noise, though only for 16 bits textures (square, pow of 2 and not compressed).

I was hoping that it was only on Kindle, but now I have reports of the same issue on Nexus S, which uses the same GPU.



So, I’m wondering if there’s a known bug, and if it’s limited to the drivers for this GPU, that way I’d know better when to use my own custom mipmap generator.



Thanks !



- On Kindle Fire HD 7"





- On Nexus S


#2

Hi Dpasca,



The textures where you’re generating the MIP Maps, there are a few bugs in older drivers under certain situations with MIP Map generation. If you could answer a few questions about how the textures are used/accessed I should be able to help answer your question better.



How often do you call glGenerateMIPMaps?

What format is the texture you’re generating MIP Maps for (RGB565, LA88, RGBA4444… etc.)?

Is the texture attached to an FBO at any point?

Do you do any texture sub image calls before the glGenerateMIPMap call? If so, is it to an existing texture object, or did you create a new one?



Hopefully that will give me enough info to suggest something.



Thanks,

Tobias


#3

Hi Tobias,



Thanks for the reply.

I use glGenerateMipmap() for pretty much all of the textures (unless it’s a UI element).

The texture giving problems is a 565, but I think I tried several formats and my conclusion was that anything 16-bit was generating noise.

There are no FBOs involved, and also not sub image calls (I removed those since there was another issue with another driver for another GPU).



Querying GL_VERSION I get: OpenGL ES 2.0 build 1.8@785978



Thanks,

Davide


#4

Hi Davide,



Hmm, that’s unfortunate, I was aware of a bug with 1.6 drivers and earlier, but 1.8 drivers should be unaffected and render correctly… Would it be possible for you to send either an APK reproducing the problem, or a PVRTrace recording (https://www.imgtec.com/powervr/insider/pvrtrace.asp) of the application to DevTech@imgtec.com? Then I should be able to investigate the issue a little better.



In the meantime, can I ask why you generate MIP Maps at run time? Have you considered pre-creating them? They only add an additional 33% to the size of your textures, which can usually be compressed quite successfully by most compression algorithms. Doing so would also allow you to use compressed textures, which can often add a significant performance boost to mobile graphics apps.



Thanks,

Tobias


#5

Hi Tobias,



I’ll email a link to the game (it’s free on Google Play).



About the format, I simply prefer to use JPEG because it has a better compression ratio and I really care about the size of the application. Also I like to have a single set of data that works for all platforms, because it makes things easier.

For me it would be ideal to be able to convert to PVRTC formats at run-time, when loading, but that’s probably too intensive for mobile.



Thanks,

Davide


#6

Hi David,



That’s what we often hear, although a combination of PVRTC to initially compress the texture followed by some sort of file compression like ZIP, RAR or GZ usually provides a similar file size (sometimes better in fact) than jpeg, usually at the same quality but with better performance. Obviously that doesn’t solve the cross-platform issues, but I’d suggest looking into it if you haven’t already.



Anyway, once we’ve got the email I’ll take a look at it and see what I can find out.



Thanks,

Tobias


#7

Hi David,



I’ve looked into it and it’s been fixed for any drivers with revision 1.9 drivers or higher. You should be able to get the driver revision in the gl version string, usually looking like this “… 19 1.9@XXXXXXX ….”



If you detect drivers for revision 1.8 or lower, you may encounter this issue. For reference, 1.8 drivers appear on the Galaxy Nexus and the Nexus S, and earlier phones will generally have drivers before those.



For these cases you should run your custom MIP Map generator. Hope that helps, let me know if you have any more questions!



Regards,

Tobias


#8

Great ! That answers it for me.



Thanks again 8)


#9

Actually, one more thing, if you don’t mind …does this apply to any SGX or just the 540 ?



Thanks.


#10

Hi Davide,



It’s a driver bug, not a HW bug as far as I can tell. So it’s any SGX with these earlier drivers.



Thanks,

Tobias


#11

Thanks !