iosopengl-esglkitpvrtcglktextureloader

GLKTextureLoader fails to load PVR (error 12 - preprocessing failure)


Background

In our app, we use a PNG sprite sheet where each sprite is just used as a mask. These are successfully loaded using GLKTextureLoader. When iOS 7 reached the 5th/6th beta, something appeared to change in the way GLKTextureLoader works, as suddenly all our PNGs started rendering incorrectly, as though there was something wrong with the alpha premultiplication.

After bug reports were submitted, and no response was received from Apple (and the problem is, worryingly, still present in the live release of iOS 7), we have decided to convert our PNGs to a PVR format.


Problem

When trying to load the PVR texture using GLKTextureLoader:

NSDictionary *options = @{ GLKTextureLoaderOriginBottomLeft : @YES, GLKTextureLoaderApplyPremultiplication : @NO };
GLKTextureInfo *textureInfo = [GLKTextureLoader textureWithContentsOfURL:url options:options error:&error];

it fails with error 12 (GLKTextureLoaderErrorDataPreprocessingFailure). What is involved in this 'preprocessing' step, and what could be the problem?

Here are some things I have checked:

This answer indicates that this can be caused by file corruption. This makes me wonder if I'm somehow generating the PVR incorrectly. I am using Imagination's PVRTexToolGUI to convert the PNG:

  1. Open the PNG in PVRTexToolGUI
  2. Premultiply the alpha (although I have also tried it without this step)
  3. Encode the current texture to a new format (have tried multiple formats, as described above)
  4. Save the texture out as a .pvr file.

Solution

  • There are 2 versions of PVR file: the new and the legacy one. Try to save your PVR textures in different file format (save as legacy).