diff options
author | Sven Gothel <[email protected]> | 2014-12-07 04:03:02 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-12-07 04:03:02 +0100 |
commit | 35622a7cef4a28ce7e32bf008ef331d9a0d9e3e2 (patch) | |
tree | e688b4fcb141c0b6b026d20379fb0ba6dd60a256 /src/jogl/classes/jogamp/opengl/SharedResourceRunner.java | |
parent | 9ea218a5990b908e04235c407c0951c60df6ffba (diff) |
Bug 1068 - Allow GLContext creation and makeCurrent without default framebuffer (Part 2); Bug 896: EGL_KHR_create_context (Part 1)
Bug 1068 - Allow GLContext creation and makeCurrent without default framebuffer (Part 2)
Implement surfaceless context on EGL and GLX/X11
utilizing *UpstreamSurfacelessHook as introduced in
commit 9ea218a5990b908e04235c407c0951c60df6ffba.
Surfaceless context is probed during GL profile probing by default.
If available, it will be used for offscreen FBO drawables.
If probing fails, or is disabled,
the new GLRendererQuirks.NoSurfacelessCtx is set.
- GLProfile.disableSurfacelessContext disables
surfaceless context probing, set property 'jogl.disable.surfacelesscontext'
Tested:
- Mesa/EGL works,
- Mesa + NVidia w/ GLX fail on GNU/Linux): Fails NoSurfacelessCtx
- TODO: Windows impl. and more tests
+++
Bug 896: EGL_KHR_create_context (Part 1)
- Detect EGL_KHR_create_context capability and utilize if available.
- Implement EGLContext.createContextARBImpl(..),
allowing native DEBUG context usage, where available.
- EGL implements SharedResourceRunner, i.e. probing profiles
on dedicated thread using common interface.
- Probe desktop profile/context ability
in EGLDrawableFactory SharedResourceRunner,
Where EGLGLnDynamicLibraryBundleInfo covers EGL + desktop GL.
- TODO: Tests w/ capable implementation
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/SharedResourceRunner.java')
-rw-r--r-- | src/jogl/classes/jogamp/opengl/SharedResourceRunner.java | 106 |
1 files changed, 54 insertions, 52 deletions
diff --git a/src/jogl/classes/jogamp/opengl/SharedResourceRunner.java b/src/jogl/classes/jogamp/opengl/SharedResourceRunner.java index 93a4eb32e..bf8891a25 100644 --- a/src/jogl/classes/jogamp/opengl/SharedResourceRunner.java +++ b/src/jogl/classes/jogamp/opengl/SharedResourceRunner.java @@ -30,21 +30,24 @@ package jogamp.opengl; import java.util.Collection; import java.util.HashSet; import java.util.Iterator; + import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.AbstractGraphicsScreen; +import javax.media.opengl.GLProfile; +import com.jogamp.common.ExceptionUtils; import com.jogamp.opengl.GLRendererQuirks; public class SharedResourceRunner implements Runnable { protected static final boolean DEBUG = GLDrawableImpl.DEBUG; public static interface Resource { - boolean isValid(); + boolean isAvailable(); AbstractGraphicsDevice getDevice(); AbstractGraphicsScreen getScreen(); GLDrawableImpl getDrawable(); GLContextImpl getContext(); - GLRendererQuirks getRendererQuirks(); + GLRendererQuirks getRendererQuirks(GLProfile glp); } public static interface Implementation { @@ -52,19 +55,19 @@ public class SharedResourceRunner implements Runnable { * <p> * Called within synchronized block. * </p> - * @param connection for creation a {@link AbstractGraphicsDevice} instance. + * @param device for creation a {@link AbstractGraphicsDevice} instance. * @return <code>true</code> if the device supports all protocols required for the implementation, otherwise <code>false</code>. */ - boolean isDeviceSupported(String connection); + boolean isDeviceSupported(final AbstractGraphicsDevice device); /** * <p> * Called within synchronized block. * </p> - * @param connection for creation a {@link AbstractGraphicsDevice} instance. + * @param device for creation a {@link AbstractGraphicsDevice} instance. * @return A new shared resource instance */ - Resource createSharedResource(String connection); + Resource createSharedResource(final AbstractGraphicsDevice device); /** Called within synchronized block. */ void releaseSharedResource(Resource shared); @@ -72,9 +75,9 @@ public class SharedResourceRunner implements Runnable { void clear(); /** Called within synchronized block. */ - Resource mapPut(String connection, Resource resource); + Resource mapPut(final AbstractGraphicsDevice device, final Resource resource); /** Called within synchronized block. */ - Resource mapGet(String connection); + Resource mapGet(final AbstractGraphicsDevice device); /** Called within synchronized block. */ Collection<Resource> mapValues(); } @@ -86,17 +89,17 @@ public class SharedResourceRunner implements Runnable { boolean running; boolean ready; boolean shouldRelease; - String initConnection; - String releaseConnection; + AbstractGraphicsDevice initDevice; + AbstractGraphicsDevice releaseDevice; - private boolean getDeviceTried(final String connection) { // synchronized call - return devicesTried.contains(connection); + private boolean getDeviceTried(final AbstractGraphicsDevice device) { // synchronized call + return devicesTried.contains(device.getConnection()); } - private void addDeviceTried(final String connection) { // synchronized call - devicesTried.add(connection); + private void addDeviceTried(final AbstractGraphicsDevice device) { // synchronized call + devicesTried.add(device.getConnection()); } - private void removeDeviceTried(final String connection) { // synchronized call - devicesTried.remove(connection); + private void removeDeviceTried(final AbstractGraphicsDevice device) { // synchronized call + devicesTried.remove(device.getConnection()); } public SharedResourceRunner(final Implementation impl) { @@ -110,8 +113,8 @@ public class SharedResourceRunner implements Runnable { ready = false; running = false; shouldRelease = false; - initConnection = null; - releaseConnection = null; + initDevice = null; + releaseDevice = null; } /** @@ -176,20 +179,20 @@ public class SharedResourceRunner implements Runnable { if(null != device) { synchronized (this) { start(); - final String connection = device.getConnection(); - sr = impl.mapGet(connection); + sr = impl.mapGet(device); if (null == sr) { - if ( !getDeviceTried(connection) ) { - addDeviceTried(connection); + if ( !getDeviceTried(device) ) { + addDeviceTried(device); if (DEBUG) { - System.err.println("SharedResourceRunner.getOrCreateShared() " + connection + ": trying - "+getThreadName()); + System.err.println("SharedResourceRunner.getOrCreateShared() " + device + ": trying - "+getThreadName()); + ExceptionUtils.dumpStack(System.err); } - if ( impl.isDeviceSupported(connection) ) { - doAndWait(connection, null); - sr = impl.mapGet(connection); + if ( impl.isDeviceSupported(device) ) { + doAndWait(device, null); + sr = impl.mapGet(device); } if (DEBUG) { - System.err.println("SharedResourceRunner.getOrCreateShared() " + connection + ": "+ ( ( null != sr ) ? "success" : "failed" ) +" - "+getThreadName()); + System.err.println("SharedResourceRunner.getOrCreateShared() " + device + ": "+ ( ( null != sr ) ? "success" : "failed" ) +" - "+getThreadName()); } } } @@ -202,16 +205,15 @@ public class SharedResourceRunner implements Runnable { SharedResourceRunner.Resource sr = null; if(null != device) { synchronized (this) { - final String connection = device.getConnection(); - sr = impl.mapGet(connection); + sr = impl.mapGet(device); if (null != sr) { - removeDeviceTried(connection); + removeDeviceTried(device); if (DEBUG) { - System.err.println("SharedResourceRunner.releaseShared() " + connection + ": trying - "+getThreadName()); + System.err.println("SharedResourceRunner.releaseShared() " + device + ": trying - "+getThreadName()); } - doAndWait(null, connection); + doAndWait(null, device); if (DEBUG) { - System.err.println("SharedResourceRunner.releaseShared() " + connection + ": done - "+getThreadName()); + System.err.println("SharedResourceRunner.releaseShared() " + device + ": done - "+getThreadName()); } } } @@ -219,13 +221,13 @@ public class SharedResourceRunner implements Runnable { return sr; } - private final void doAndWait(final String initConnection, final String releaseConnection) { + private final void doAndWait(final AbstractGraphicsDevice initDevice, final AbstractGraphicsDevice releaseDevice) { synchronized (this) { // wait until thread becomes ready to init new device, // pass the device and release the sync final String threadName = getThreadName(); if (DEBUG) { - System.err.println("SharedResourceRunner.doAndWait() START init: " + initConnection + ", release: "+releaseConnection+" - "+threadName); + System.err.println("SharedResourceRunner.doAndWait() START init: " + initDevice + ", release: "+releaseDevice+" - "+threadName); } while (!ready && running) { try { @@ -233,20 +235,20 @@ public class SharedResourceRunner implements Runnable { } catch (final InterruptedException ex) { } } if (DEBUG) { - System.err.println("SharedResourceRunner.doAndWait() set command: " + initConnection + ", release: "+releaseConnection+" - "+threadName); + System.err.println("SharedResourceRunner.doAndWait() set command: " + initDevice + ", release: "+releaseDevice+" - "+threadName); } - this.initConnection = initConnection; - this.releaseConnection = releaseConnection; + this.initDevice = initDevice; + this.releaseDevice = releaseDevice; this.notifyAll(); // wait until thread has init/released the device - while ( running && ( !ready || null != this.initConnection || null != this.releaseConnection ) ) { + while ( running && ( !ready || null != this.initDevice || null != this.releaseDevice ) ) { try { this.wait(); } catch (final InterruptedException ex) { } } if (DEBUG) { - System.err.println("SharedResourceRunner.initializeAndWait END init: " + initConnection + ", release: "+releaseConnection+" - "+threadName); + System.err.println("SharedResourceRunner.initializeAndWait END init: " + initDevice + ", release: "+releaseDevice+" - "+threadName); } } // done @@ -283,40 +285,40 @@ public class SharedResourceRunner implements Runnable { if (!shouldRelease) { if (DEBUG) { - System.err.println("SharedResourceRunner.run(): WOKE UP for device connection init: " + initConnection + - ", release: " + releaseConnection + " - " + threadName); + System.err.println("SharedResourceRunner.run(): WOKE UP for device connection init: " + initDevice + + ", release: " + releaseDevice + " - " + threadName); } - if(null != initConnection) { + if(null != initDevice) { if (DEBUG) { - System.err.println("SharedResourceRunner.run(): create Shared for: " + initConnection + " - " + threadName); + System.err.println("SharedResourceRunner.run(): create Shared for: " + initDevice + " - " + threadName); } Resource sr = null; try { - sr = impl.createSharedResource(initConnection); + sr = impl.createSharedResource(initDevice); } catch (final Exception e) { e.printStackTrace(); } if (null != sr) { - impl.mapPut(initConnection, sr); + impl.mapPut(initDevice, sr); } } - if(null != releaseConnection) { + if(null != releaseDevice) { if (DEBUG) { - System.err.println("SharedResourceRunner.run(): release Shared for: " + releaseConnection + " - " + threadName); + System.err.println("SharedResourceRunner.run(): release Shared for: " + releaseDevice + " - " + threadName); } - final Resource sr = impl.mapGet(releaseConnection); + final Resource sr = impl.mapGet(releaseDevice); if (null != sr) { try { impl.releaseSharedResource(sr); - impl.mapPut(releaseConnection, null); + impl.mapPut(releaseDevice, null); } catch (final Exception e) { e.printStackTrace(); } } } } - initConnection = null; - releaseConnection = null; + initDevice = null; + releaseDevice = null; } if (DEBUG) { |