Chia-I Wu wrote:
> A context or surface that is neither linked to a display nor current to
> a thread should be destroyed.  Therefore, an unlinked context or surface
> implies a pending delete automatically.


IIRC, the EGL spec has some language about deleting surfaces/contexts 
that are currently bound.  Do your changes respect that language?  I 
haven't gone back to re-read the spec so I may be off base.

-Brian


> Signed-off-by: Chia-I Wu <[email protected]>
> ---
>  src/egl/drivers/demo/demo.c                  |   12 ++----------
>  src/egl/drivers/dri/egldri.c                 |   12 ++----------
>  src/egl/drivers/glx/egl_glx.c                |    6 +-----
>  src/egl/drivers/xdri/egl_xdri.c              |    5 +----
>  src/egl/main/eglcontext.c                    |   14 +++++---------
>  src/egl/main/eglcontext.h                    |    1 -
>  src/egl/main/egldisplay.h                    |    5 +++++
>  src/egl/main/eglsurface.c                    |    6 +-----
>  src/egl/main/eglsurface.h                    |    1 -
>  src/gallium/state_trackers/egl/egl_context.c |    4 +---
>  src/gallium/state_trackers/egl/egl_surface.c |    4 +---
>  src/gallium/winsys/egl_xlib/egl_xlib.c       |   10 ++--------
>  src/mesa/drivers/dri/fb/fb_egl.c             |   12 ++----------
>  13 files changed, 23 insertions(+), 69 deletions(-)
> 
> diff --git a/src/egl/drivers/demo/demo.c b/src/egl/drivers/demo/demo.c
> index fa9efa5..f316974 100644
> --- a/src/egl/drivers/demo/demo.c
> +++ b/src/egl/drivers/demo/demo.c
> @@ -236,12 +236,8 @@ demoDestroySurface(_EGLDriver *drv, EGLDisplay dpy, 
> EGLSurface surface)
>  {
>     DemoSurface *fs = LookupDemoSurface(surface);
>     _eglUnlinkSurface(&fs->Base);
> -   if (fs->Base.IsBound) {
> -      fs->Base.DeletePending = EGL_TRUE;
> -   }
> -   else {
> +   if (!fs->Base.IsBound)
>        free(fs);
> -   }
>     return EGL_TRUE;
>  }
> 
> @@ -251,12 +247,8 @@ demoDestroyContext(_EGLDriver *drv, EGLDisplay dpy, 
> EGLContext context)
>  {
>     DemoContext *fc = LookupDemoContext(context);
>     _eglUnlinkContext(&fc->Base);
> -   if (fc->Base.IsBound) {
> -      fc->Base.DeletePending = EGL_TRUE;
> -   }
> -   else {
> +   if (!fc->Base.IsBound)
>        free(fc);
> -   }
>     return EGL_TRUE;
>  }
> 
> diff --git a/src/egl/drivers/dri/egldri.c b/src/egl/drivers/dri/egldri.c
> index df45fbf..3f9617a 100644
> --- a/src/egl/drivers/dri/egldri.c
> +++ b/src/egl/drivers/dri/egldri.c
> @@ -296,12 +296,8 @@ _eglDRIDestroySurface(_EGLDriver *drv, EGLDisplay dpy, 
> EGLSurface surface)
> 
>     fs->drawable.destroyDrawable(disp, fs->drawable.private);
> 
> -   if (fs->Base.IsBound) {
> -      fs->Base.DeletePending = EGL_TRUE;
> -   }
> -   else {
> +   if (!fs->Base.IsBound)
>        free(fs);
> -   }
>     return EGL_TRUE;
>  }
> 
> @@ -316,12 +312,8 @@ _eglDRIDestroyContext(_EGLDriver *drv, EGLDisplay dpy, 
> EGLContext context)
> 
>     fc->driContext.destroyContext(disp, 0, fc->driContext.private);
> 
> -   if (fc->Base.IsBound) {
> -      fc->Base.DeletePending = EGL_TRUE;
> -   }
> -   else {
> +   if (!fc->Base.IsBound)
>        free(fc);
> -   }
>     return EGL_TRUE;
>  }
> 
> diff --git a/src/egl/drivers/glx/egl_glx.c b/src/egl/drivers/glx/egl_glx.c
> index 661b313..207b1ea 100644
> --- a/src/egl/drivers/glx/egl_glx.c
> +++ b/src/egl/drivers/glx/egl_glx.c
> @@ -739,12 +739,8 @@ GLX_eglDestroySurface(_EGLDriver *drv, EGLDisplay dpy, 
> EGLSurface surface)
>     return EGL_TRUE;
>     if (surf) {
>        _eglUnlinkSurface(surf);
> -      if (surf->IsBound) {
> -         surf->DeletePending = EGL_TRUE;
> -      }
> -      else {
> +      if (!surf->IsBound)
>           free(surf);
> -      }
> 
>        return EGL_TRUE;
>     }
> diff --git a/src/egl/drivers/xdri/egl_xdri.c b/src/egl/drivers/xdri/egl_xdri.c
> index 34d69de..e040efd 100644
> --- a/src/egl/drivers/xdri/egl_xdri.c
> +++ b/src/egl/drivers/xdri/egl_xdri.c
> @@ -958,10 +958,7 @@ xdri_eglDestroySurface(_EGLDriver *drv, EGLDisplay dpy, 
> EGLSurface surface)
>     struct xdri_egl_surface *xdri_surf = lookup_surface(surface);
>     if (xdri_surf) {
>        _eglUnlinkSurface(&xdri_surf->Base);
> -      if (xdri_surf->Base.IsBound) {
> -         xdri_surf->Base.DeletePending = EGL_TRUE;
> -      }
> -      else {
> +      if (!xdri_surf->Base.IsBound) {
>           /*
>           st_unreference_framebuffer(surf->Framebuffer);
>           */
> diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c
> index 4e49449..ed7e864 100644
> --- a/src/egl/main/eglcontext.c
> +++ b/src/egl/main/eglcontext.c
> @@ -97,12 +97,8 @@ _eglDestroyContext(_EGLDriver *drv, EGLDisplay dpy, 
> EGLContext ctx)
>     _EGLContext *context = _eglLookupContext(ctx);
>     if (context) {
>        _eglUnlinkContext(context);
> -      if (context->IsBound) {
> -         context->DeletePending = EGL_TRUE;
> -      }
> -      else {
> +      if (!context->IsBound)
>           free(context);
> -      }
>        return EGL_TRUE;
>     }
>     else {
> @@ -147,7 +143,7 @@ _eglQueryContext(_EGLDriver *drv, EGLDisplay dpy, 
> EGLContext ctx,
> 
>  /**
>   * Drivers will typically call this to do the error checking and
> - * update the various IsBound and DeletePending flags.
> + * update the various flags.
>   * Then, the driver will do its device-dependent Make-Current stuff.
>   */
>  EGLBoolean
> @@ -212,7 +208,7 @@ _eglMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, 
> EGLSurface d,
>      */
>     if (oldDrawSurface != NULL) {
>        oldDrawSurface->IsBound = EGL_FALSE;
> -      if (oldDrawSurface->DeletePending) {
> +      if (!_EGL_SURFACE_IS_LINKED(oldDrawSurface)) {
>           /* make sure we don't try to rebind a deleted surface */
>           if (draw == oldDrawSurface || draw == oldReadSurface) {
>              draw = NULL;
> @@ -223,7 +219,7 @@ _eglMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, 
> EGLSurface d,
>     }
>     if (oldReadSurface != NULL && oldReadSurface != oldDrawSurface) {
>        oldReadSurface->IsBound = EGL_FALSE;
> -      if (oldReadSurface->DeletePending) {
> +      if (!_EGL_SURFACE_IS_LINKED(oldReadSurface)) {
>           /* make sure we don't try to rebind a deleted surface */
>           if (read == oldDrawSurface || read == oldReadSurface) {
>              read = NULL;
> @@ -234,7 +230,7 @@ _eglMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, 
> EGLSurface d,
>     }
>     if (oldContext != NULL) {
>        oldContext->IsBound = EGL_FALSE;
> -      if (oldContext->DeletePending) {
> +      if (!_EGL_CONTEXT_IS_LINKED(oldContext)) {
>           /* make sure we don't try to rebind a deleted context */
>           if (ctx == oldContext) {
>              ctx = NULL;
> diff --git a/src/egl/main/eglcontext.h b/src/egl/main/eglcontext.h
> index 8e20643..2fb28d3 100644
> --- a/src/egl/main/eglcontext.h
> +++ b/src/egl/main/eglcontext.h
> @@ -21,7 +21,6 @@ struct _egl_context
>     _EGLSurface *ReadSurface;
> 
>     EGLBoolean IsBound;
> -   EGLBoolean DeletePending;
> 
>     EGLint ClientAPI; /**< EGL_OPENGL_ES_API, EGL_OPENGL_API, EGL_OPENVG_API 
> */
>     EGLint ClientVersion; /**< 1 = OpenGLES 1.x, 2 = OpenGLES 2.x */
> diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h
> index d7a2e60..b3970a2 100644
> --- a/src/egl/main/egldisplay.h
> +++ b/src/egl/main/egldisplay.h
> @@ -8,6 +8,11 @@
>  #include "egltypedefs.h"
> 
> 
> +#define _EGL_DISPLAY_IS_LINKED(dpy) ((dpy)->Handle)
> +#define _EGL_CONTEXT_IS_LINKED(ctx) ((ctx)->Display)
> +#define _EGL_SURFACE_IS_LINKED(surf) ((surf)->Display)

These should be inline functions.


> +
> +
>  struct _egl_display
>  {
>     EGLNativeDisplayType NativeDisplay;
> diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c
> index 8d4df9e..727c694 100644
> --- a/src/egl/main/eglsurface.c
> +++ b/src/egl/main/eglsurface.c
> @@ -419,12 +419,8 @@ _eglDestroySurface(_EGLDriver *drv, EGLDisplay dpy, 
> EGLSurface surface)
>     _EGLSurface *surf = _eglLookupSurface(surface);
>     if (surf) {
>        _eglUnlinkSurface(surf);
> -      if (surf->IsBound) {
> -         surf->DeletePending = EGL_TRUE;
> -      }
> -      else {
> +      if (!surf->IsBound)
>           free(surf);
> -      }
>        return EGL_TRUE;
>     }
>     else {
> diff --git a/src/egl/main/eglsurface.h b/src/egl/main/eglsurface.h
> index f6874e6..f9413eb 100644
> --- a/src/egl/main/eglsurface.h
> +++ b/src/egl/main/eglsurface.h
> @@ -19,7 +19,6 @@ struct _egl_surface
> 
>     /* May need reference counting here */
>     EGLBoolean IsBound;
> -   EGLBoolean DeletePending;
>     EGLBoolean BoundToTexture;
> 
>     EGLint Type; /* one of EGL_WINDOW_BIT, EGL_PIXMAP_BIT or EGL_PBUFFER_BIT 
> */
> diff --git a/src/gallium/state_trackers/egl/egl_context.c 
> b/src/gallium/state_trackers/egl/egl_context.c
> index 7a74cf4..a88b6bc 100644
> --- a/src/gallium/state_trackers/egl/egl_context.c
> +++ b/src/gallium/state_trackers/egl/egl_context.c
> @@ -148,9 +148,7 @@ drm_destroy_context(_EGLDriver *drv, EGLDisplay dpy, 
> EGLContext context)
>  {
>         struct drm_context *c = lookup_drm_context(context);
>         _eglUnlinkContext(&c->base);
> -       if (c->base.IsBound) {
> -               c->base.DeletePending = EGL_TRUE;
> -       } else {
> +       if (!c->base.IsBound) {
>                 st_destroy_context(c->st);
>                 c->pipe->destroy(c->pipe);
>                 free(c);
> diff --git a/src/gallium/state_trackers/egl/egl_surface.c 
> b/src/gallium/state_trackers/egl/egl_surface.c
> index ae2e24b..27fe3c6 100644
> --- a/src/gallium/state_trackers/egl/egl_surface.c
> +++ b/src/gallium/state_trackers/egl/egl_surface.c
> @@ -365,9 +365,7 @@ drm_destroy_surface(_EGLDriver *drv, EGLDisplay dpy, 
> EGLSurface surface)
>  {
>         struct drm_surface *surf = lookup_drm_surface(surface);
>         _eglUnlinkSurface(&surf->base);
> -       if (surf->base.IsBound) {
> -               surf->base.DeletePending = EGL_TRUE;
> -       } else {
> +       if (!surf->base.IsBound) {
>                 if (surf->screen)
>                         drm_takedown_shown_screen(drv, surf->screen);
>                 st_unreference_framebuffer(surf->stfb);
> diff --git a/src/gallium/winsys/egl_xlib/egl_xlib.c 
> b/src/gallium/winsys/egl_xlib/egl_xlib.c
> index 9914dff..e1ddcae 100644
> --- a/src/gallium/winsys/egl_xlib/egl_xlib.c
> +++ b/src/gallium/winsys/egl_xlib/egl_xlib.c
> @@ -382,10 +382,7 @@ xlib_eglDestroyContext(_EGLDriver *drv, EGLDisplay dpy, 
> EGLContext ctx)
>     struct xlib_egl_context *context = lookup_context(ctx);
>     if (context) {
>        _eglUnlinkContext(&context->Base);
> -      if (context->Base.IsBound) {
> -         context->Base.DeletePending = EGL_TRUE;
> -      }
> -      else {
> +      if (!context->Base.IsBound) {
>           /* API-dependent clean-up */
>           switch (context->Base.ClientAPI) {
>           case EGL_OPENGL_ES_API:
> @@ -536,10 +533,7 @@ xlib_eglDestroySurface(_EGLDriver *drv, EGLDisplay dpy, 
> EGLSurface surface)
>     struct xlib_egl_surface *surf = lookup_surface(surface);
>     if (surf) {
>        _eglUnlinkSurface(&surf->Base);
> -      if (surf->Base.IsBound) {
> -         surf->Base.DeletePending = EGL_TRUE;
> -      }
> -      else {
> +      if (!surf->Base.IsBound) {
>           XFreeGC(surf->Dpy, surf->Gc);
>           st_unreference_framebuffer(surf->Framebuffer);
>           free(surf);
> diff --git a/src/mesa/drivers/dri/fb/fb_egl.c 
> b/src/mesa/drivers/dri/fb/fb_egl.c
> index c367741..dee67fe 100644
> --- a/src/mesa/drivers/dri/fb/fb_egl.c
> +++ b/src/mesa/drivers/dri/fb/fb_egl.c
> @@ -605,12 +605,8 @@ fbDestroySurface(_EGLDriver *drv, EGLDisplay dpy, 
> EGLSurface surface)
>  {
>     fbSurface *fs = Lookup_fbSurface(surface);
>     _eglUnlinkSurface(&fs->Base);
> -   if (fs->Base.IsBound) {
> -      fs->Base.DeletePending = EGL_TRUE;
> -   }
> -   else {
> +   if (!fs->Base.IsBound)
>        free(fs);
> -   }
>     return EGL_TRUE;
>  }
> 
> @@ -620,12 +616,8 @@ fbDestroyContext(_EGLDriver *drv, EGLDisplay dpy, 
> EGLContext context)
>  {
>     fbContext *fc = Lookup_fbContext(context);
>     _eglUnlinkContext(&fc->Base);
> -   if (fc->Base.IsBound) {
> -      fc->Base.DeletePending = EGL_TRUE;
> -   }
> -   else {
> +   if (!fc->Base.IsBound)
>        free(fc);
> -   }
>     return EGL_TRUE;
>  }
> 
> --
> 1.6.2.4
> 
> 
> ------------------------------------------------------------------------------
> Enter the BlackBerry Developer Challenge
> This is your chance to win up to $100,000 in prizes! For a limited time,
> vendors submitting new applications to BlackBerry App World(TM) will have
> the opportunity to enter the BlackBerry Developer Challenge. See full prize
> details at: http://p.sf.net/sfu/Challenge
> _______________________________________________
> Mesa3d-dev mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mesa3d-dev
> .
> 


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Mesa3d-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to