What's the common way to control the rendering loop?

Hi all,

I’m trying to render using EGL/OpenGLES on an embedded device with two displays. Both displays have a refresh rate of 60Hz, I want that ‘A’ app is output to display 1 at 60fps, and ‘B’ app is to display 2 at 30fps. The reason I want to output at 30fps on a 60Hz refresh rate display is to reduce GPU usage. I set the eglSwapInterval(2) in app ‘B’ but failed, and as a result of inquiring to GPU vendor eglSwapInterval(1), they can’t support it. At this point, which method is the most common way to control the rendering loop? I’ve already gathered a lot of information through articles on this forum or googling.

I found OpenGL Setting FPS, but I can’t use the wglSwapIntervalEXT() API. I’d like to know what is the common way, among other things. For example, what is the common way to render at 30fps on an LCD with a refresh rate of 60Hz?

Any help or advice would be appreciated.

Ok, so EGL_MAX_SWAP_INTERVAL == 1?

Well, since you’re talking with your GPU vendor, I’d ask them how best to achieve the underlying goal you’re trying to accomplish (unstated) by reducing GPU usage. You also might state that underlying goal here, as it might suggest a better solution.

Check and see if your EGL surface’s EGL_SWAP_BEHAVIOR == EGL_BUFFER_PRESERVED. If so, you can just call eglSwapBuffers() 2X in a row on the device you want to drop to 30Hz. However, this presumes that your existing app ‘B’ rendering never exceeds a single 60Hz (16.6ms) display interval.

On the other hand, if the surface’s EGL_SWAP_BEHAVIOR == EGL_BUFFER_DESTROYED, then you’re probably going to need to pakrat off the color buffer someplace and blit it back to the display. On mobile with it’s slow DRAM-backed framebuffer, this isn’t free. One option is to switch your frames to render-to-texture (RTT) via FBO, and then at the end of the frame Blit the color texture to the default framebuffer. On the 30Hz device, this lends well to skipping the RTT one every other frame and just doing the Blit. You may need a ring buffer of FBOs and color textures to avoid implicit syncs (stalls) inside the GL-ES driver. Check with your vendor for details on optimizing RTT on their driver. Same assumption here about your existing app ‘B’ rendering never exceeds a single 60Hz.

Have you run a run the vendor’s GPU profiler and optimized your rendering? Depending on your unstated goal, that might be a better route to explore.

Hi @Dark_Photon,

Thanks for your kindly explanation.

Yes, When I query that, the value is ‘1’

I’ve never explicitly used EGL_SWAP_BEHAVIOR while programming. Upon checking, it seems that the default value is set according to the GPU vendor. I am far from fully understanding your explanation. So, let’s check a little more about EGL_SWAP_BEHAVIOR. It seems that your RTT proposal can be applied immediately. I hadn’t even thought of programming like that, but it seems like a good idea, thanks.

Not yet. I plan to analyze it using the GPU profiler, but I left a question because I want to know what kind of ‘common’ method there is.