Context sharing between offscreen drawable and external GL context

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Context sharing between offscreen drawable and external GL context

TomN
I have a problem with GL context sharing, of which I'm not sure if it's in my code, in JOGL or in the driver. My setup is as follows. I have a Java library which renders into an offscreen drawable. This library needs to be integrated into a native host application (C++, C#, ...). To do so, the Java code renders into a texture, which I then want to make available to a GL context created by the native code. I set this up as follows:
  • The native code creates a GL context and makes it current
  • The Java code creates an external GL context (corresponding to the native one)
  • On a different thread, the Java code then creates an offscreen drawable which shares with the external GL context
For various reasons, it would be convenient if the "different thread" above could be the EDT. However, on Windows systems with NVidia GPUs, that doesn't work. After the offscreen drawable is created, the first call to display() results in an exception:
  com.jogamp.opengl.GLException: AWT-EventQueue-0: createImpl ctx !ARB but ARB is used, profile > GL2 requested (OpenGL >= 3.1). Requested: GLProfile[GL4bc/GL4bc.hw], current: 4.5 (Compat profile, compat[ES2, ES3, ES31], FBO, hardware) - 4.5.0 NVIDIA 347.52
    at jogamp.opengl.windows.wgl.WindowsWGLContext.createImpl(WindowsWGLContext.java:377)
    at jogamp.opengl.GLContextImpl.makeCurrentWithinLock(GLContextImpl.java:757)
    at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:642)
    at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:580)
    at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1263)
    at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1131)
    at jogamp.opengl.GLAutoDrawableBase.defaultDisplay(GLAutoDrawableBase.java:475)
    at com.jogamp.opengl.GLAutoDrawableDelegate.display(GLAutoDrawableDelegate.java:190)
When I use a dedicated (non-EDT) thread, this error does not occur. On an AMD GPU, either approach works fine.

I've narrowed this whole scenario down to a unit test: ShareWithExternalContextTest.java

The test covers both the EDT and non-EDT case (the latter uses a single-threaded ExecutorService). I used a second offscreen drawable as a stub for the native GL context.

Any idea what causes this error or how I could work around it (while continuing to use the EDT)? Should I file this as a JOGL bug?

Thanks, Tom

Reply | Threaded
Open this post in threaded view
|

Re: Context sharing between offscreen drawable and external GL context

gouessej
Administrator
Hi

It reminds me a bug... Which version of JOGL do you use? Maybe there is a way of working around this bug, it depends on which profile you request.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Context sharing between offscreen drawable and external GL context

TomN
I tried 2.1.5 and 2.3.1 -- the result is the same. I also tried using the GL2 profile on both sides. I'll test again using higher versions to see if that makes a difference.

Can anyone by any chance shed any light on why it makes a difference whether I use the EDT or not?

Thanks,
Tom
Reply | Threaded
Open this post in threaded view
|

Re: Context sharing between offscreen drawable and external GL context

Xerxes Rånby
In reply to this post by TomN
TomN wrote
<p/>
I've narrowed this whole scenario down to a unit test: ShareWithExternalContextTest.java
<p/>
The test covers both the EDT and non-EDT case (the latter uses a single-threaded ExecutorService). I used a second offscreen drawable as a stub for the native GL context.
<p/>
Any idea what causes this error or how I could work around it (while continuing to use the EDT)? Should I file this as a JOGL bug?
<p/>
Thank you for creating a unit test!
Do you mind cloning our jogl git and adding your unit test to
jogl/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ShareWithExternalContextTest.java
send a pull request and file a bug in our bugzilla.
This will allow us to run the test on all platforms that we support.
http://jogamp.org/wiki/index.php/Contributing_a_new_feature_or_fix
Reply | Threaded
Open this post in threaded view
|

Re: Context sharing between offscreen drawable and external GL context

TomN
Reply | Threaded
Open this post in threaded view
|

Re: Context sharing between offscreen drawable and external GL context

gigs
In reply to this post by gouessej
There's been a few of these lately, this looks like it's the third different test case about this message. These two are very similar:

https://jogamp.org/bugzilla/show_bug.cgi?id=1158
https://jogamp.org/bugzilla/show_bug.cgi?id=1146

It's the first time I see it on Nvidia only, though.