Results 1 to 6 of 6

Thread: Texture Sharing.

  1. #1
    Junior Member
    Join Date
    Sep 2009
    Posts
    3

    Texture Sharing.

    I am looking to implement texture sharing between two EGL contexts in two different threads. One thread to do the drawing, and one to load the textures.

    Are there any examples of how to do this?

    If I am just loading a texture from a context do I need to call:

    eglMakeCurrent(currentDisplay, localSurface, localSurface, localContext);

    do I need a surface at all? or is calling:

    eglCreateContext(currentDisplay, currentConfig, currentContext, null);

    enough?


    Regards,
    Keean.

  2. #2
    Senior Member
    Join Date
    May 2006
    Posts
    353

    Re: Texture Sharing.

    Yes, you do need to make the context current to the thread to operate on it, and unfortunately the EGL spec also requires a surface for it, which may not currently be in use by another thread.
    Georg Kolling, Imagination Technologies
    Please ask questions specific to PowerVR hardware or SDKs on the PowerVR Insider Forum
    DevTech@imgtec.com | http://www.powervrinsider.com

  3. #3
    Junior Member
    Join Date
    Sep 2009
    Posts
    3

    Re: Texture Sharing.

    Are there any requirements for the surface? Would a pbuffer be the best type to use?

    When I run the following:

    In OpenGL rendering thread:

    currentDisplay = eglGetCurrentDisplay();
    currentContext = eglGetCurrentContext();
    currentConfig = // config used to select display

    In Texture loading thread:

    localContext = eglCreateContext(currentDisplay, currentConfig, currentContext, null);
    localSurface = eglCreatePbufferSurface(currentDisplay, currentConfig, surfaceAttribs);
    eglMakeCurrent(currentDisplay, localSurface, localSurface, localContext);


    I am getting the error "validate_display_context:475 error 3006 (EGL_BAD_CONTEXT)" from the "eglMakeCurrent" call. Any idea why this is?

    Regards,
    Keean.

  4. #4
    Junior Member
    Join Date
    Sep 2009
    Posts
    3

    Re: Texture Sharing.

    I should point out I test the localContext returned from eglCreateContext like this:

    errc = eglGetError();
    if (errc != EGL10.EGL_SUCCESS) {
    // log error
    }
    if (localContext == EGL_NO_CONTEXT) {
    // log error
    }

    So it appears "eglCreateContext" is returning a valid context, but that "eglMakeCurrent" thinks it is a "EGL_BAD_CONTEXT" when passed a shared-context.

    Right now I suspect this is an implementation dependent issue, but if I am doing anything wrong, please let me know.

  5. #5

    Re: Texture Sharing.

    why do you need to different contexts..? I mean you can use one context only for texture sharing. And threads can share the context, only the condition is that while using shared context, you have to use some mutex / semaphores for synchronization as 1 context can be current to only one thread at a time.

    You can create eglimage and attach texture to it in first thread. And use this eglimage texture directly in another thread.

  6. #6
    Senior Member
    Join Date
    May 2008
    Posts
    104

    Re: Texture Sharing.

    If you want to keep two CPU cores busy or upload textures in the background, having multiple contexts are useful.

    A 1x1 pbuffer surface is usually a good choice.

    That looks correct, it's possible your platform doesn't support shared contexts. They're not the most typical use-case and often support for them can get left for last.

Similar Threads

  1. Problem with GL-CL sharing context
    By eilgin in forum OpenCL
    Replies: 3
    Last Post: 05-20-2011, 04:44 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •