[Mesa-dev] egl/dri2: don't require a context for ClientWaitSync (v2)

Submitted by Marek Olšák on Sept. 27, 2015, 6:21 p.m.

Details

Message ID 1443378093-15560-1-git-send-email-maraeo@gmail.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Marek Olšák Sept. 27, 2015, 6:21 p.m.
From: Marek Olšák <marek.olsak@amd.com>

The spec doesn't require it. This fixes a crash on Android.

v2: don't set any flags if ctx == NULL

Cc: 10.6 11.0 <mesa-stable@lists.freedesktop.org>
---
 src/egl/drivers/dri2/egl_dri2.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 1740ee3..4072a02 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -2424,13 +2424,13 @@  dri2_client_wait_sync(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync,
    unsigned wait_flags = 0;
    EGLint ret = EGL_CONDITION_SATISFIED_KHR;
 
-   if (flags & EGL_SYNC_FLUSH_COMMANDS_BIT_KHR)
+   if (dri2_ctx && flags & EGL_SYNC_FLUSH_COMMANDS_BIT_KHR)
       wait_flags |= __DRI2_FENCE_FLAG_FLUSH_COMMANDS;
 
    /* the sync object should take a reference while waiting */
    dri2_egl_ref_sync(dri2_sync);
 
-   if (dri2_dpy->fence->client_wait_sync(dri2_ctx->dri_context,
+   if (dri2_dpy->fence->client_wait_sync(dri2_ctx ? dri2_ctx->dri_context : NULL,
                                          dri2_sync->fence, wait_flags,
                                          timeout))
       dri2_sync->base.SyncStatus = EGL_SIGNALED_KHR;

Comments

On 27/09/15 19:21, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak@amd.com>
>
> The spec doesn't require it. This fixes a crash on Android.
>
> v2: don't set any flags if ctx == NULL
>
> Cc: 10.6 11.0 <mesa-stable@lists.freedesktop.org>
> ---
>  src/egl/drivers/dri2/egl_dri2.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
> index 1740ee3..4072a02 100644
> --- a/src/egl/drivers/dri2/egl_dri2.c
> +++ b/src/egl/drivers/dri2/egl_dri2.c
> @@ -2424,13 +2424,13 @@ dri2_client_wait_sync(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync,
>     unsigned wait_flags = 0;
>     EGLint ret = EGL_CONDITION_SATISFIED_KHR;
>  
Nit: it would be nice to quote the spec here, e.g.:

/*
 * The EGL_KHR_fence_sync spec states:
 *
 *    "If no context is current for the bound API,
 *     the EGL_SYNC_FLUSH_COMMANDS_BIT_KHR bit is ignored.
 */

> -   if (flags & EGL_SYNC_FLUSH_COMMANDS_BIT_KHR)
> +   if (dri2_ctx && flags & EGL_SYNC_FLUSH_COMMANDS_BIT_KHR)
>        wait_flags |= __DRI2_FENCE_FLAG_FLUSH_COMMANDS;
>  
>     /* the sync object should take a reference while waiting */
>     dri2_egl_ref_sync(dri2_sync);
>  
> -   if (dri2_dpy->fence->client_wait_sync(dri2_ctx->dri_context,
> +   if (dri2_dpy->fence->client_wait_sync(dri2_ctx ? dri2_ctx->dri_context : NULL,
>                                           dri2_sync->fence, wait_flags,
>                                           timeout))
>        dri2_sync->base.SyncStatus = EGL_SIGNALED_KHR;
Either way:
Reviewed-by: Frank Binns <frank.binns@imgtec.com>