2

How close can I get to Android devices' graphics hardware safely, starting with Froyo and later?

I want to implement a simple page-flipping scheme on Android devices, using two frame buffers.

It should go like this:

  1. Render into Frame Buffer A. (Frame Buffer A is the Back Buffer and Frame Buffer B is currently displayed.)

  2. Wait for the next VSYNC (maybe an VSYNC interrupt?)

  3. Tell the OS to display Frame Buffer A and make Frame Buffer B the Back Buffer.

  4. Render into Frame Buffer B. (Frame Buffer B is the Back Buffer and Frame Buffer A is currently displayed.)

  5. Wait for the next VSYNC (maybe an VSYNC interrupt?)

  6. Tell the OS to display Frame Buffer B and make Frame Buffer A the Back Buffer.

Repeat steps 1 - 6.

Updating the display about 15 - 25 times a second is optimal for my needs. (I'll never need 60 fps or anything higher than 30 fps.)

I'm planning to use only OpenGL ES 2.0 for all rendering.

Janin zah
  • 201
  • 2
  • 14
  • Usually, GL's double buffering does exactly that. So there is nothing you need to implement here. – derhass Aug 03 '14 at 21:46
  • @derhass: I've read that before Jelly Beans, the Android was not guaranteed to start working on displaying the newly-ready-to-display buffer. So my understanding is for devices with Froyo through Ice Cream Sandwich, I'd better implement page-flipping myself, if that's possible at all. – Janin zah Aug 04 '14 at 00:47

1 Answers1

3

You don't need to do this. If you do, your buffering will be redundant with the buffering the operating system is doing for you, and will just be adding latency and overhead.

You can learn about the current Android graphics architecture from this page. Older versions of Android were much different, but the notion of double- or triple-buffering has been present in Android since the beginning. It's very much part of how OpenGL ES works.

The one tricky bit from the app side is figuring out when VSYNC is arriving if you want to pace your app behavior with that (rather than blocking while queue-stuffing). See the "game loops" section of the docs for details, but know that you can use Choreographer to get the VSYNC timing on API 16+.

According to this dashboard, Froyo and earlier is about 0.7% of the market. Targeting gingerbread and later is more typical. If you target API 16 (the first Jellybean release) you'd lose about 25% right now (13.5% gingerbread, 11.4% ICS), mostly low-end devices that ship with gingerbread due to its lower hardware requirements.

fadden
  • 51,356
  • 5
  • 116
  • 166
  • Thank you for your answer, Mr.Fadden. I've just voted "useful." Yes, I just found out that Froyo is not a significant segment of the Android market anymore. I can abandon Froyo now and that will give me an option of using VBO's without resorting to using NDK. – Janin zah Aug 04 '14 at 16:36