4

昨天我在尝试创建大小为 256x8 的帧缓冲区时遇到了一个问题 - 在 iOS 设备上(在 iPad 3、iPhone 4 和 iPad Mini 上测试)某些大小将失败GL_FRAMEBUFFER_UNSUPPORTED。这些相同的尺寸在 iOS 模拟器中工作。

该问题先前已在此处报告,但仍未得到答复。我创建了一个测试来检查哪些帧缓冲区大小不起作用。需要明确的是,这些尺寸仅在实际的 iOS 硬件上失败,尺寸在 iOS 模拟器中正常工作。

有谁知道为什么这些尺寸会失败(包括在下面)?这些尺寸应该起作用吗?或者他们失败的原因是什么?或者它只是一个错误?有趣的一点是,每个维度(宽度或高度)始终是 2 的幂。我测试过的每一个两种大小的非幂都有效。

这是测试帧缓冲区大小的代码:

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 );
}

无效帧缓冲区大小列表(在 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
4

0 回答 0