4

I ran into a problem yesterday when trying to create a framebuffer of size 256x8 - on iOS devices (tested on iPad 3, iPhone 4 & iPad Mini) certain sizes will fail with GL_FRAMEBUFFER_UNSUPPORTED. These same sizes work in the iOS Simulator.

The issue was previously reported here but remains unanswered. I created a test to check which framebuffer sizes don’t work. To be clear, these sizes only fail on actual iOS hardware, the sizes work properly in the iOS Simulator.

Does anyone know why these sizes fail (included below)? Should these sizes work? Or is there some reason why they fail? Or is it just a bug? One thing interesting to note is that each dimension (width or height) are always a power of two. Every non-power of two size that I’ve tested works.

Here’s the code for testing framebuffer sizes:

void initGL()
{
    //  create OpenGL ES 2.0 context
    EAGLContext * context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];

    if ( !context )
        return;

    [EAGLContext setCurrentContext:context];
}

void framebufferTest( int width, int height )
{
    //  create empty texture
    GLuint  texture = 0;

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

    GLenum  dataType = GL_UNSIGNED_BYTE;
    GLint   internalFormat = GL_RGBA;

    glTexImage2D( GL_TEXTURE_2D, 0, internalFormat, width, height, 0, internalFormat, dataType, NULL );

    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
    // This is necessary for non-power-of-two textures
    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 a framebuffer & attatch to texture
    GLuint  framebuffer = 0;

    glGenFramebuffers( 1, &framebuffer );
    glBindFramebuffer( GL_FRAMEBUFFER, framebuffer );

    glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0 );
    GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);

    if ( status != GL_FRAMEBUFFER_COMPLETE )
        printf( "%5dx%5d\t\tFAILED! FBO status: 0x%x\n", width, height, status );

    //  cleanup
    glDeleteFramebuffers( 1, &framebuffer );
    glDeleteTextures( 1, &texture );

    glBindTexture( GL_TEXTURE_2D, 0 );
    glBindFramebuffer( GL_FRAMEBUFFER, 0 );
}

List of invalid framebuffer sizes (run on iPad3 & iPhone 4)

    1x    4     FAILED! FBO status: 0x8cdd
    1x    8     FAILED! FBO status: 0x8cdd
    1x   16     FAILED! FBO status: 0x8cdd
    1x   32     FAILED! FBO status: 0x8cdd
    1x   64     FAILED! FBO status: 0x8cdd
    1x  128     FAILED! FBO status: 0x8cdd
    1x  256     FAILED! FBO status: 0x8cdd
    1x  512     FAILED! FBO status: 0x8cdd
    1x 1024     FAILED! FBO status: 0x8cdd
    1x 2048     FAILED! FBO status: 0x8cdd
    2x    1     FAILED! FBO status: 0x8cdd
    2x    8     FAILED! FBO status: 0x8cdd
    2x   16     FAILED! FBO status: 0x8cdd
    2x   32     FAILED! FBO status: 0x8cdd
    2x   64     FAILED! FBO status: 0x8cdd
    2x  128     FAILED! FBO status: 0x8cdd
    2x  256     FAILED! FBO status: 0x8cdd
    2x  512     FAILED! FBO status: 0x8cdd
    2x 1024     FAILED! FBO status: 0x8cdd
    2x 2048     FAILED! FBO status: 0x8cdd
    4x    1     FAILED! FBO status: 0x8cdd
    4x    2     FAILED! FBO status: 0x8cdd
    4x   16     FAILED! FBO status: 0x8cdd
    4x   32     FAILED! FBO status: 0x8cdd
    4x   64     FAILED! FBO status: 0x8cdd
    4x  128     FAILED! FBO status: 0x8cdd
    4x  256     FAILED! FBO status: 0x8cdd
    4x  512     FAILED! FBO status: 0x8cdd
    4x 1024     FAILED! FBO status: 0x8cdd
    4x 2048     FAILED! FBO status: 0x8cdd
    8x    1     FAILED! FBO status: 0x8cdd
    8x    2     FAILED! FBO status: 0x8cdd
    8x    4     FAILED! FBO status: 0x8cdd
    8x   32     FAILED! FBO status: 0x8cdd
    8x   64     FAILED! FBO status: 0x8cdd
    8x  128     FAILED! FBO status: 0x8cdd
    8x  256     FAILED! FBO status: 0x8cdd
    8x  512     FAILED! FBO status: 0x8cdd
    8x 1024     FAILED! FBO status: 0x8cdd
    8x 2048     FAILED! FBO status: 0x8cdd
   16x    1     FAILED! FBO status: 0x8cdd
   16x    2     FAILED! FBO status: 0x8cdd
   16x    4     FAILED! FBO status: 0x8cdd
   16x    8     FAILED! FBO status: 0x8cdd
   32x    1     FAILED! FBO status: 0x8cdd
   32x    2     FAILED! FBO status: 0x8cdd
   32x    4     FAILED! FBO status: 0x8cdd
   32x    8     FAILED! FBO status: 0x8cdd
   64x    1     FAILED! FBO status: 0x8cdd
   64x    2     FAILED! FBO status: 0x8cdd
   64x    4     FAILED! FBO status: 0x8cdd
   64x    8     FAILED! FBO status: 0x8cdd
  128x    1     FAILED! FBO status: 0x8cdd
  128x    2     FAILED! FBO status: 0x8cdd
  128x    4     FAILED! FBO status: 0x8cdd
  128x    8     FAILED! FBO status: 0x8cdd
  256x    1     FAILED! FBO status: 0x8cdd
  256x    2     FAILED! FBO status: 0x8cdd
  256x    4     FAILED! FBO status: 0x8cdd
  256x    8     FAILED! FBO status: 0x8cdd
  512x    1     FAILED! FBO status: 0x8cdd
  512x    2     FAILED! FBO status: 0x8cdd
  512x    4     FAILED! FBO status: 0x8cdd
  512x    8     FAILED! FBO status: 0x8cdd
 1024x    1     FAILED! FBO status: 0x8cdd
 1024x    2     FAILED! FBO status: 0x8cdd
 1024x    4     FAILED! FBO status: 0x8cdd
 1024x    8     FAILED! FBO status: 0x8cdd
 2048x    1     FAILED! FBO status: 0x8cdd
 2048x    2     FAILED! FBO status: 0x8cdd
 2048x    4     FAILED! FBO status: 0x8cdd
 2048x    8     FAILED! FBO status: 0x8cdd
Community
  • 1
  • 1
Cutterpillow
  • 1,717
  • 13
  • 32
  • 2
    I guess, technically, the implementation is free to not support some backing textures. Seems like the GPU doesn't support power-of-two textures with a side length of 1, 2, 4 or 8. Weird! At least you can just always use at least a side length of 16 to work around it. – Jesse Rusak Apr 10 '13 at 20:47
  • 1
    Yeah, I think this is just hardware-specific rejection of certain backing texture sizes. I think it also varies device-to-device, because I'm pretty sure I've had 1x256 framebuffers work on certain iOS devices while 256x1 framebuffers failed. – Brad Larson Apr 10 '13 at 22:20

0 Answers0