8
\$\begingroup\$

I'm working on a game which can't run at Full speed on some devices. On Tegra2, with many optimizations, performance is near 40 fps. The framerate is stable but animations aren't smooth enough, so i need a vsync.
With 2.3 Android SDK, we can use EGL library natively. So i try to use eglSwapInterval but no success. In this GDC Paper, it seems that Tegra2 can do it.

Ps: Thread.sleep() to force a constant FPS is not an acceptable solution

\$\endgroup\$
2
  • \$\begingroup\$ I haven't developed anything for Android, so I can't say for certain if it's possible or not to affect its swap interval, though it seems doubtful. So if animation stuttering comes from a large difference in it's logic timesteps, maybe it's worth a try to calculate an average timestep for a batch of frames? Like this, maybe using a period of 5-6 frames. It's not an answer to your vsync question, but maybe it will help your animations without introducing a fixed render timestep. \$\endgroup\$
    – EnoughTea
    Sep 6, 2011 at 20:15
  • 1
    \$\begingroup\$ As Tegra2 is an immediate renderer (not a tile), i can check if time elapsed before eglSwapBuffer is < 1/60s. If not, i wait 1ms more than the 16ms and do the eglSwapBuffer. That's just horrible!!! It is very strange that they speak about this function at the Google IO 2011 if it it not implemented. \$\endgroup\$
    – Ellis
    Sep 6, 2011 at 20:30

2 Answers 2

2
\$\begingroup\$

According to this thread on some opengl es benchmark, most devices' drivers simply ignore the eglSwapInterval, but tegra2 should have vsync enabled by default (and eglSwapInterval can be used to disable it).

Perhaps the vsync rate on your device is such that your stuttering comes from sometimes hitting, sometimes missing the frame time? Have you tried if disabling vsync will actually improve matters?

\$\endgroup\$
9
  • \$\begingroup\$ I haven't tried to disable vsync. I tried eglSwapInterval(...,2) without success. I will try as soon as possible. \$\endgroup\$
    – Ellis
    Sep 5, 2011 at 8:02
  • \$\begingroup\$ The swapinterval parameter defines the minimum amount of frames that must go by, so it's possible you're seeing stutter like 2,2,3,2,2,3,2,2,2,3 .. assuming the whole thing works, which doesn't seem to be guaranteed =) \$\endgroup\$ Sep 6, 2011 at 7:19
  • \$\begingroup\$ Here's another little nugget: "interval is silently clamped to minimum and maximum implementation dependent values before being stored; these values are defined by EGLConfig attributes EGL_MIN_SWAP_INTERVAL and EGL_MAX_SWAP_INTERVAL respectively." \$\endgroup\$ Sep 6, 2011 at 7:24
  • \$\begingroup\$ eglSwapInterval( ,2) doesn't change my framerate of 42fps and EGL_MIN_SWAP_INTERVAL is 0 and MAX 10. \$\endgroup\$
    – Ellis
    Sep 6, 2011 at 7:33
  • \$\begingroup\$ Only other thing I can think of to try is go through the values 0 to 10 and see if there's any change. If there isn't, well, the function is broken. (Or well, values 0,1,9 and 10) \$\endgroup\$ Sep 6, 2011 at 10:36
0
\$\begingroup\$

Published a sample doing 30FPS using choreographer API. https://github.com/googlesamples/android-ndk/tree/master/choreographer-30fps Does that work for you?

\$\endgroup\$
2
  • 1
    \$\begingroup\$ While your link might be helpful (I haven't looked at it), it's preferred on this site that links are summarised in the answer in case the link dies, and so that others know what to expect from it. Are you able to include a helpful portion or description of the sample in your answer? \$\endgroup\$
    – Jibb Smart
    May 4, 2016 at 4:05
  • \$\begingroup\$ And the link is in fact dead :) \$\endgroup\$
    – Karu
    May 28, 2017 at 22:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .