2

In my app I am trying to use textures but I am getting the errors

:0: SGXQueueTransfer: all paths failed
:0: HardwareMipGen: Failed to generate texture mipmap levels (error=3)

on my Galaxy Nexus. I don't get these errors on my EVO 4G.

Here is the relevant loading code.

private static int load(Context context, int resID) {
    Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(),
            resID);

    int[] texts = new int[1];
    GLES20.glGenTextures(1, texts, 0);
    int texID = texts[0];

    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texID);

    GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
            GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
    GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
            GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);

    GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S,
            GLES20.GL_CLAMP_TO_EDGE);
    GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T,
            GLES20.GL_REPEAT);

    GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);

    return texID;
}

private static int loadWithMipmap(Context context, int resID) {
    int texID = load(context, resID);

    GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
            GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR_MIPMAP_NEAREST);
    GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
            GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR_MIPMAP_NEAREST);

    GLES20.glGenerateMipmap(GLES20.GL_TEXTURE_2D);

    return texID;
}

Any ideas what is going on and how I can fix it?

EDIT: There is only one image causing the error and it is a 1024x2048 png.

Alchitry
  • 1,369
  • 1
  • 16
  • 29

3 Answers3

1

Frickin' scary. Tested on a Galaxy Nexus 7.

You need to do the following:

    GLES20.glTexParameterf(
        GLES20.GL_TEXTURE_2D,
        GLES20.GL_TEXTURE_MIN_FILTER,
    GLES20.GL_LINEAR_MIPMAP_NEAREST);
    this.context.checkError("GL_TEXTURE_MIN_FILTER");
    GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
        GLES20.GL_TEXTURE_MAG_FILTER,
    GLES20.GL_LINEAR);

Strictly speaking, I guess GL_LINEAR_MIPMAP_NEAREST isn't a valid MAG_FILTER. Nexus 7 thinks so anyway. And it mipmaps beautifully with the change made.

Robin Davies
  • 7,547
  • 1
  • 35
  • 50
  • I changed my program to use one large sprite sheet instead of many images and now I don't get the error even with GL_LINEAR_MIPMAP_NEAREST. It was only failing on one image that was 1024x2048 but now its working. – Alchitry Aug 14 '12 at 18:03
1

I saw this, and it worked once I squashed the image to be square. OpenGL doesn't give an error.

Learn OpenGL ES
  • 4,759
  • 1
  • 36
  • 38
0

Wild guess, as I don't have any access to the hardware you're mentioning, but does the error occur with a texture that has non power of two dimensions ?

rotoglup
  • 5,223
  • 25
  • 37
  • They are all power of two dimensions. They don't show up at all on some phones if they're not. The dimensions of the one causing problems are 1024x2048 – Alchitry Jun 17 '12 at 20:57