This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

FBO doesn't work?

Note: This was originally posted on 12th September 2011 at http://forums.arm.com

Sorry, this is a repost of a question I added to someone else's thread. It's a similar issue, but went unanswered. I kind of need to get an answer on this:

I create the FBO, bind it to a texture, check the status to make sure it's framebuffer complete, then set it to the rendering buffer, and call DrawElements. DrawElements fails with "GL_INVALID_FRAMEBUFFER_OPERATION" error. This is a bit of a mystery since I check the completeness status on the line immediately prior to the draw call and it claims to be framebuffer complete.

Do the settings on the texture object matter, e.g. repeat/linear/reflect. Does Mali require me to specify a depth or stencil buffer? Does it require an alpha channel?

This code works on Tegra2 and Adreno 205. Not sure why Mali doesn't like it.

Cheers!


Edit: Added example Android code that doesn't work as it should on the SGS2.
  • Note: This was originally posted on 14th September 2011 at http://forums.arm.com


    Sorry, this is a repost of a question I added to someone else's thread. It's a similar issue, but went unanswered. I kind of need to get an answer on this:

    I create the FBO, bind it to a texture, check the status to make sure it's framebuffer complete, then set it to the rendering buffer, and call DrawElements. DrawElements fails with "GL_INVALID_FRAMEBUFFER_OPERATION" error. This is a bit of a mystery since I check the completeness status on the line immediately prior to the draw call and it claims to be framebuffer complete.


    Even if the framebuffer is complete, it sounds like you've got it bound to the render buffer and a texture at the same time, which you shouldn't really do.


    Edit: Added example Android code that doesn't work as it should on the SGS2.


    I can't see the code here, are you sure you posted it?

    -Stacy
  • Note: This was originally posted on 15th September 2011 at http://forums.arm.com

    The code I uploaded came from here:

    http://blog.shayanjaved.com/2011/05/13/android-opengl-es-2-0-render-to-texture/

    It's not mine. It works on Adreno 205 (HTC Desire), but doesn't work on Mali 400 (Samsung Galaxy SII).
  • Note: This was originally posted on 19th September 2011 at http://forums.arm.com

    Hiya,

    I've started to look into the APK on a Samsung Galaxy SII. It was forced to close so I looked at the logcat output and was able to see the shader was failing to compile. This is because the shader programs normalmap_ps.txt and normalmap_vs.txt attempt to overload the dot() function. Since this is a built-in function in ESSL, the compiler throws an error. I fixed this by removing the overloaded function to let the progam use the built-in.

    The next error is a problem with glDrawElements(), and it seems the application is trying to pass a type of GL_UNSIGNED_INT, when the spec clearly states that only byte and short are permitted.

    I've fixed those two issues and now there's no crash, but I still only see a black screen. I will continue to investigate, as I have my own NDK FBO example which works fine and there's no reason this shouldn't work if the API is used correctly.

    Cheers, Pete
  • Note: This was originally posted on 20th September 2011 at http://forums.arm.com

    Hiya,

    I looked further into it, and I think I found the last bits that needed fixing to make it run on the Galaxy SII. Not only does the call to glDrawElements() need to switch from GL_UNSIGNED_INT to GL_UNSIGNED_SHORT, but also the underlying index buffer for the quad needs fixing.

    I changed:
    _quadi to a short array
    _qib to a ShortBuffer

    and fixed the _qib initializer to:

    _qib = ByteBuffer.allocateDirect(_quadi.length * 2).order(ByteOrder.nativeOrder()).asShortBuffer();

    Now the APK runs OK I believe:



    Please note though, it appears to be using FBOs to render a scene to a texture twice the size of the screen, then using bilinear filtering when plotting the texture to the screen as a sort of antialiasing effect.

    This isn't how I'd recommend achieving this effect on Mali - it already supports 4x fullscreen antialiasing for almost no performance cost, just by selecting an appropriate EGL config with EGL_SAMPLES set to 4. We hope to have an example how to detect Mali and enable this in your APKs uploaded to the portal in the next few weeks, and I'd recommend that method instead - it will be much more efficient in terms of memory consumption (no need for a large texture).

    There are a few other issues with the application such as allocating twice as much texture memory as is necessary (uses an int rather than a short, when the data is only RGB565) and it passes the texture flag "hasTexture" from a uniform in the vertex shader via a varying which is wasteful - it should really just access the same uniform from the fragment shader.

    HTH, Pete