I am trying to create a color-renderable texture (to attach to a framebuffer) on a Nexus4 with Adreno320 chipset using GLES 2.0. The driver reports both GL_EXT_color_buffer_half_float and GL_OES_texture_half_float extensions as supported.
The following call (which succeeds on a range of other devices) fails with "GL_INVALID_OPERATION":
GLES20.glTexImage2D(
GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA16F_EXT, width, height, 0, GLES20.GL_RGBA, GL_HALF_FLOAT_OES, null);
Calling the following instead succeeds:
GLES20.glTexImage2D(
GLES20.GL_TEXTURE_2D, 0, GL_RGBA_EXT, width, height, 0, GLES20.GL_RGBA, GL_HALF_FLOAT_OES, null);
But then the subsequent call to bind the texture leaves the framebuffer "attachment incomplete":
GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0,
GLES20.GL_TEXTURE_2D, textureHandle, 0);
This behaviour is the same on devices running both Android JellyBean and KitKat.
What is the proper way to create a half-float, color-renderable, framebuffer-attachable texture on this hardware?
Thanks!
The glTexImage2D call should be ok:
GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GL_RGBA_EXT, width, height, 0, GLES20.GL_RGBA, GL_HALF_FLOAT_OES, null);
Can you review the following link for clues on why the incomplete framebuffer message might be generated?
https://www.opengl.org/wiki/Framebuffer_Object
Thanks for the hint - I assume you are referring to the following list of completeness requirements:
* The source object for the image still exists and has the same type it was attached with.
The texture is created immediately before attaching it to the framebuffer, so it should still be there and have the same type.
* The image has a non-zero width and height (the height of a 1D image is assumed to be 1). The width/height must also be less than GL_MAX_FRAMEBUFFER_WIDTH and GL_MAX_FRAMEBUFFER_HEIGHT respectively (if GL 4.3/ARB_framebuffer_no_attachments).
Image is 1920x1080; driver won't let me query GL_MAX_FRAMEBUFFER_WIDTH and GL_MAX_FRAMEBUFFER_HEIGHT, but the device can handle this exact size with full float textures, so I am going to assume the size is fine for half-float as well.
* The layer for 3D or array textures attachments is less than the depth of the texture. It must also be less than GL_MAX_FRAMEBUFFER_LAYERS (if GL 4.3/ARB_framebuffer_no_attachments).
2D texture; does not apply.
* The number of samples must be less than GL_MAX_FRAMEBUFFER_SAMPLES (if GL 4.3/ARB_framebuffer_no_attachments).
Only one sample.
* The image's format must match the attachment point's requirements, as defined above. Color-renderable formats for color attachments, etc.
According to the driver, half-float is color-renderable ("GL_EXT_color_buffer_half_float").
Am I missing something?
A bit of additional information I found today - on Nexus 5, the half-float framebuffer fails as described when the device runs Kitkat, but succeeds under Lollipop.