Search code examples
androidopengl-esfragment-shaderopengl-extensions

How to enable OpenGL extension GL_EXT_shader_framebuffer_fetch on Android?


I'm developing an Android app with OpenGL ES 2.0 and I'd like to use the GL_EXT_shader_framebuffer_fetch extension.

From what I understand, I need to enable it first with the #extension directive at the top of my fragment shader, and then I can use the built-in variable gl_LastFragData.

So here is my fragment shader:

#extension GL_EXT_shader_framebuffer_fetch : require
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ <- Enable the extension

varying highp vec2 textureCoords;
uniform sampler2D currentTexture;

void main()
{
    vec4 currentColor = texture2D(currentTexture, textureCoords);
    gl_FragColor = currentColor;
}

However, when I compile the shader, I get the following compilation error:

Couldn't compile shader: Fragment shader compilation failed.
ERROR: 0:1: '' :     GLSL error: extension 'GL_EXT_shader_framebuffer_fetch' is not supported
ERROR: 1 compilation errors. No code generated.

The error is pretty explicit: this extension is not supported.

My technical specs:

  • Hardware: Samsung Galaxy S4
  • Android version: 5.0.1
  • Android API level: 21
  • OpenGL version (glGetString(GL_VERSION)): OpenGL ES 3.0 V@84.0 AU@ (CL@)

I have a few questions:

  • Is there anything I can do to install this extension on my device?
  • If not, can I install it/use it on an emulator?
  • Is it a software matter or really a hardware problem?

Solution

  • Is there anything I can do to install this extension on my device?

    No; either the GPU and driver support it, or they don't.

    If not, can I install it/use it on an emulator?

    If the emulator supports the extension, then yes you can use it ...

    Is it a software matter or really a hardware problem?

    Could be either a limitation in the underlying hardware, or a limitation in the driver. From an app developer point of view the two are indivisible, so it's sort of irrelevant which is the limitation really ...