[Mesa-dev] [PATCH] i965: avoid fence fd dup in EGL layer

Tapani Pälli tapani.palli at intel.com
Tue May 9 10:47:38 UTC 2017



On 05/05/2017 10:14 AM, Randy Xu wrote:
> Follow up "i965: Solve Android native fence fd double close"
> The _EGLSync.SyncFd is not neccesary to keep after pass to
> dri driver.
> 
> Test: Run Vulkan and GLES stress test and no crash.

Yep I've verified as well that no crashes happen. Lots of tearing though 
but that happens independent of this patch so I'm assuming it's a bug 
elsewhere.


> ---
>   src/egl/drivers/dri2/egl_dri2.c      | 10 ++++++----
>   src/mesa/drivers/dri/i965/brw_sync.c |  2 +-
>   2 files changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
> index 0be7132..9ef35d3 100644
> --- a/src/egl/drivers/dri2/egl_dri2.c
> +++ b/src/egl/drivers/dri2/egl_dri2.c
> @@ -2637,6 +2637,7 @@ dri2_create_sync(_EGLDriver *drv, _EGLDisplay *dpy,
>            free(dri2_sync);
>            return NULL;
>         }
> +      dri2_sync->base.SyncFd = EGL_NO_NATIVE_FENCE_FD_ANDROID;
>         break;
>      }
>   
> @@ -2678,24 +2679,25 @@ dri2_dup_native_fence_fd(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync)

please rename this to dri2_get_native_fence_fd

>   {
>      struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
>      struct dri2_egl_sync *dri2_sync = dri2_egl_sync(sync);
> +   EGLint SyncFd = sync->SyncFd;
>   
>      assert(sync->Type == EGL_SYNC_NATIVE_FENCE_ANDROID);
>   
> -   if (sync->SyncFd == EGL_NO_NATIVE_FENCE_FD_ANDROID) {
> +   if (SyncFd == EGL_NO_NATIVE_FENCE_FD_ANDROID) {
>         /* try to retrieve the actual native fence fd.. if rendering is
>          * not flushed this will just return -1, aka NO_NATIVE_FENCE_FD:
>          */
> -      sync->SyncFd = dri2_dpy->fence->get_fence_fd(dri2_dpy->dri_screen,
> +      SyncFd = dri2_dpy->fence->get_fence_fd(dri2_dpy->dri_screen,
>                                                      dri2_sync->fence);

code indentation went wrong here

>      }
>   
> -   if (sync->SyncFd == EGL_NO_NATIVE_FENCE_FD_ANDROID) {
> +   if (SyncFd == EGL_NO_NATIVE_FENCE_FD_ANDROID) {
>         /* if native fence fd still not created, return an error: */
>         _eglError(EGL_BAD_PARAMETER, "eglDupNativeFenceFDANDROID");
>         return EGL_NO_NATIVE_FENCE_FD_ANDROID;
>      }
>   
> -   return dup(sync->SyncFd);
> +   return SyncFd;
>   }
>   
>   static EGLint
> diff --git a/src/mesa/drivers/dri/i965/brw_sync.c b/src/mesa/drivers/dri/i965/brw_sync.c
> index a8356c3..5b78503 100644
> --- a/src/mesa/drivers/dri/i965/brw_sync.c
> +++ b/src/mesa/drivers/dri/i965/brw_sync.c
> @@ -470,7 +470,7 @@ brw_dri_create_fence_fd(__DRIcontext *dri_ctx, int fd)
>            goto fail;
>      } else {
>         /* Import the sync fd as an in-fence. */
> -      fence->sync_fd = dup(fd);
> +      fence->sync_fd = fd;
>      }
>   
>      assert(fence->sync_fd != -1);
> 


More information about the mesa-dev mailing list