<div dir="ltr">Hi Tapani,<br><div><br>Thank you very much for this explanation! All is clear now, and you are right about function description, they have to be a bit more detailed regarding this. As far as I understood there is a huge GPS navigation framework which depends on wrong behavior regarding deferred context and surface destroy using EGL and GLES drivers for one of the GPUs integrated into ARM based SoC. And this framework failed to run on automotive Intel ApolloLake platform using Mesa3D EGL (which is used even if Intel UFO drivers are used in place of i965 driver).<br><br></div><div>Thanks!<br></div><div><br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Apr 28, 2017 at 1:52 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
<br>
On 04/28/2017 08:08 AM, Tapani Pälli wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
On 04/28/2017 08:05 AM, Tapani Pälli wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
On 04/27/2017 06:59 PM, Mike Gorchak wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Tapani,<br>
<br>
Could you please do modification like I suggested to eglut library and check how it is going?<br>
<br>
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>
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>
</blockquote>
<br>
ok, so in the driver side we do handle refcount but the API side has called _eglUnlinkSurface ... yeah, this looks a bit weird, I'll try to think of an example for this.<br>
<br>
I did not quite get your eglut proposal, I believe in that one I will be destroying surface and context since no other thread has them current at that point. I should have 2 threads where both have made surface current and then destroy surface in another and make sure surface is still usable in another, right?<br>
</blockquote>
<br>
Sorry nope, now I got it. You mean surface should survive because it is still current at same thread.<br>
</blockquote>
<br></span>
Which IMO is not right, although I agree that EGL spec could state it more clearly. For surfaces the spec says:<br>
<br>
"Following eglDestroySurface, the surface and the handle referring to it are treated in the same fashion as a surface destroyed by eglTerminate (see section 3.2)."<br>
<br>
which says:<br>
<br>
"Termination marks all EGL-specific resources, such as contexts and surfaces, associated with the specified display for deletion. Handles to all such resources are invalid as soon as eglTerminate returns, but the dpy handle itself remains valid. Passing such handles to any other EGL command will generate EGL_BAD_SURFACE or EGL_BAD_CONTEXT errors."<br>
<br>
And as bonus there is also section 'Updates to EGL 1.4" that has this:<br>
<br>
"Change object destruction behavior such that object handles become invalid immediately after an object is deleted, although the underlying object may remain valid if it’s current to a context. This affects eglTerminate (section 3.2), eglDestroySurface (section 3.5.5), eglDestroyContext (section 3.7.2), and eglGetCurrentContext and eglGetCurrentSurface (section 3.7.4)."<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Same applies for Context resource.<br>
<br>
Thank you!<br>
<br>
On Thu, Apr 27, 2017 at 2:37 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>
<br>
<br>
    On 04/26/2017 05:08 PM, Mike Gorchak wrote:<br>
<br>
        Hi Tapani,<br>
<br>
        Sure, I can share them, but they are QNX based. And as far as I<br>
        remember it was an issue in the past :)<br>
<br>
<br>
    I thought to ask because there are some multithread dEQP EGL tests<br>
    around this and they are passing at the moment.<br>
<br>
    Surface and context reference counts are incremented in<br>
    _eglBindContext that gets called during makecurrent. Surface count<br>
    decrements via _eglPutSurface and _eglPutContext calls. AFAIK<br>
    everything looks OK.<br>
<br>
<br>
        I think the simplest way for you is to add following calls to<br>
        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>
<<a href="https://cgit.freedesktop.org/mesa/demos/tree/src/egl/eglut/eglut.c#n321" rel="noreferrer" target="_blank">https://cgit.freedesktop.org/<wbr>mesa/demos/tree/src/egl/eglut/<wbr>eglut.c#n321</a>> <br>
<br>
        |if (!eglMakeCurrent(_eglut->dpy, win->surface, win->surface,<br>
        win->context)) _eglutFatal("failed to make window current");|<br>
<br>
        to<br>
<br>
        |if (!eglMakeCurrent(_eglut->dpy, win->surface, win->surface,<br>
        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<br>
        specification, these Destroy calls should be delayed till<br>
        surface and context is not current in any thread. Perhaps I<br>
        understand specification too literally, that's why I'm asking<br>
        rather than reporting it as a bug.<br>
<br>
        Thank you!<br>
<br>
<br>
        On Wed, Apr 26, 2017 at 2:09 AM, Tapani Pälli<br>
        <<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>><br>
        <mailto:<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>>>><br>
        wrote:<br>
<br>
             On 04/25/2017 10:20 PM, Mike Gorchak wrote:<br>
<br>
                 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<br>
            context and<br>
                 surface destroy doesn't work properly.<br>
<br>
<br>
             What kind of test case are you using, could you share this?<br>
<br>
                 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>
<<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>
<<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,<br>
            eglDestroySurface<br>
                 destroys it immediately. Otherwise, surface is<br>
            destroyed when it<br>
                 becomes not current to any thread. Furthermore, resources<br>
                 associated with a pbuffer surface are not released<br>
            until all color<br>
                 buffers of that pbuffer bound to a texture object have<br>
            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>
<<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>
<<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,<br>
            context is<br>
                 destroyed when it becomes not current to any thread.<br>
<br>
                 Should this behavior be handled at EGL common DRI2<br>
            level or DRI2<br>
                 platform driver level or it should be handled by EGL<br>
            itself? I can<br>
                 see some refcounts implemented for EGL surfaces,<br>
            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>
            <a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
            <mailto:<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedes<wbr>ktop.org</a>><br>
            <mailto:<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedes<wbr>ktop.org</a><br>
            <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>
            <<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>
<br>
<br>
<br>
<br>
<br>
</blockquote>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.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>
</blockquote>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.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>
</blockquote>
</div></div></blockquote></div><br></div>