glCheckFramebufferStatus() returns GL_FRAMEBUFFER_UNSUPPORTED when creating too many fbo

This topic contains 3 replies, has 3 voices, and was last updated by  bjano 2 years, 10 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #31486

    Philippe
    Member

    Device: Samsung Galaxy Tab 2 7” (PowerVR SGX 540)
    Android Version: Android 4.2.2 (latest update)

    It seems that I am not able to create more than 152 fbo regardless of the size or format. Trying to create 256 fbo 64x64x32bit returns the above error after fbo #152. This doesn’t look like a memory issue since I am not getting any GL_OUT_OF_MEMORY error before calling glCheckFramebufferStatus() and those 256 fbos would only use 4MB of memory (in theory).

    Below is the init code that can trigger the issue (I can send an apk if necessary) :


    for (int i = 0; i < 256; ++i)
    {
    uint width = 64;
    uint height = 64;
    uint texture = 0;
    uint fbo = 0;

    glGenTextures(1, &texture);
    glBindTexture(GL_TEXTURE_2D, texture);
    glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);

    glGenFramebuffers(1, ref fbo);
    glBindFramebuffer(GL_FRAMEBUFFER, fbo);
    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATACHMENT0, GL_TEXTURE_2D, texture, 0);

    int status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
    if (status != GL_FRAMEBUFFER_COMPLETE)
    printf ("%d: %s n", i, "Framebuffer incomplete");
    }

    Am I doing anything I shouldn’t do ? Is this a driver bug or an implementation specific limitation coming from the PowerVR SGX 540 itself ?

    #37987

    Hi Philippe,

    Sorry for the delay in replying! I’ve looked into this and it turns out it is a specific hardware limitation, you won’t be able to get any more framebuffer objects than that I’m afraid. The limit will vary across different GPUs as well.

    Is there a reason you need to create this many framebuffer objects?

    Regards,
    Tobias

    #37988

    Philippe
    Member

    We allocate a big pool of FBO upfront to use for large terrain rendering. IIRC the result was the same with creating a bunch of texture/renderbuffer and using only one FBO and swapping attachments.
    Independent rendertargets made it a bit easier to manage than an atlas and performance of swapping many rendertargets wasn’t really noticeable in our case (no VTF + no instancing = setup + drawcall for each terrain patch anyway).

    We ended up reverting to a big texture atlas for our use case but it would have been nice to get some sort of OpenGL error or having this limitation documented (I guess now it is 🙂 )

    In any case thank you for the valuable information !

    #37989

    bjano
    Member

    Is there any new info on this? I am having the same problem: I have more than 152 textures that I want to render to, but on the 153rd I get GL_FRAMEBUFFER_UNSUPPORTED . I use only one FBO and just reattach the different textures with glFramebufferTexture2D.

    The code works on android devices with Mali GPUs, also on any of the iOS devices (iPhone 4 with SGX535 is the oldest one I tried on) but it has this problem on Android devices with PowerVR GPUs.

    Is there any workaround other than creating a texture atlas? (which I am afraid is near impossible for my case) I tried deleting and recreating the FBO whenever I change the texture I am rendering to, but it didn’t help. And why is it working on iOS then?

Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic.