GithubHelp home page GithubHelp logo

Comments (5)

stonesthrow avatar stonesthrow commented on July 22, 2024

You are correct about the EGLContext.

I have seen instances where if you call eglMakeCurrent(dpy, null, null, null); just after eglDestroyContext - as given above - which does result in the real destroy, And then ctx2 could have the same Handle value just by coincidence that its the same block of memory reallocated for the new ctx2. But all object handles are unique. You wont have ctx1 and ctx2 with same handle.

The Handle EGLContext exists, but as you point out, eglDestroyContext and eglTerminate will mark it for destroy, and that basically means from the app you can't use that handle for another egl operation (except for eglMakeCurrent and eglReleaseThread). But internally, that context, being "current", can still be in use for rendering. An so it isn't truly deleted until eglMakeCurrent sets it uncurrent - thus not in use for rendering. You can see why that needs to be, if deleted immediately current running GL/GLES draw calls would could come to a crash with your GPU.

eglGetCurrentContext will return the context made current with eglMakeCurrent on the thread that called that operation - it may be a valid current context or EGL_NO_CONTEXT. A different thread can not make it uncurrent. Think of it as when you create a context or any egl object it exists with one ref count. When made current its get a refcount but owned by that specific thread. Only eglMakeCurrent(dpy, null,null,null) decrements that count and only Destroy or Terminate decrements the original ref count. A count of zero is needed to delete.

from egl-registry.

evelikov avatar evelikov commented on July 22, 2024

FWIW Mesa's implementation matches the reply by @stonesthrow
Namely:

  • ctx1 and ctx2 may be the same, only if the mem. allocator provides the same address
  • eglGetCurrent* gets the thread specific data, which in the case of a eglDestroy* call is "unlinked" (the term used in Mesa), thus EGL_NO_* is returned.

from egl-registry.

stonesthrow avatar stonesthrow commented on July 22, 2024

If the questions/concerns/issues have been addressed, then lets close this issue?

from egl-registry.

kbrenneman avatar kbrenneman commented on July 22, 2024

The crux of the question is whether there's an identity relationship between an EGLContext handle and the actual context. That would define what it means when a handle is "invalidated" after eglDestroyContext or eglTerminate returns.

@stonesthrow's (and my) interpretation assumes that there must be an identity relationship between the EGLContext handle and the context. In that case, the handle must be in use as long as the context exists, and therefore you can't re-use the same handle as long as the old context is current.

If an EGLContext handle is simply a pointer to the driver's internal reference-counted context struct, then this is the behavior you'd get.

If you don't assume an identity relationship, then you could read it that the EGLContext handle is more like the context XID in GLX. If the client sends a GLXDestroyContext request for a current context. then the resource ID is destroyed, but the context in the server still sticks around. You can still reference the context by context tag, and (I think) the client could then use that XID for another GLXCreateContext request.

You could get behavior like that if a driver kept an array of pointers to its internal (still reference-counted) context structs, and used an index into that array as an EGLContext handle.

Anyway, I'd be perfectly happy to close the issue and take the first option of not reusing a context, since that's the only way I can think of to get coherent results from eglGetCurrentContext. I just want to make sure we've nailed down the identity question.

from egl-registry.

stonesthrow avatar stonesthrow commented on July 22, 2024

Discussed in EGL WG, clarification is warranted. KBrenneman to propose text in a new Khronos gitlab MR

from egl-registry.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.