<div dir="ltr"><div>Hi Tapani,<br><br></div><div>Could you please do modification like I suggested to eglut library and check how it is going?<br><br></div><div>I'm asking because I see following code:<br><br>EGLBoolean EGLAPIENTRY<br>eglDestroySurface(EGLDisplay dpy, EGLSurface surface)<br>{<br> _EGLDisplay *disp = _eglLockDisplay(dpy);<br> _EGLSurface *surf = _eglLookupSurface(surface, disp);<br> _EGLDriver *drv;<br> EGLBoolean ret;<br><br> _EGL_FUNC_START(disp, EGL_OBJECT_SURFACE_KHR, surf, EGL_FALSE);<br> _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv);<br> _eglUnlinkSurface(surf);<br> ret = drv->API.DestroySurface(drv, disp, surf);<br><br> RETURN_EGL_EVAL(disp, ret);<br>}<br><br></div><div>It does explicit call to _eglUnlinkSurface(surf) without any conditions which unlinks Surface from current Display and then if we re-use this surface, for example, in eglSwapBuffer() it return EGL_BAD_SURFACE, because _eglCheckSurface() will return error (NULL). This surface was unlinked from Display, but not yet destroyed.<br></div><div><br></div><div>Same applies for Context resource.<br></div><div><br></div>Thank you!<br><div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 27, 2017 at 2:37 AM, Tapani Pälli <span dir="ltr"><<a href="mailto:tapani.palli@intel.com" target="_blank">tapani.palli@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-"><br>
<br>
On 04/26/2017 05:08 PM, Mike Gorchak wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Hi Tapani,<br>
<br>
Sure, I can share them, but they are QNX based. And as far as I remember it was an issue in the past :)<br>
</blockquote>
<br></span>
I thought to ask because there are some multithread dEQP EGL tests around this and they are passing at the moment.<br>
<br>
Surface and context reference counts are incremented in _eglBindContext that gets called during makecurrent. Surface count decrements via _eglPutSurface and _eglPutContext calls. AFAIK everything looks OK.<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">
I think the simplest way for you is to add following calls to function eglutCreateWindow():<br>
<br>
<a href="https://cgit.freedesktop.org/mesa/demos/tree/src/egl/eglut/eglut.c#n321" rel="noreferrer" target="_blank">https://cgit.freedesktop.org/m<wbr>esa/demos/tree/src/egl/eglut/e<wbr>glut.c#n321</a><br>
<br>
|if (!eglMakeCurrent(_eglut->dpy, win->surface, win->surface, win->context)) _eglutFatal("failed to make window current");|<br>
<br>
to<br>
<br>
|if (!eglMakeCurrent(_eglut->dpy, win->surface, win->surface, win->context)) _eglutFatal("failed to make window current");<br>
|<br>
<br>
|||eglDestroySurface(|||_eglut<wbr>->dpy, ||||win->surface|);|<br>
<br>
|eglDestroyContext||(||||_eglu<wbr>t->dpy, ||||win->context||);|<br>
<br>
And then run GLES 1.x gears for example. According to EGL specification, these Destroy calls should be delayed till surface and context is not current in any thread. Perhaps I understand specification too literally, that's why I'm asking rather than reporting it as a bug.<br>
<br>
Thank you!<br>
<br>
<br></span><div><div class="gmail-h5">
On Wed, Apr 26, 2017 at 2:09 AM, Tapani Pälli <<a href="mailto:tapani.palli@intel.com" target="_blank">tapani.palli@intel.com</a> <mailto:<a href="mailto:tapani.palli@intel.com" target="_blank">tapani.palli@intel.com</a><wbr>>> wrote:<br>
<br>
On 04/25/2017 10:20 PM, Mike Gorchak wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Hi all,<br>
<br>
During a quick tests of latest Mesa3D versions at different<br>
branches 12.x, 13.x, 17.x we have found that deferred context and<br>
surface destroy doesn't work properly.<br>
<br>
</blockquote>
<br>
What kind of test case are you using, could you share this?<br>
<br>
</div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div class="gmail-h5">
According to docs:<br>
<a href="https://www.khronos.org/registry/EGL/sdk/docs/man/html/eglDestroySurface.xhtml" rel="noreferrer" target="_blank">https://www.khronos.org/regist<wbr>ry/EGL/sdk/docs/man/html/<wbr>eglDestroySurface.xhtml</a><br>
<<a href="https://www.khronos.org/registry/EGL/sdk/docs/man/html/eglDestroySurface.xhtml" rel="noreferrer" target="_blank">https://www.khronos.org/regis<wbr>try/EGL/sdk/docs/man/html/<wbr>eglDestroySurface.xhtml</a>><br>
<br>
Description<br>
If the EGL surface is not current to any thread, eglDestroySurface<br>
destroys it immediately. Otherwise, surface is destroyed when it<br>
becomes not current to any thread. Furthermore, resources<br>
associated with a pbuffer surface are not released until all color<br>
buffers of that pbuffer bound to a texture object have been released.<br>
<br>
Same for context destroy:<br>
<a href="https://www.khronos.org/registry/EGL/sdk/docs/man/html/eglDestroyContext.xhtml" rel="noreferrer" target="_blank">https://www.khronos.org/regist<wbr>ry/EGL/sdk/docs/man/html/<wbr>eglDestroyContext.xhtml</a><br>
<<a href="https://www.khronos.org/registry/EGL/sdk/docs/man/html/eglDestroyContext.xhtml" rel="noreferrer" target="_blank">https://www.khronos.org/regis<wbr>try/EGL/sdk/docs/man/html/<wbr>eglDestroyContext.xhtml</a>><br>
<br>
Description<br>
If the EGL rendering context is not current to any thread,<br>
eglDestroyContext destroys it immediately. Otherwise, context is<br>
destroyed when it becomes not current to any thread.<br>
<br>
Should this behavior be handled at EGL common DRI2 level or DRI2<br>
platform driver level or it should be handled by EGL itself? I can<br>
see some refcounts implemented for EGL surfaces, buteglMakeCurrent<br>
seems don't increment them for surfaces and contexts.<br>
<br>
Thanks!<br>
<br>
<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br></div></div>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a> <mailto:<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedes<wbr>ktop.org</a>><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
<<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org<wbr>/mailman/listinfo/mesa-dev</a>><br>
</blockquote>
<br>
<br>
<br>
</blockquote>
</blockquote></div><br></div></div></div></div></div>