This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

EGL on GNU/Linux framebuffer: eglSwapInterval() has no effect.

Hi there,

I'm using MALI EGL/GLES driver with kernel 3.4.-67 cloned from here: linux-sunxi/linux-sunxi

I cloned the MALI driver from here: linux-sunxi/sunxi-mali

I configured, built and installed like this:

git clone https://github.com/linux-sunxi/sunxi-mali.git

cd sunxi-mali

git submodule init

git submodule update

make config ABI=armhf EGL_TYPE=framebuffer

make

sudo make install

The resulting version seems to be "r3p0".

Please NOTE that I'm using the framebuffer EGL implementation, NOT the X11 EGL. In this case, X11 is NOT an option.

EGL/GLESv2 examples seem to work fine. However, when it comes to screen refresh in my own projects, tearing is visible.

This is how I swap EGL buffers in my code:

static void gfx_ctx_swap_buffers(void)

{

       eglSwapBuffers(g_egl_dpy, g_egl_surf);

}

According to Khronos Group docs, eglSwapBuffers should wait for vsync. This is very clear if we read the eglSwapInterval() documentation:

eglSwapInterval

According to these docs, the swap interval is "1" by default, hence waiting for 1 complete frame to be shown before showing the next. There should be no tearing at all.

I even tried specifying this in my EGL init code:

if ( eglSwapInterval(g_egl_dpy,1) != EGL_TRUE ){

      printf("\neglSwapInterval failed.\n");

      goto error;

}

...but there's still tearing to be seen.

I can, of course, use the FBIO_WAITFORVYSNC ioctl before calling eglSwapBuffers(), but that's a blocking call that will take the application to it's knees. This is not a solution.

What I think is that swap interval is NOT respected on the EGL-on-framebuffer implementation. Is there any possibility to fix it at all? Without this, we'll have to say goodbye to MALI for this project

Thanks!

  • Hi vanfanel,

    I'm not entirely sure where you get the impression that the EGL specification mandates vsync; this has always been a platform specific implementation option as far as I know. The eglSwapInterval function simply allows the system to slow down frame rendering, but nothing in the spec mentions anything to do with syncing display controller surface swap. Indeed, on most operating systems the EGL library implementation has nothing to do with getting the frames produced by the GPU to the screen - we produce the frames, but the display controller driver is responsible for the physical frame swap.

    The most common reason for tearing occurs because the display controller which consumes complete frames from the backbuffer does not implement vsync control. This is not part of the Mali software / EGL; Mali is just responsible for constructing the next frame, and has no control over what happens with it after we hand completed frames over to the display controller. Please check that your display controller driver is correctly implementing vsync waits.

    Hope that helps,
    Pete