<div> /**</div><div>+ * Called via eglDestroyContext(), drv->API.DestroyContext().</div><div>+ */</div><div>+static EGLBoolean</div><div>+dri2_destroy_context(_EGLDriver *drv, _EGLDisplay *disp, _EGLContext *ctx)</div><div>
+{</div><div>+ struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx);</div><div>+ struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);</div><div>+</div><div>+ if (_eglPutContext(ctx)) {</div><div>+ dri2_dpy->core->destroyContext(dri2_ctx->dri_context);</div>
<div>+ free(dri2_ctx);</div><div>+ }</div><div>+</div><div>+ return EGL_TRUE;</div><div>+}</div><div>+</div><div>+/**</div><div> * Called via eglMakeCurrent(), drv->API.MakeCurrent().</div><div> */</div><div>
static EGLBoolean</div><div>@@ -765,9 +782,8 @@ dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf,</div><div> drv->API.DestroySurface(drv, disp, old_dsurf);</div><div> if (old_rsurf)</div>
<div> drv->API.DestroySurface(drv, disp, old_rsurf);</div><div>- /* no destroy? */</div><div> if (old_ctx)</div><div>- _eglPutContext(old_ctx);</div><div>+ drv->API.DestroyContext(drv, disp, old_ctx);</div>
<div> </div><div class="gmail_quote">On Sun, Aug 14, 2011 at 12:16 PM, Chia-I Wu <span dir="ltr"><<a href="mailto:olvaffe@gmail.com">olvaffe@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Fri, Aug 12, 2011 at 11:44 PM, Cooper Yuan <<a href="mailto:cooperyuan@gmail.com">cooperyuan@gmail.com</a>> wrote:<br>
> Hi, this patch calls corresponding destroyContext in egl_dri2 and egl_glx<br>
> driver.<br>
> Any comment?<br>
><br>
> Cooper<br>
><br>
> ---<br>
> src/egl/drivers/dri2/egl_dri2.c | 17 +++++++++++++++++<br>
> src/egl/drivers/glx/egl_glx.c | 18 ++++++++++++++++++<br>
> 2 files changed, 35 insertions(+), 0 deletions(-)<br>
><br>
> diff --git a/src/egl/drivers/dri2/egl_dri2.c<br>
> b/src/egl/drivers/dri2/egl_dri2.c<br>
> index 9a37ea4..2d947cd 100644<br>
> --- a/src/egl/drivers/dri2/egl_dri2.c<br>
> +++ b/src/egl/drivers/dri2/egl_dri2.c<br>
> @@ -726,6 +726,22 @@ dri2_create_context(_EGLDriver *drv, _EGLDisplay *disp,<br>
> _EGLConfig *conf,<br>
> }<br>
><br>
> /**<br>
> + * Called via eglDestroyContext(), drv->API.DestroyContext().<br>
> + */<br>
> +static EGLBoolean<br>
> +dri2_destroy_context(_EGLDriver *drv, _EGLDisplay *disp, _EGLContext *ctx)<br>
> +{<br>
> + struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx);<br>
> + struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);<br>
> +<br>
> + _eglPutContext(ctx);<br>
</div>You should check the return value of _eglPutContext and destroy the<br>
context only when it returns true. Then in dri2_make_current, replace<br>
the call to _eglPutContext by a call to drv->API.DestroyContext.<br>
<br>
It should be symmetric to how surfaces are destroyed.<br>
<div><div></div><div class="h5">> + dri2_dpy->core->destroyContext(dri2_ctx->dri_context);<br>
> + free(dri2_ctx);<br>
> +<br>
> + return EGL_TRUE;<br>
> +}<br>
> +<br>
> +/**<br>
> * Called via eglMakeCurrent(), drv->API.MakeCurrent().<br>
> */<br>
> static EGLBoolean<br>
> @@ -1348,6 +1364,7 @@ _EGL_MAIN(const char *args)<br>
> dri2_drv->base.API.Initialize = dri2_initialize;<br>
> dri2_drv->base.API.Terminate = dri2_terminate;<br>
> dri2_drv->base.API.CreateContext = dri2_create_context;<br>
> + dri2_drv->base.API.DestroyContext = dri2_destroy_context;<br>
> dri2_drv->base.API.MakeCurrent = dri2_make_current;<br>
> dri2_drv->base.API.GetProcAddress = dri2_get_proc_address;<br>
> dri2_drv->base.API.WaitClient = dri2_wait_client;<br>
> diff --git a/src/egl/drivers/glx/egl_glx.c b/src/egl/drivers/glx/egl_glx.c<br>
> index 7cf8f4d..b21a3d7 100644<br>
> --- a/src/egl/drivers/glx/egl_glx.c<br>
> +++ b/src/egl/drivers/glx/egl_glx.c<br>
> @@ -713,6 +713,23 @@ GLX_eglCreateContext(_EGLDriver *drv, _EGLDisplay<br>
> *disp, _EGLConfig *conf,<br>
> return &GLX_ctx->Base;<br>
> }<br>
><br>
> +/**<br>
> + * Called via eglDestroyContext(), drv->API.DestroyContext().<br>
> + */<br>
> +static EGLBoolean<br>
> +GLX_eglDestroyContext(_EGLDriver *drv, _EGLDisplay *disp, _EGLContext *ctx)<br>
> +{<br>
> + struct GLX_egl_driver *GLX_drv = GLX_egl_driver(drv);<br>
> + struct GLX_egl_context *GLX_ctx = GLX_egl_context(ctx);<br>
> +<br>
> + _eglPutContext(ctx);<br>
> + assert(GLX_ctx);<br>
> + GLX_drv->glXDestroyContext(disp, ctx);<br>
> +<br>
> + free(GLX_ctx);<br>
> +<br>
> + return EGL_TRUE;<br>
> +}<br>
</div></div>Ditto.<br>
<div class="im">> /**<br>
> * Destroy a surface. The display is allowed to be uninitialized.<br>
> @@ -1142,6 +1159,7 @@ _EGL_MAIN(const char *args)<br>
> GLX_drv->Base.API.Initialize = GLX_eglInitialize;<br>
> GLX_drv->Base.API.Terminate = GLX_eglTerminate;<br>
> GLX_drv->Base.API.CreateContext = GLX_eglCreateContext;<br>
> + GLX_drv->Base.API.DestroyContext = GLX_eglDestroyContext;<br>
> GLX_drv->Base.API.MakeCurrent = GLX_eglMakeCurrent;<br>
> GLX_drv->Base.API.CreateWindowSurface = GLX_eglCreateWindowSurface;<br>
> GLX_drv->Base.API.CreatePixmapSurface = GLX_eglCreatePixmapSurface;<br>
> --<br>
> 1.7.4.4<br>
><br>
><br>
><br>
</div>> _______________________________________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
><br>
><br>
<font color="#888888"><br>
<br>
<br>
--<br>
olv@LunarG.com<br>
</font></blockquote></div><br>