[Mesa-dev] [PATCH] i965: avoid fence fd dup in EGL layer
Randy Xu
randy.xu at intel.com
Fri May 5 07:14:39 UTC 2017
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
More information about the mesa-dev
mailing list