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

Rob Clark robdclark at gmail.com
Thu May 11 14:08:54 UTC 2017


I don't suppose anyone tested this already with any gallium driver?  I
suppose if not, I should (but I didn't bring the right board with me
today so it might have to be tomorrow)

BR,
-R

On Fri, May 5, 2017 at 3:17 AM, Xu, Randy <randy.xu at intel.com> wrote:
> Ping Chad & Emil & Tapani
>
> Please help to review it, I just verified it on Intel i965 driver.
>
> Thanks,
> Randy
>
>
>> -----Original Message-----
>> From: Xu, Randy
>> Sent: Friday, May 5, 2017 3:15 PM
>> To: mesa-dev at lists.freedesktop.org
>> Cc: Xu, Randy <randy.xu at intel.com>
>> Subject: [PATCH] i965: avoid fence fd dup in EGL layer
>>
>> 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.
>> ---
>>  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)  {
>>     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);
>>     }
>>
>> -   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);
>> --
>> 2.7.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list