4

I found some ways to speed up glReadPixels by OpenGL ES 3.0, but I am not sure if it works or not.

  1. specifies the fifth argument of glReadPixels() as GL_BGRA to avoid unnecessary swizzle.
  2. use PBO as this mentioned.

In order to verify, I updated to the latest Android SDK and ADT, and try to use OpenGL ES 3.0. However, I can't find GL_BGRA definition as I expected, and I don't know how to use glMapBuffer(). Am I missing something?

To summarize,

  • Is there any other faster way to access framebuffer than using glReadPixels() ?
  • How to use GL_BGRA and PBO by OpenGL ES 3.0 on Android?

If anyone knows, please point me out. Some code snippets would be better. Thanks in advance.

Justin
  • 115
  • 3
  • 9
  • I try [glMapBufferRange()](http://www.opengl.org/sdk/docs/man/xhtml/glMapBufferRange.xml) instead of glMapBuffer(). `GLES30.glMapBufferRange(GLES30.GL_PIXEL_PACK_BUFFER, 0, size, GLES30.GL_MAP_READ_BIT);` but it returns **GL_INVALID_ENUM** by using GLES20.glGetError().... Does anyone know how to make it right? Thanks. – Justin Sep 11 '13 at 06:00
  • Why are you using GLES20.glGetError anyway, can't you use GLES30.glGetError? – Arttu Peltonen Sep 13 '13 at 05:57
  • I try GLES30.glGetError, it has the same result GL_INVALID_ENUM. (I found glGetError defined in GLES20) – Justin Sep 16 '13 at 01:52
  • On certain devices I've seen a big different in performance between GL_RGB and GL_RGBA. I haven't tried BGRA, but I'm not sure how many devices use that as a native format. (IIRC, Mali devices do.) – fadden Dec 09 '14 at 17:12
  • How much time does glReadPixels take on average, btw? Please do mention your tex resolution and device specs too, thanks. – bad_keypoints Oct 09 '15 at 11:29

1 Answers1

1
  1. Not really. I don't know whether you would get performance gains by using BGRA format, but it's worth a try. In ES 2.0, GL_BGRA is only available through extension: EXT_read_format_bgra, so you would need to use the enum GL_BGRA_EXT, and apparently it's the same in OpenGL ES 3.0 too.

  2. Yes, glMapBufferRange is the way to go on OpenGL ES 3.0. It looks like your call is correct, as per your comment. According to spec and man page, glMapBufferRange should not generate GL_INVALID_ENUM errors, so I think something else is wrong here. Make sure the error is not generated by an earlier call.

Arttu Peltonen
  • 1,250
  • 14
  • 18
  • 1. GLES20.GL_BGRA_EXT can't be resolved or is not a field. (GL_BGRA_EXT is not defined in GLES20.class, GLES30.class either). Does it need to include something else? 2. I saw man page too, that's why I feel strange. Maybe you are right, there is something else wrong. I will try to find it out. Thanks for your hint. – Justin Sep 16 '13 at 01:58
  • Thanks for pointing this out. `GL_BGRA` comes from one of the many Windows examples. I just swapped for `GL_RGBA` on Android. – c z Nov 13 '20 at 11:49