diff options
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/egl')
8 files changed, 518 insertions, 362 deletions
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java index b6a05aeeb..28448d537 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java @@ -49,9 +49,9 @@ import com.jogamp.opengl.GLProfile; import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLDrawableImpl; +import jogamp.opengl.GLDynamicLookupHelper; import jogamp.opengl.egl.EGLExtImpl; import jogamp.opengl.egl.EGLExtProcAddressTable; -import jogamp.opengl.windows.wgl.WindowsWGLContext; import com.jogamp.common.ExceptionUtils; import com.jogamp.common.nio.Buffers; @@ -168,19 +168,17 @@ public class EGLContext extends GLContextImpl { final long eglConfig = config.getNativeConfig(); final EGLDrawableFactory factory = (EGLDrawableFactory) drawable.getFactoryImpl(); - final boolean hasOpenGLAPISupport = factory.hasOpenGLAPISupport(); + final boolean hasFullOpenGLAPISupport = factory.hasOpenGLDesktopSupport(); final boolean useKHRCreateContext = factory.hasDefaultDeviceKHRCreateContext(); - final boolean allowOpenGLAPI = hasOpenGLAPISupport && useKHRCreateContext; - final boolean ctDesktopGL = 0 == ( GLContext.CTX_PROFILE_ES & ctp ); + final boolean ctDesktopGL = 0 == ( CTX_PROFILE_ES & ctp ); final boolean ctBwdCompat = 0 != ( CTX_PROFILE_COMPAT & ctp ) ; final boolean ctFwdCompat = 0 != ( CTX_OPTION_FORWARD & ctp ) ; final boolean ctDebug = 0 != ( CTX_OPTION_DEBUG & ctp ) ; if(DEBUG) { System.err.println(getThreadName() + ": EGLContext.createContextARBImpl: Start "+getGLVersion(reqMajor, reqMinor, ctp, "@creation") - + ", hasOpenGLAPISupport "+hasOpenGLAPISupport + ", useKHRCreateContext "+useKHRCreateContext - + ", allowOpenGLAPI "+allowOpenGLAPI + + ", OpenGL API Support "+hasFullOpenGLAPISupport + ", device "+device); } if ( 0 == eglDisplay ) { @@ -203,8 +201,7 @@ public class EGLContext extends GLContextImpl { * hence it must be switched before makeCurrent w/ different APIs, see: * eglWaitClient(); */ - if( ctDesktopGL && !allowOpenGLAPI ) { - // if( ctDesktopGL && !hasOpenGLAPISupport ) { + if( ctDesktopGL && !hasFullOpenGLAPISupport ) { if(DEBUG) { System.err.println(getThreadName() + ": EGLContext.createContextARBImpl: DesktopGL not avail "+getGLVersion(reqMajor, reqMinor, ctp, "@creation")); } @@ -212,7 +209,7 @@ public class EGLContext extends GLContextImpl { } try { - if( allowOpenGLAPI && device.getEGLVersion().compareTo(Version1_2) >= 0 ) { + if( hasFullOpenGLAPISupport && device.getEGLVersion().compareTo(Version1_2) >= 0 ) { EGL.eglWaitClient(); // EGL >= 1.2 } if( !EGL.eglBindAPI( ctDesktopGL ? EGL.EGL_OPENGL_API : EGL.EGL_OPENGL_ES_API) ) { @@ -238,11 +235,11 @@ public class EGLContext extends GLContextImpl { int index = ctx_attribs_idx_major + 2; - /** if( ctDesktopGL && reqMinor >= 0 ) { // FIXME: No minor version probing for ES currently! + if( reqMinor >= 0 ) { attribs.put(index + 0, EGLExt.EGL_CONTEXT_MINOR_VERSION_KHR); attribs.put(index + 1, reqMinor); index += 2; - } */ + } if( ctDesktopGL && ( useMajor > 3 || useMajor == 3 && reqMinor >= 2 ) ) { attribs.put(index + 0, EGLExt.EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR); @@ -364,14 +361,17 @@ public class EGLContext extends GLContextImpl { } @Override - protected final void updateGLXProcAddressTable() { + protected final void updateGLXProcAddressTable(final String contextFQN, final GLDynamicLookupHelper dlh) { + if( null == dlh ) { + throw new GLException("No GLDynamicLookupHelper for "+this); + } final AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration(); final AbstractGraphicsDevice adevice = aconfig.getScreen().getDevice(); final String key = "EGL-"+adevice.getUniqueID(); + // final String key = contextFQN; if (DEBUG) { System.err.println(getThreadName() + ": Initializing EGLextension address table: "+key); } - ProcAddressTable table = null; synchronized(mappedContextTypeObjectLock) { table = mappedGLXProcAddress.get( key ); @@ -386,7 +386,7 @@ public class EGLContext extends GLContextImpl { } } else { eglExtProcAddressTable = new EGLExtProcAddressTable(new GLProcAddressResolver()); - resetProcAddressTable(eglExtProcAddressTable); + resetProcAddressTable(eglExtProcAddressTable, dlh); synchronized(mappedContextTypeObjectLock) { mappedGLXProcAddress.put(key, eglExtProcAddressTable); if(DEBUG) { @@ -432,11 +432,21 @@ public class EGLContext extends GLContextImpl { } @Override - protected boolean setSwapIntervalImpl(final int interval) { - if( hasRendererQuirk(GLRendererQuirks.NoSetSwapInterval) ) { - return false; + protected final Integer setSwapIntervalImpl2(final int interval) { + if( !drawable.getChosenGLCapabilities().isOnscreen() || + hasRendererQuirk(GLRendererQuirks.NoSetSwapInterval) ) { + return null; + } + final int useInterval; + if( 0 > interval ) { + useInterval = Math.abs(interval); + } else { + useInterval = interval; } - return EGL.eglSwapInterval(drawable.getNativeSurface().getDisplayHandle(), interval); + if( EGL.eglSwapInterval(drawable.getNativeSurface().getDisplayHandle(), useInterval) ) { + return Integer.valueOf(useInterval); + } + return null; } static long eglGetProcAddress(final long eglGetProcAddressHandle, final String procname) @@ -453,52 +463,32 @@ public class EGLContext extends GLContextImpl { // Accessible .. // - /* pp */ void mapCurrentAvailableGLESVersion(final AbstractGraphicsDevice device) { - mapStaticGLESVersion(device, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); + /* pp */ static final boolean isGLES1(final int majorVersion, final int ctxOptions) { + return 0 != ( ctxOptions & GLContext.CTX_PROFILE_ES ) && majorVersion == 1 ; } - /* pp */ int getContextOptions() { return ctxOptions; } - /* pp */ static void mapStaticGLESVersion(final AbstractGraphicsDevice device, final GLCapabilitiesImmutable caps) { - final GLProfile glp = caps.getGLProfile(); - final int[] reqMajorCTP = new int[2]; - GLContext.getRequestMajorAndCompat(glp, reqMajorCTP); - if( glp.isGLES() ) { - if( reqMajorCTP[0] >= 3 ) { - reqMajorCTP[1] |= GLContext.CTX_IMPL_ES3_COMPAT | GLContext.CTX_IMPL_ES2_COMPAT | GLContext.CTX_IMPL_FBO ; - } else if( reqMajorCTP[0] >= 2 ) { - reqMajorCTP[1] |= GLContext.CTX_IMPL_ES2_COMPAT | GLContext.CTX_IMPL_FBO ; - } - } - if( !caps.getHardwareAccelerated() ) { - reqMajorCTP[1] |= GLContext.CTX_IMPL_ACCEL_SOFT; + /* pp */ static final boolean isGLES2ES3(final int majorVersion, final int ctxOptions) { + if( 0 != ( ctxOptions & CTX_PROFILE_ES ) ) { + return 2 == majorVersion || 3 == majorVersion; + } else { + return false; } - mapStaticGLESVersion(device, reqMajorCTP[0], 0, reqMajorCTP[1]); } - /* pp */ static void mapStaticGLESVersion(final AbstractGraphicsDevice device, final int major, final int minor, final int ctp) { - if( 0 != ( ctp & GLContext.CTX_PROFILE_ES) ) { - // ES1, ES2, ES3, .. - mapStaticGLESVersion(device, major /* reqMajor */, major, minor, ctp); - if( 3 == major ) { - // map ES2 -> ES3 - mapStaticGLESVersion(device, 2 /* reqMajor */, major, minor, ctp); - } - } + /* pp */ static final boolean isGLDesktop(final int ctxOptions) { + return 0 != (ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_CORE)); } - private static void mapStaticGLESVersion(final AbstractGraphicsDevice device, final int reqMajor, final int major, final int minor, final int ctp) { - GLContext.mapAvailableGLVersion(device, reqMajor, GLContext.CTX_PROFILE_ES, major, minor, ctp); - if(! ( device instanceof EGLGraphicsDevice ) ) { - final EGLGraphicsDevice eglDevice = new EGLGraphicsDevice(device.getHandle(), EGL.EGL_NO_DISPLAY, device.getConnection(), device.getUnitID(), null); - GLContext.mapAvailableGLVersion(eglDevice, reqMajor, GLContext.CTX_PROFILE_ES, major, minor, ctp); - } + protected static StringBuilder getGLProfile(final StringBuilder sb, final int ctp) { + return GLContext.getGLProfile(sb, ctp); } - protected static String getGLVersion(final int major, final int minor, final int ctp, final String gl_version) { - return GLContext.getGLVersion(major, minor, ctp, gl_version); + /* pp */ int getContextOptions() { return ctxOptions; } + protected static void remapAvailableGLVersions(final AbstractGraphicsDevice fromDevice, final AbstractGraphicsDevice toDevice) { + GLContextImpl.remapAvailableGLVersions(fromDevice, toDevice); } - - protected static boolean getAvailableGLVersionsSet(final AbstractGraphicsDevice device) { - return GLContext.getAvailableGLVersionsSet(device); + protected static synchronized void setMappedGLVersionListener(final MappedGLVersionListener mvl) { + GLContextImpl.setMappedGLVersionListener(mvl); } - protected static void setAvailableGLVersionsSet(final AbstractGraphicsDevice device, final boolean set) { - GLContext.setAvailableGLVersionsSet(device, set); + + protected static String getGLVersion(final int major, final int minor, final int ctp, final String gl_version) { + return GLContext.getGLVersion(major, minor, ctp, gl_version); } protected static String toHexString(final int hex) { diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java b/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java index 3d2d03403..fcd4f54eb 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java @@ -80,10 +80,17 @@ public class EGLDisplayUtil { static EGLDisplayRef getOrCreateOpened(final long eglDisplay, final IntBuffer major, final IntBuffer minor) { final EGLDisplayRef o = (EGLDisplayRef) openEGLDisplays.get(eglDisplay); if( null == o ) { - if( EGL.eglInitialize(eglDisplay, major, minor) ) { + final boolean ok = EGL.eglInitialize(eglDisplay, major, minor); + if( DEBUG ) { + System.err.println("EGLDisplayUtil.EGL.eglInitialize 0x"+Long.toHexString(eglDisplay)+" -> "+ok); + } + if( ok ) { final EGLDisplayRef n = new EGLDisplayRef(eglDisplay); openEGLDisplays.put(eglDisplay, n); n.initRefCount++; + if( DEBUG ) { + System.err.println("EGLDisplayUtil.EGL.eglInitialize "+n); + } if( null == singletonEGLDisplay ) { singletonEGLDisplay = n; } @@ -113,7 +120,12 @@ public class EGLDisplayUtil { if( 0 < o.initRefCount ) { // no negative refCount o.initRefCount--; if( 0 == o.initRefCount ) { - res[0] = EGL.eglTerminate(eglDisplay); + final boolean ok = EGL.eglTerminate(eglDisplay); + if( DEBUG ) { + System.err.println("EGLDisplayUtil.EGL.eglTerminate 0x"+Long.toHexString(eglDisplay)+" -> "+ok); + System.err.println("EGLDisplayUtil.EGL.eglTerminate "+o); + } + res[0] = ok; if( o == singletonEGLDisplay ) { singletonEGLDisplay = null; } @@ -340,6 +352,22 @@ public class EGLDisplayUtil { * <p> * Using the default {@link ToolkitLock}, via {@link NativeWindowFactory#getDefaultToolkitLock(String, long)}. * </p> + * @param adevice + * @return an uninitialized {@link EGLGraphicsDevice} + */ + public static EGLGraphicsDevice eglCreateEGLGraphicsDevice(final AbstractGraphicsDevice aDevice) { + return new EGLGraphicsDevice(aDevice, EGL.EGL_NO_DISPLAY, eglLifecycleCallback); + } + + /** + * Returns an uninitialized {@link EGLGraphicsDevice}. User needs to issue {@link EGLGraphicsDevice#open()} before usage. + * <p> + * Using {@link #eglGetDisplayAndInitialize(long[])} for the {@link EGLGraphicsDevice#open()} implementation + * and {@link #eglTerminate(long)} for {@link EGLGraphicsDevice#close()}. + * </p> + * <p> + * Using the default {@link ToolkitLock}, via {@link NativeWindowFactory#getDefaultToolkitLock(String, long)}. + * </p> * @param surface * @return an uninitialized EGLGraphicsDevice */ diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java index e63a63634..ef3c96aeb 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java @@ -36,6 +36,7 @@ package jogamp.opengl.egl; +import com.jogamp.common.ExceptionUtils; import com.jogamp.nativewindow.ProxySurface; import com.jogamp.opengl.GLContext; import com.jogamp.opengl.GLException; @@ -82,7 +83,10 @@ public class EGLDrawable extends GLDrawableImpl { final EGLSurface eglSurf = (EGLSurface) surface; final long eglSurfHandle = eglSurf.getSurfaceHandle(); if(DEBUG) { - System.err.println(getThreadName() + ": destroyHandle of "+eglSurf); + System.err.println(getThreadName() + ": EGLDrawable: destroyHandle of "+toHexString(eglSurfHandle)); + ProxySurfaceImpl.dumpHierarchy(System.err, eglSurf); + System.err.println(getThreadName() + ": EGLSurface : "+eglSurf); + ExceptionUtils.dumpStack(System.err); } if( !eglSurf.containsUpstreamOptionBits( ProxySurface.OPT_UPSTREAM_SURFACELESS ) && EGL.EGL_NO_SURFACE == eglSurfHandle ) { diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java index 4fecafdfc..fed02f34e 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java @@ -38,10 +38,9 @@ package jogamp.opengl.egl; import java.nio.IntBuffer; import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.Set; import com.jogamp.nativewindow.AbstractGraphicsConfiguration; @@ -67,6 +66,7 @@ import com.jogamp.opengl.GLProfile; import jogamp.common.os.PlatformPropsImpl; import jogamp.opengl.Debug; import jogamp.opengl.GLContextImpl; +import jogamp.opengl.GLContextImpl.MappedGLVersion; import jogamp.opengl.GLDrawableFactoryImpl; import jogamp.opengl.GLDrawableImpl; import jogamp.opengl.GLDynamicLookupHelper; @@ -78,7 +78,6 @@ import com.jogamp.common.nio.Buffers; import com.jogamp.common.nio.PointerBuffer; import com.jogamp.common.os.DynamicLookupHelper; import com.jogamp.common.os.Platform; -import com.jogamp.common.util.PropertyAccess; import com.jogamp.common.util.ReflectionUtil; import com.jogamp.common.util.VersionNumber; import com.jogamp.nativewindow.GenericUpstreamSurfacelessHook; @@ -90,17 +89,20 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { protected static final boolean DEBUG = GLDrawableFactoryImpl.DEBUG; // allow package access private static final boolean DEBUG_SHAREDCTX = DEBUG || GLContext.DEBUG; - /* package */ static final boolean QUERY_EGL_ES_NATIVE_TK; - static { Debug.initSingleton(); - QUERY_EGL_ES_NATIVE_TK = PropertyAccess.isPropertyDefined("jogl.debug.EGLDrawableFactory.QueryNativeTK", true); } private static boolean eglDynamicLookupHelperInit = false; private static GLDynamicLookupHelper eglES1DynamicLookupHelper = null; private static GLDynamicLookupHelper eglES2DynamicLookupHelper = null; private static GLDynamicLookupHelper eglGLnDynamicLookupHelper = null; + private static boolean isANGLE = false; + private static boolean hasX11 = false; + private static String defaultConnection = null; + private static EGLGraphicsDevice defaultDevice = null; + private static EGLFeatures defaultDeviceEGLFeatures = null; + private static SharedResource defaultSharedResource = null; private static final boolean isANGLE(final GLDynamicLookupHelper dl) { if(Platform.OSType.WINDOWS == PlatformPropsImpl.OS_TYPE) { @@ -128,7 +130,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { public EGLFeatures(final EGLGraphicsDevice device) { final long eglDisplay = device.getHandle(); vendor = EGL.eglQueryString(eglDisplay, EGL.EGL_VENDOR); - if(DEBUG) { + if(DEBUG_SHAREDCTX) { System.err.println("EGLFeatures on device "+device+", vendor "+vendor); } version = device.getEGLVersion(); @@ -139,13 +141,13 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { final String eglClientAPIStr = EGL.eglQueryString(eglDisplay, EGL.EGL_CLIENT_APIS); if( hasEGL_1_4 ) { final String[] eglClientAPIs = eglClientAPIStr.split("\\s"); - for(int i=eglClientAPIs.length-1; i>=0; i--) { + for(int i=eglClientAPIs.length-1; !_hasGLAPI && i>=0; i--) { _hasGLAPI = eglClientAPIs[i].equals("OpenGL"); } } hasGLAPI = _hasGLAPI; - if(DEBUG) { - System.err.println(" Client APIs: "+eglClientAPIStr+"; has EGL 1.4 "+hasEGL_1_4+" -> has OpenGL "+hasGLAPI); + if(DEBUG_SHAREDCTX) { + System.err.println(" Client APIs: '"+eglClientAPIStr+"'; has EGL 1.4 "+hasEGL_1_4+" -> has OpenGL "+hasGLAPI); } } { @@ -163,7 +165,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } hasKHRSurfaceless = extensions.contains("EGL_KHR_surfaceless_context"); } - if(DEBUG) { + if(DEBUG_SHAREDCTX) { System.err.println(" Extensions: "+extensions); System.err.println(" KHR_create_context: "+hasKHRCreateContext); System.err.println(" KHR_surfaceless_context: "+hasKHRSurfaceless); @@ -193,12 +195,16 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { eglDynamicLookupHelperInit = true; // Check for other underlying stuff .. - if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(true)) { + final String nwt = NativeWindowFactory.getNativeWindowType(true); + if(NativeWindowFactory.TYPE_X11 == nwt) { hasX11 = true; try { ReflectionUtil.createInstance("jogamp.opengl.x11.glx.X11GLXGraphicsConfigurationFactory", EGLDrawableFactory.class.getClassLoader()); } catch (final Exception jre) { /* n/a .. */ } + } else { + hasX11 = false; } + defaultConnection = NativeWindowFactory.getDefaultDisplayConnection(nwt); /** * FIXME: Probably need to move EGL from a static model @@ -337,14 +343,14 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { // The act of constructing them causes them to be registered EGLGraphicsConfigurationFactory.registerFactory(); - sharedMap = new HashMap<String, SharedResourceRunner.Resource>(); - - // FIXME: defaultDevice.open() triggers eglInitialize(..) which crashed on Windows w/ Chrome/ANGLE, FF/ANGLE! - defaultDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); + // Note: defaultDevice.open() triggers eglInitialize(..) which crashed on Windows w/ Chrome/ANGLE, FF/ANGLE! + // Hence opening will happen later, eventually + defaultDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, defaultConnection, AbstractGraphicsDevice.DEFAULT_UNIT); // Init shared resources off thread // Will be released via ShutdownHook - sharedResourceRunner = new SharedResourceRunner(new SharedResourceImplementation()); + sharedResourceImplementation = new SharedResourceImplementation(); + sharedResourceRunner = new SharedResourceRunner(sharedResourceImplementation); sharedResourceRunner.start(); } } @@ -353,7 +359,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { @Override protected final boolean isComplete() { - return null != sharedMap; // null != eglES2DynamicLookupHelper || null != eglES1DynamicLookupHelper; + return null != sharedResourceImplementation; // null != eglES2DynamicLookupHelper || null != eglES1DynamicLookupHelper || ..; } @@ -366,9 +372,9 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { sharedResourceRunner.stop(); sharedResourceRunner = null; } - if(null != sharedMap) { - sharedMap.clear(); - sharedMap = null; + if(null != sharedResourceImplementation) { + sharedResourceImplementation.clear(); + sharedResourceImplementation = null; } if(null != defaultDevice) { @@ -395,57 +401,63 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } private void dumpMap() { - synchronized(sharedMap) { - System.err.println("EGLDrawableFactory.map "+sharedMap.size()); + synchronized(sharedResourceImplementation) { + final Map<String /* uniqueId */, SharedResourceRunner.Resource> sharedMap = sharedResourceImplementation.getSharedMap(); + System.err.println("EGLDrawableFactory.MapGLVersion.map "+sharedMap.size()); int i=0; final Set<String> keys = sharedMap.keySet(); for(final Iterator<String> keyI = keys.iterator(); keyI.hasNext(); i++) { final String key = keyI.next(); final SharedResource sr = (SharedResource) sharedMap.get(key); - System.err.println("EGLDrawableFactory.map["+i+"] "+key+" -> "+sr.getDevice()+", avail "+sr.isAvailable+ - "gln [quirks "+sr.rendererQuirksGLn+", ctp "+EGLContext.getGLVersion(3, 0, sr.ctpGLn, null)+"], "+ - "es1 [quirks "+sr.rendererQuirksES1+", ctp "+EGLContext.getGLVersion(1, 0, sr.ctpES1, null)+"], "+ - "es2/3 [quirks "+sr.rendererQuirksES3ES2+", ctp "+EGLContext.getGLVersion(2, 0, sr.ctpES3ES2, null)+"]"); + System.err.println("EGLDrawableFactory.MapGLVersion.map["+i+"] "+key+" -> "+sr.getDevice()+", avail "+sr.isAvailable+", "+ + "es1 [avail "+sr.isAvailableES1+", quirks "+sr.rendererQuirksES1+", ctp "+EGLContext.getGLVersion(1, 0, sr.ctpES1, null)+"], "+ + "es2 [avail "+sr.isAvailableES2+", quirks "+sr.rendererQuirksES2+", ctp "+EGLContext.getGLVersion(2, 0, sr.ctpES2, null)+"], "+ + "es3 [avail "+sr.isAvailableES3+", quirks "+sr.rendererQuirksES3+", ctp "+EGLContext.getGLVersion(2, 0, sr.ctpES3, null)+"], "+ + "gln [avail "+sr.isAvailableGLn+", quirks "+sr.rendererQuirksGLn+", ctp "+EGLContext.getGLVersion(3, 0, sr.ctpGLn, null)+"]"); } ; } } - private boolean isANGLE = false; - private boolean hasX11 = false; - private EGLGraphicsDevice defaultDevice = null; - private EGLFeatures defaultDeviceEGLFeatures; + private SharedResourceImplementation sharedResourceImplementation; private SharedResourceRunner sharedResourceRunner; - private HashMap<String /* uniqueKey */, SharedResourceRunner.Resource> sharedMap; static class SharedResource implements SharedResourceRunner.Resource { private EGLGraphicsDevice device; - // private final EGLContext contextES1; - // private final EGLContext contextES2; - // private final EGLContext contextES3; final boolean isAvailable; - final GLRendererQuirks rendererQuirksGLn; + final boolean isAvailableES1; + final boolean isAvailableES2; + final boolean isAvailableES3; + final boolean isAvailableGLn; final GLRendererQuirks rendererQuirksES1; - final GLRendererQuirks rendererQuirksES3ES2; - final int ctpGLn; + final GLRendererQuirks rendererQuirksES2; + final GLRendererQuirks rendererQuirksES3; + final GLRendererQuirks rendererQuirksGLn; final int ctpES1; - final int ctpES3ES2; + final int ctpES2; + final int ctpES3; + final int ctpGLn; - SharedResource(final EGLGraphicsDevice dev, final boolean isAvailable, - final GLRendererQuirks rendererQuirksGLn, final int ctpGLn, - final GLRendererQuirks rendererQuirksES1, final int ctpES1, - final GLRendererQuirks rendererQuirksES3ES2, final int ctpES3ES2) { + SharedResource(final EGLGraphicsDevice dev, + final boolean isAvailableES1, final GLRendererQuirks rendererQuirksES1, final int ctpES1, + final boolean isAvailableES2, final GLRendererQuirks rendererQuirksES2, final int ctpES2, + final boolean isAvailableES3, final GLRendererQuirks rendererQuirksES3, final int ctpES3, + final boolean isAvailableGLn, final GLRendererQuirks rendererQuirksGLn, final int ctpGLn) { this.device = dev; - this.isAvailable = isAvailable; - - this.rendererQuirksGLn = rendererQuirksGLn; - this.ctpGLn = ctpGLn; + this.isAvailable = isAvailableES1 || isAvailableES2 || isAvailableES3 || isAvailableGLn; + this.isAvailableES1 = isAvailableES1; this.rendererQuirksES1 = rendererQuirksES1; this.ctpES1 = ctpES1; - - this.rendererQuirksES3ES2 = rendererQuirksES3ES2; - this.ctpES3ES2 = ctpES3ES2; + this.isAvailableES2 = isAvailableES2; + this.rendererQuirksES2 = rendererQuirksES2; + this.ctpES2 = ctpES2; + this.isAvailableES3 = isAvailableES3; + this.rendererQuirksES3 = rendererQuirksES3; + this.ctpES3 = ctpES3; + this.isAvailableGLn = isAvailableGLn; + this.rendererQuirksGLn = rendererQuirksGLn; + this.ctpGLn = ctpGLn; } @Override @@ -470,8 +482,10 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { @Override public GLRendererQuirks getRendererQuirks(final GLProfile glp) { if( null == glp ) { - if( null != rendererQuirksES3ES2 ) { - return rendererQuirksES3ES2; + if( null != rendererQuirksES3 ) { + return rendererQuirksES3; + } else if( null != rendererQuirksES2 ) { + return rendererQuirksES2; } else if( null != rendererQuirksES1 ) { return rendererQuirksES1; } else { @@ -481,33 +495,18 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { return rendererQuirksGLn; } else if( glp.isGLES1() ) { return rendererQuirksES1; - } else { - return rendererQuirksES3ES2; + } else if( glp.isGLES2() ) { + return rendererQuirksES2; + } else /* if( glp.isGLES3() ) */ { + return rendererQuirksES3; } } } - class SharedResourceImplementation implements SharedResourceRunner.Implementation { - @Override - public void clear() { - sharedMap.clear(); - } - @Override - public SharedResourceRunner.Resource mapPut(final AbstractGraphicsDevice device, final SharedResourceRunner.Resource resource) { - return sharedMap.put(device.getConnection(), resource); - } - @Override - public SharedResourceRunner.Resource mapGet(final AbstractGraphicsDevice device) { - return sharedMap.get(device.getConnection()); - } - @Override - public Collection<SharedResourceRunner.Resource> mapValues() { - return sharedMap.values(); - } - + class SharedResourceImplementation extends SharedResourceRunner.AImplementation { @Override public boolean isDeviceSupported(final AbstractGraphicsDevice device) { - return null != sharedMap; // null != eglES2DynamicLookupHelper || null != eglES1DynamicLookupHelper + return null != sharedResourceImplementation; // null != eglES2DynamicLookupHelper || null != eglES1DynamicLookupHelper || .. } @Override @@ -523,78 +522,128 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } private SharedResource createEGLSharedResourceImpl(final AbstractGraphicsDevice adevice) { - final GLRendererQuirks[] rendererQuirksES1 = new GLRendererQuirks[] { null }; - final GLRendererQuirks[] rendererQuirksES3ES2 = new GLRendererQuirks[] { null }; - final GLRendererQuirks[] rendererQuirksGLn = new GLRendererQuirks[] { null }; - final int[] ctpES1 = new int[] { EGLContext.CTX_PROFILE_ES }; - final int[] ctpES3ES2 = new int[] { EGLContext.CTX_PROFILE_ES }; - final int[] ctpGLn = new int[] { EGLContext.CTX_PROFILE_CORE }; - if ( DEBUG_SHAREDCTX ) { - System.err.println("EGLDrawableFactory.createShared(): device "+adevice); + System.err.println("EGLDrawableFactory.MapGLVersions: device "+adevice); } - boolean madeCurrentES1 = false; - boolean madeCurrentES2 = false; - boolean madeCurrentES3 = false; - boolean madeCurrentGLn = false; - - if( null != eglGLnDynamicLookupHelper ) { - // OpenGL 3.1 core -> GL3, will utilize normal desktop profile mapping - final int[] major = { 3 }; - final int[] minor = { 1 }; // FIXME: No minor version probing for ES currently! - madeCurrentGLn = mapAvailableEGLESConfig(adevice, major, minor, - ctpGLn, rendererQuirksGLn) && 0 != major[0]; + final boolean initDefaultDevice; + if( 0 == defaultDevice.getHandle() ) { // Note: GLProfile always triggers EGL device initialization first! + initDefaultDevice = true; + defaultDevice.open(); + defaultDeviceEGLFeatures = new EGLFeatures(defaultDevice); + if ( DEBUG_SHAREDCTX ) { + System.err.println("EGLDrawableFactory.MapGLVersions: defaultDevice "+defaultDevice); + System.err.println("EGLDrawableFactory.MapGLVersions: defaultDevice EGLFeatures "+defaultDeviceEGLFeatures); + } + // Probe for GLRendererQuirks.SingletonEGLDisplayOnly + final boolean singletonEGLDisplayOnlyVendor, singletonEGLDisplayOnlyProbe; + if( defaultDeviceEGLFeatures.vendor.contains("NVIDIA") ) { // OpenGL ES 3.1 NVIDIA 355.06 unstable + singletonEGLDisplayOnlyVendor=true; + singletonEGLDisplayOnlyProbe=false; + } else { + singletonEGLDisplayOnlyVendor=false; + final long secondEGLDisplay = EGL.eglGetDisplay(EGL.EGL_DEFAULT_DISPLAY); + singletonEGLDisplayOnlyProbe = EGL.EGL_NO_DISPLAY == secondEGLDisplay; + } + if( singletonEGLDisplayOnlyVendor || singletonEGLDisplayOnlyProbe ) { + final int quirk = GLRendererQuirks.SingletonEGLDisplayOnly; + GLRendererQuirks.addStickyDeviceQuirk(adevice, quirk); + EGLDisplayUtil.setSingletonEGLDisplayOnly(true); + if ( DEBUG_SHAREDCTX ) { + if( singletonEGLDisplayOnlyVendor ) { + System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: Vendor: "+defaultDeviceEGLFeatures); + } else if( singletonEGLDisplayOnlyProbe ) { + System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: Second eglGetDisplay(EGL_DEFAULT_DISPLAY) failed"); + } + } + } } else { - madeCurrentGLn = false; + initDefaultDevice = false; + if( null == defaultSharedResource ) { + throw new InternalError("XXX: defaultDevice "+defaultDevice+", adevice "+adevice); + } } - EGLContext.setAvailableGLVersionsSet(adevice, true); - if( null != eglES1DynamicLookupHelper ) { - final int[] major = { 1 }; - final int[] minor = { 0 }; - madeCurrentES1 = mapAvailableEGLESConfig(adevice, major, minor, - ctpES1, rendererQuirksES1) && 1 == major[0]; - } else { - madeCurrentES1 = false; - } - if( null != eglES2DynamicLookupHelper ) { - // ES3 Query - final int[] major = { 3 }; - final int[] minor = { 0 }; - madeCurrentES3 = mapAvailableEGLESConfig(adevice, major, minor, - ctpES3ES2, rendererQuirksES3ES2) && 3 == major[0]; - if( !madeCurrentES3 ) { - // ES2 Query, may result in ES3 - major[0] = 2; - if( mapAvailableEGLESConfig(adevice, major, minor, - ctpES3ES2, rendererQuirksES3ES2) ) - { - switch( major[0] ) { - case 2: madeCurrentES2 = true; break; - case 3: madeCurrentES3 = true; break; - default: throw new InternalError("XXXX Got "+major[0]); + final boolean[] mappedToDefaultDevice = { false }; + final GLRendererQuirks[] rendererQuirksES1 = new GLRendererQuirks[] { null }; + final GLRendererQuirks[] rendererQuirksES2 = new GLRendererQuirks[] { null }; + final GLRendererQuirks[] rendererQuirksES3 = new GLRendererQuirks[] { null }; + final GLRendererQuirks[] rendererQuirksGLn = new GLRendererQuirks[] { null }; + final int[] ctpES1 = new int[] { 0 }; + final int[] ctpES2 = new int[] { 0 }; + final int[] ctpES3 = new int[] { 0 }; + final int[] ctpGLn = new int[] { 0 }; + final boolean[] madeCurrentES1 = { false }; + final boolean[] madeCurrentES2 = { false }; + final boolean[] madeCurrentES3 = { false }; + final boolean[] madeCurrentGLn = { false }; + + final GLContextImpl.MappedGLVersionListener mvl = new GLContextImpl.MappedGLVersionListener() { + @Override + public void glVersionMapped(final MappedGLVersion e) { + if ( DEBUG_SHAREDCTX ) { + System.err.println("EGLDrawableFactory.MapGLVersions: Mapped: "+e); + } + if ( EGLContext.isGLES2ES3(e.ctxVersion.getMajor(), e.ctxOptions) ) { + if( e.ctxVersion.getMajor() == 3 ) { + madeCurrentES3[0] = true; + rendererQuirksES3[0] = e.quirks; + ctpES3[0] = e.ctxOptions; } + madeCurrentES2[0] = true; + rendererQuirksES2[0] = e.quirks; + ctpES2[0] = e.ctxOptions; + } else if ( EGLContext.isGLES1(e.ctxVersion.getMajor(), e.ctxOptions) ) { + madeCurrentES1[0] = true; + rendererQuirksES1[0] = e.quirks; + ctpES1[0] = e.ctxOptions; + } else if( EGLContext.isGLDesktop(e.ctxOptions) ) { + madeCurrentGLn[0] = true; + rendererQuirksGLn[0] = e.quirks; + ctpGLn[0] = e.ctxOptions; } } + }; + final SharedResource sr; + final EGLGraphicsDevice[] eglDevice = { null }; + final boolean mapSuccess; + EGLContext.setMappedGLVersionListener(mvl); + try { + // Query triggers profile mapping! + mapSuccess = mapAvailableEGLESConfig(adevice, mappedToDefaultDevice, eglDevice); + } finally { + EGLContext.setMappedGLVersionListener(null); } - if( hasX11 ) { - handleDontCloseX11DisplayQuirk(rendererQuirksES1[0]); - handleDontCloseX11DisplayQuirk(rendererQuirksES3ES2[0]); + if( mappedToDefaultDevice[0] ) { + EGLContext.remapAvailableGLVersions(defaultDevice, adevice); + sr = defaultSharedResource; + } else { + if( hasX11 ) { + handleDontCloseX11DisplayQuirk(rendererQuirksES1[0]); + handleDontCloseX11DisplayQuirk(rendererQuirksGLn[0]); + handleDontCloseX11DisplayQuirk(rendererQuirksES3[0]); + handleDontCloseX11DisplayQuirk(rendererQuirksES2[0]); + } + sr = new SharedResource(eglDevice[0], + madeCurrentES1[0], rendererQuirksES1[0], ctpES1[0], + madeCurrentES2[0], rendererQuirksES2[0], ctpES2[0], + madeCurrentES3[0], rendererQuirksES3[0], ctpES3[0], + madeCurrentGLn[0], rendererQuirksGLn[0], ctpGLn[0]); + if( initDefaultDevice ) { + defaultSharedResource = sr; + } } - final SharedResource sr = new SharedResource(defaultDevice, - madeCurrentGLn || madeCurrentES1 || madeCurrentES2 || madeCurrentES3, - rendererQuirksGLn[0], ctpGLn[0], - rendererQuirksES1[0], ctpES1[0], - rendererQuirksES3ES2[0], ctpES3ES2[0]); if ( DEBUG_SHAREDCTX ) { - System.err.println("EGLDrawableFactory.createShared: devices: queried nativeTK "+QUERY_EGL_ES_NATIVE_TK+", adevice " + adevice + ", defaultDevice " + defaultDevice); - System.err.println("EGLDrawableFactory.createShared: context GLn: " + madeCurrentGLn + ", quirks "+rendererQuirksGLn[0]); - System.err.println("EGLDrawableFactory.createShared: context ES1: " + madeCurrentES1 + ", quirks "+rendererQuirksES1[0]); - System.err.println("EGLDrawableFactory.createShared: context ES2: " + madeCurrentES2 + ", quirks "+rendererQuirksES3ES2[0]); - System.err.println("EGLDrawableFactory.createShared: context ES3: " + madeCurrentES3 + ", quirks "+rendererQuirksES3ES2[0]); + System.err.println("EGLDrawableFactory.MapGLVersions: mapSuccess "+mapSuccess+", mappedToDefaultDevice "+mappedToDefaultDevice[0]); + System.err.println("EGLDrawableFactory.MapGLVersions: defDevice : " + defaultDevice); + System.err.println("EGLDrawableFactory.MapGLVersions: adevice : " + adevice); + System.err.println("EGLDrawableFactory.MapGLVersions: eglDevice : " + sr.device); + System.err.println("EGLDrawableFactory.MapGLVersions: context ES1: " + sr.isAvailableES1 + ", quirks "+sr.rendererQuirksES1); + System.err.println("EGLDrawableFactory.MapGLVersions: context ES2: " + sr.isAvailableES2 + ", quirks "+sr.rendererQuirksES2); + System.err.println("EGLDrawableFactory.MapGLVersions: context ES3: " + sr.isAvailableES3 + ", quirks "+sr.rendererQuirksES3); + System.err.println("EGLDrawableFactory.MapGLVersions: context GLn: " + sr.isAvailableGLn + ", quirks "+sr.rendererQuirksGLn); dumpMap(); } return sr; @@ -607,200 +656,218 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } private boolean mapAvailableEGLESConfig(final AbstractGraphicsDevice adevice, - final int[] majorVersion, final int[] minorVersion, - final int[] ctxProfile, final GLRendererQuirks[] rendererQuirks) { - final String profileString = EGLContext.getGLProfile(majorVersion[0], minorVersion[0], ctxProfile[0]); + final boolean[] mapsADeviceToDefaultDevice, + final EGLGraphicsDevice[] resEGLDevice) { + final int majorVersion = 2; + final int minorVersion = 0; + final int ctxProfile = EGLContext.CTX_PROFILE_ES; + final String profileString = EGLContext.getGLProfile(majorVersion, minorVersion, ctxProfile); if ( !GLProfile.isAvailable(adevice, profileString) ) { if ( DEBUG_SHAREDCTX ) { - System.err.println("EGLDrawableFactory.mapAvailableEGLESConfig: "+profileString+" n/a on "+adevice); + System.err.println("EGLDrawableFactory.MapGLVersions: "+profileString+" n/a on "+adevice); } return false; } final GLProfile glp = GLProfile.get(adevice, profileString) ; final GLDrawableFactoryImpl desktopFactory = (GLDrawableFactoryImpl) GLDrawableFactory.getDesktopFactory(); - final boolean initDefaultDevice = 0 == defaultDevice.getHandle(); // Note: GLProfile always triggers EGL device initialization first! - final boolean mapsADeviceToDefaultDevice = !QUERY_EGL_ES_NATIVE_TK || initDefaultDevice || - null == desktopFactory; - // FIXME || adevice instanceof EGLGraphicsDevice ; + + final GLCapabilities reqCapsAny = new GLCapabilities(glp); + reqCapsAny.setRedBits(5); reqCapsAny.setGreenBits(5); reqCapsAny.setBlueBits(5); reqCapsAny.setAlphaBits(0); + reqCapsAny.setDoubleBuffered(false); + final GLCapabilitiesImmutable reqCapsPBuffer = GLGraphicsConfigurationUtil.fixGLPBufferGLCapabilities(reqCapsAny); + final List<GLCapabilitiesImmutable> defaultDevicePBufferCapsL = getAvailableEGLConfigs(defaultDevice, reqCapsPBuffer); + final boolean defaultDeviceHasPBuffer = defaultDevicePBufferCapsL.size() > 0; + + final boolean useDefaultDevice = adevice == defaultDevice; + + mapsADeviceToDefaultDevice[0] = !useDefaultDevice && + null != defaultSharedResource && defaultSharedResource.isAvailable && + defaultConnection.equals(adevice.getConnection()); + if ( DEBUG_SHAREDCTX ) { - System.err.println("EGLDrawableFactory.mapAvailableEGLESConfig: "+profileString+" ( "+majorVersion[0]+" ), "+ - "mapsADeviceToDefaultDevice "+mapsADeviceToDefaultDevice+ - " (QUERY_EGL_ES_NATIVE_TK "+QUERY_EGL_ES_NATIVE_TK+", initDefaultDevice "+initDefaultDevice+", hasDesktopFactory "+(null != desktopFactory)+ + System.err.println("EGLDrawableFactory.MapGLVersions: "+profileString+" ( "+majorVersion+" ), "+ + "mapsADeviceToDefaultDevice "+mapsADeviceToDefaultDevice[0]+ + " (useDefaultDevice "+useDefaultDevice+", defaultDeviceHasPBuffer "+defaultDeviceHasPBuffer+", hasDesktopFactory "+(null != desktopFactory)+ ", isEGLGraphicsDevice "+(adevice instanceof EGLGraphicsDevice)+")"); } - boolean hasPBuffer; - EGLGraphicsDevice eglDevice = null; - EGLFeatures eglFeatures = null; - NativeSurface surface = null; - ProxySurface upstreamSurface = null; // X11, GLX, .. - ProxySurface downstreamSurface = null; // EGL + if( mapsADeviceToDefaultDevice[0] ) { + return true; + } + + final boolean defaultNoSurfacelessCtx = GLRendererQuirks.existStickyDeviceQuirk(defaultDevice, GLRendererQuirks.NoSurfacelessCtx); boolean success = false; - try { - final GLCapabilities reqCapsAny = new GLCapabilities(glp); - reqCapsAny.setRedBits(5); reqCapsAny.setGreenBits(5); reqCapsAny.setBlueBits(5); reqCapsAny.setAlphaBits(0); - reqCapsAny.setDoubleBuffered(false); - - if( mapsADeviceToDefaultDevice ) { - // In this branch, any non EGL device is mapped to EGL default shared resources (default behavior). - // Only one default shared resource instance is ever be created. - if( initDefaultDevice ) { - defaultDevice.open(); - defaultDeviceEGLFeatures = new EGLFeatures(defaultDevice); - - // Probe for GLRendererQuirks.SingletonEGLDisplayOnly - final long secondEGLDisplay = EGL.eglGetDisplay(EGL.EGL_DEFAULT_DISPLAY); - if ( EGL.EGL_NO_DISPLAY == secondEGLDisplay ) { - final int quirk = GLRendererQuirks.SingletonEGLDisplayOnly; - GLRendererQuirks.addStickyDeviceQuirk(adevice, quirk); - EGLDisplayUtil.setSingletonEGLDisplayOnly(true); + final boolean hasKHRSurfacelessTried; + if( defaultDeviceEGLFeatures.hasKHRSurfaceless && !defaultNoSurfacelessCtx ) { + hasKHRSurfacelessTried = true; + final AbstractGraphicsDevice zdevice = useDefaultDevice ? defaultDevice : adevice; // reuse + final EGLSurface zeroSurface = createSurfacelessImpl(zdevice, false, reqCapsAny, reqCapsAny, null, 64, 64); + resEGLDevice[0] = (EGLGraphicsDevice) zeroSurface.getGraphicsConfiguration().getScreen().getDevice(); + if ( DEBUG_SHAREDCTX ) { + System.err.println("EGLDrawableFactory-MapGLVersions.0: "+resEGLDevice[0]); + } + EGLDrawable zeroDrawable = null; + EGLContext context = null; + boolean hasException = false; + try { + zeroDrawable = (EGLDrawable) createOnscreenDrawableImpl ( zeroSurface ); + zeroDrawable.setRealized(true); + + context = (EGLContext) zeroDrawable.createContext(null); + if (null == context) { + throw new GLException("Couldn't create shared context for drawable: "+zeroDrawable); + } + // Triggers initial mapping, if not done yet + if( GLContext.CONTEXT_NOT_CURRENT != context.makeCurrent() ) { // could cause exception + // context.isCurrent() ! + final GL gl = context.getGL(); + final String glVersionString = gl.glGetString(GL.GL_VERSION); + if(null != glVersionString) { + success = true; + } else { + setNoSurfacelessCtxQuirk(context); + } + } else if ( DEBUG_SHAREDCTX ) { + System.err.println("EGLDrawableFactory-MapGLVersions.0: NOT_CURRENT: "+resEGLDevice[0]+", "+context); + } + } catch (final Throwable t) { + hasException = true; + if ( DEBUG_SHAREDCTX ) { + System.err.println("EGLDrawableFactory-MapGLVersions.0: INFO: context create/makeCurrent failed"); + t.printStackTrace(); + } + } finally { + if( null != context ) { + try { + context.destroy(); + } catch (final GLException gle) { if ( DEBUG_SHAREDCTX ) { - System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: Second eglGetDisplay(EGL_DEFAULT_DISPLAY) failed"); + System.err.println("EGLDrawableFactory-MapGLVersions.0: INFO: destroy caught exception:"); + gle.printStackTrace(); } } } - eglDevice = defaultDevice; // reuse + if( null != zeroDrawable ) { + zeroDrawable.setRealized(false); + } + if( null != zeroSurface ) { + zeroSurface.destroyNotify(); + } + if( success || hasException ) { // cont. using device if !success + if( defaultDevice != resEGLDevice[0] ) { // don't close default device + if(null != resEGLDevice[0]) { + resEGLDevice[0].close(); + } + } + } + } + if( success ) { + return true; + } + } else { // hasKHRSurfaceless + hasKHRSurfacelessTried = false; + } + EGLFeatures eglFeatures = null; + NativeSurface surface = null; + EGLDrawable drawable = null; + GLDrawable zeroDrawable = null; + EGLContext context = null; + ProxySurface upstreamSurface = null; // X11, GLX, .. + ProxySurface downstreamSurface = null; // EGL + try { + if( useDefaultDevice && defaultDeviceHasPBuffer ) { + // Map any non EGL device to EGL default shared resources (default behavior), using a pbuffer surface + resEGLDevice[0] = defaultDevice; // reuse eglFeatures = defaultDeviceEGLFeatures; if ( DEBUG_SHAREDCTX ) { - System.err.println("EGLDrawableFactory.mapAvailableEGLESConfig.0: "+eglFeatures); + System.err.println("EGLDrawableFactory-MapGLVersions.1: "+resEGLDevice[0]); + System.err.println("EGLDrawableFactory-MapGLVersions.1: "+eglFeatures); } - if( !glp.isGLES() && !eglFeatures.hasGLAPI ) { - if ( DEBUG_SHAREDCTX ) { - System.err.println("EGLDrawableFactory.mapAvailableEGLESConfig() OpenGL API not supported (1)"); - } - } else { - final GLCapabilitiesImmutable reqCapsPBuffer = GLGraphicsConfigurationUtil.fixGLPBufferGLCapabilities(reqCapsAny); - final List<GLCapabilitiesImmutable> availablePBufferCapsL = getAvailableEGLConfigs(eglDevice, reqCapsPBuffer); - hasPBuffer = availablePBufferCapsL.size() > 0; - - // attempt to created the default shared resources .. - if( hasPBuffer ) { - // 2nd case create defaultDevice shared resource using pbuffer surface - downstreamSurface = createDummySurfaceImpl(eglDevice, false, reqCapsPBuffer, reqCapsPBuffer, null, 64, 64); // egl pbuffer offscreen - if( null != downstreamSurface ) { - downstreamSurface.createNotify(); - surface = downstreamSurface; - } - } else { - // 3rd case fake creation of defaultDevice shared resource, no pbuffer available - final List<GLCapabilitiesImmutable> capsAnyL = getAvailableEGLConfigs(eglDevice, reqCapsAny); - if(capsAnyL.size() > 0) { - final GLCapabilitiesImmutable chosenCaps = capsAnyL.get(0); - EGLContext.mapStaticGLESVersion(eglDevice, chosenCaps); - success = true; - } - if ( DEBUG_SHAREDCTX ) { - System.err.println("EGLDrawableFactory.mapAvailableEGLESConfig() no pbuffer config available, detected !pbuffer config: "+success); - EGLGraphicsConfigurationFactory.printCaps("!PBufferCaps", capsAnyL, System.err); - } - } + downstreamSurface = createDummySurfaceImpl(resEGLDevice[0], false, reqCapsPBuffer, reqCapsPBuffer, null, 64, 64); + if( null != downstreamSurface ) { + downstreamSurface.createNotify(); + surface = downstreamSurface; } - } else { - // 4th case always creates a true mapping of given device to EGL + } else if( adevice != defaultDevice ) { + // Create a true mapping of given device to EGL upstreamSurface = desktopFactory.createDummySurface(adevice, reqCapsAny, null, 64, 64); // X11, WGL, .. dummy window if(null != upstreamSurface) { upstreamSurface.createNotify(); - eglDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(upstreamSurface); - eglDevice.open(); - eglFeatures = new EGLFeatures(eglDevice); + resEGLDevice[0] = EGLDisplayUtil.eglCreateEGLGraphicsDevice(upstreamSurface); + resEGLDevice[0].open(); + eglFeatures = new EGLFeatures(resEGLDevice[0]); if ( DEBUG_SHAREDCTX ) { - System.err.println("EGLDrawableFactory.mapAvailableEGLESConfig.1: "+eglFeatures); - } - if( !glp.isGLES() && !eglFeatures.hasGLAPI ) { - if ( DEBUG_SHAREDCTX ) { - System.err.println("EGLDrawableFactory.mapAvailableEGLESConfig() OpenGL API not supported (2)"); - } - // disposed at finalized: eglDevice, upstreamSurface - } else { - hasPBuffer = true; - surface = upstreamSurface; + System.err.println("EGLDrawableFactory-MapGLVersions.2: "+resEGLDevice[0]); + System.err.println("EGLDrawableFactory-MapGLVersions.2: "+eglFeatures); } + surface = upstreamSurface; } } if(null != surface) { - EGLDrawable drawable = null; - GLDrawable zeroDrawable = null; - EGLContext context = null; - try { - drawable = (EGLDrawable) createOnscreenDrawableImpl ( surface ); - drawable.setRealized(true); - - context = (EGLContext) drawable.createContext(null); - if (null == context) { - throw new GLException("Couldn't create shared context for drawable: "+drawable); - } + drawable = (EGLDrawable) createOnscreenDrawableImpl ( surface ); + drawable.setRealized(true); - if( GLContext.CONTEXT_NOT_CURRENT != context.makeCurrent() ) { // could cause exception - // context.isCurrent() ! - final String glVersionString = context.getGL().glGetString(GL.GL_VERSION); - if(null != glVersionString) { - context.mapCurrentAvailableGLESVersion(eglDevice); - if(eglDevice != adevice) { - context.mapCurrentAvailableGLESVersion(adevice); - } + context = (EGLContext) drawable.createContext(null); + if (null == context) { + throw new GLException("Couldn't create shared context for drawable: "+drawable); + } - if( eglFeatures.hasKHRSurfaceless && - ( context.isGLES() || context.getGLVersionNumber().compareTo(GLContext.Version3_0) >= 0 ) - ) - { - if( probeSurfacelessCtx(context, false /* restoreDrawable */) ) { - zeroDrawable = context.getGLDrawable(); - } - } else { - setNoSurfacelessCtxQuirk(context); + // Triggers initial mapping, if not done yet + if( GLContext.CONTEXT_NOT_CURRENT != context.makeCurrent() ) { // could cause exception + // context.isCurrent() ! + final GL gl = context.getGL(); + final String glVersionString = gl.glGetString(GL.GL_VERSION); + if(null != glVersionString) { + success = true; + if( !hasKHRSurfacelessTried && eglFeatures.hasKHRSurfaceless && + ( context.isGLES() || context.getGLVersionNumber().compareTo(GLContext.Version3_0) >= 0 ) + ) + { + if( probeSurfacelessCtx(context, false /* restoreDrawable */) ) { + zeroDrawable = context.getGLDrawable(); } - rendererQuirks[0] = context.getRendererQuirks(); - ctxProfile[0] = context.getContextOptions(); - majorVersion[0] = context.getGLVersionNumber().getMajor(); - minorVersion[0] = context.getGLVersionNumber().getMinor(); - success = true; } else { - // Oops .. something is wrong - if ( DEBUG_SHAREDCTX ) { - System.err.println("EGLDrawableFactory.mapAvailableEGLESConfig: "+eglDevice+", "+context.getGLVersion()+" - VERSION is null, dropping availability!"); - } + setNoSurfacelessCtxQuirk(context); } + } else if ( DEBUG_SHAREDCTX ) { + System.err.println("EGLDrawableFactory-MapGLVersions.12: NULL VERSION: "+resEGLDevice[0]+", "+context.getGLVersion()); } - } catch (final Throwable t) { - if ( DEBUG_SHAREDCTX ) { - System.err.println("EGLDrawableFactory.mapAvailableEGLESConfig: INFO: context create/makeCurrent failed"); - t.printStackTrace(); - } - } finally { - if( null != context ) { - try { - context.destroy(); - } catch (final GLException gle) { - if ( DEBUG_SHAREDCTX ) { - System.err.println("EGLDrawableFactory.mapAvailableEGLESConfig: INFO: destroy caught exception:"); - gle.printStackTrace(); - } - } - } - if( null != zeroDrawable ) { - zeroDrawable.setRealized(false); - } - if( null != drawable ) { - drawable.setRealized(false); - } + } else if ( DEBUG_SHAREDCTX ) { + System.err.println("EGLDrawableFactory-MapGLVersions.12: NOT_CURRENT: "+resEGLDevice[0]+", "+context); } } } catch (final Throwable t) { if ( DEBUG_SHAREDCTX ) { - System.err.println("Caught exception on thread "+getThreadName()); + System.err.println("EGLDrawableFactory-MapGLVersions.12: INFO: context create/makeCurrent failed"); t.printStackTrace(); } success = false; } finally { - if(null != downstreamSurface) { + if( null != context ) { + try { + context.destroy(); + } catch (final GLException gle) { + if ( DEBUG_SHAREDCTX ) { + System.err.println("EGLDrawableFactory-MapGLVersions.12: INFO: destroy caught exception:"); + gle.printStackTrace(); + } + } + } + if( null != zeroDrawable ) { + zeroDrawable.setRealized(false); + } + if( null != drawable ) { + drawable.setRealized(false); + } + if( null != downstreamSurface ) { downstreamSurface.destroyNotify(); } - if( defaultDevice != eglDevice ) { // don't close default device - if(null != eglDevice) { - eglDevice.close(); + if( defaultDevice != resEGLDevice[0] ) { // don't close default device + if(null != resEGLDevice[0]) { + resEGLDevice[0].close(); } } if(null != upstreamSurface) { @@ -831,8 +898,44 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { public final boolean hasDefaultDeviceKHRCreateContext() { return defaultDeviceEGLFeatures.hasKHRCreateContext; } - public final boolean hasOpenGLAPISupport() { - return defaultDeviceEGLFeatures.hasGLAPI; + /** + * {@inheritDoc} + * <p> + * This factory may support native desktop OpenGL if {@link EGL#EGL_CLIENT_APIS} contains {@code OpenGL} + * <i>and</i> if {@code EGL_KHR_create_context} extension is supported. + * </p> + */ + @Override + public final boolean hasOpenGLDesktopSupport() { + /** + * It has been experienced w/ Mesa 10.3.2 (EGL 1.4/Gallium) + * that even though initial OpenGL context can be created w/o 'EGL_KHR_create_context', + * switching the API via 'eglBindAPI(EGL_OpenGL_API)' the latter 'eglCreateContext(..)' fails w/ EGL_BAD_ACCESS. + * Hence we require both: OpenGL API support _and_ 'EGL_KHR_create_context'. + */ + return null != eglGLnDynamicLookupHelper && + defaultDeviceEGLFeatures.hasGLAPI && defaultDeviceEGLFeatures.hasKHRCreateContext; + } + + /** + * {@inheritDoc} + * <p> + * This factory always supports native GLES profiles. + * </p> + */ + @Override + public final boolean hasOpenGLESSupport() { return true; } + + /** + * {@inheritDoc} + * <p> + * Return true if {@code EGL_KHR_create_context} extension is supported, + * see {@link #hasDefaultDeviceKHRCreateContext()}. + * </p> + */ + @Override + public final boolean hasMajorMinorCreateContextARB() { + return hasDefaultDeviceKHRCreateContext(); } @Override @@ -843,7 +946,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { @Override public final boolean getIsDeviceCompatible(final AbstractGraphicsDevice device) { // via mappings (X11/WGL/.. -> EGL) we shall be able to handle all types. - return null != sharedMap ; // null!=eglES2DynamicLookupHelper || null!=eglES1DynamicLookupHelper; + return null != sharedResourceImplementation ; // null!=eglES2DynamicLookupHelper || null!=eglES1DynamicLookupHelper || ..; } private static List<GLCapabilitiesImmutable> getAvailableEGLConfigs(final EGLGraphicsDevice eglDisplay, final GLCapabilitiesImmutable caps) { @@ -885,24 +988,28 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } @Override - public GLDynamicLookupHelper getGLDynamicLookupHelper(final String esProfile) { + public final GLDynamicLookupHelper getGLDynamicLookupHelper(final int majorVersion, final int contextOptions) { final GLDynamicLookupHelper res; - if ( GLProfile.GLES2 == esProfile || GLProfile.GLES3 == esProfile ) { + if ( EGLContext.isGLES2ES3(majorVersion, contextOptions) ) { res = eglES2DynamicLookupHelper; - } else if ( GLProfile.GLES1 == esProfile ) { + } else if ( EGLContext.isGLES1(majorVersion, contextOptions) ) { res = eglES1DynamicLookupHelper; - } else { + } else if( EGLContext.isGLDesktop(contextOptions) ) { res = eglGLnDynamicLookupHelper; + } else { + throw new IllegalArgumentException("neither GLES1, GLES2, GLES3 nor desktop GL has been specified: "+majorVersion+" ("+EGLContext.getGLProfile(new StringBuilder(), contextOptions).toString()); } - if( null == res ) { - throw new GLException("No lookup for esProfile "+esProfile); + if( DEBUG_SHAREDCTX ) { + if( null == res ) { + System.err.println("EGLDrawableFactory.getGLDynamicLookupHelper: NULL for profile "+majorVersion+" ("+EGLContext.getGLProfile(new StringBuilder(), contextOptions).toString()); + } } return res; } @Override protected List<GLCapabilitiesImmutable> getAvailableCapabilitiesImpl(final AbstractGraphicsDevice device) { - if(null == sharedMap) { // null == eglES1DynamicLookupHelper && null == eglES2DynamicLookupHelper + if(null == sharedResourceImplementation) { // null == eglES1DynamicLookupHelper && null == eglES2DynamicLookupHelper || .. return new ArrayList<GLCapabilitiesImmutable>(); // null } return EGLGraphicsConfigurationFactory.getAvailableCapabilities(this, device); @@ -942,9 +1049,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { final GLCapabilitiesChooser chooser) { final EGLGraphicsDevice device; if( createNewDevice || ! (deviceReq instanceof EGLGraphicsDevice) ) { - final long nativeDisplayID = ( deviceReq instanceof EGLGraphicsDevice) ? - ( (EGLGraphicsDevice) deviceReq ).getNativeDisplayID() : deviceReq.getHandle() ; - device = EGLDisplayUtil.eglCreateEGLGraphicsDevice(nativeDisplayID, deviceReq.getConnection(), deviceReq.getUnitID()); + device = EGLDisplayUtil.eglCreateEGLGraphicsDevice(deviceReq); device.open(); ownDevice[0] = true; } else { @@ -960,7 +1065,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } @Override - protected final ProxySurface createMutableSurfaceImpl(final AbstractGraphicsDevice deviceReq, final boolean createNewDevice, + protected final EGLSurface createMutableSurfaceImpl(final AbstractGraphicsDevice deviceReq, final boolean createNewDevice, final GLCapabilitiesImmutable capsChosen, final GLCapabilitiesImmutable capsRequested, final GLCapabilitiesChooser chooser, final UpstreamSurfaceHook upstreamHook) { final boolean[] ownDevice = { false }; @@ -969,14 +1074,14 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } @Override - public final ProxySurface createDummySurfaceImpl(final AbstractGraphicsDevice deviceReq, final boolean createNewDevice, + public final EGLSurface createDummySurfaceImpl(final AbstractGraphicsDevice deviceReq, final boolean createNewDevice, GLCapabilitiesImmutable chosenCaps, final GLCapabilitiesImmutable requestedCaps, final GLCapabilitiesChooser chooser, final int width, final int height) { chosenCaps = GLGraphicsConfigurationUtil.fixGLPBufferGLCapabilities(chosenCaps); // complete validation in EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(..) above return createMutableSurfaceImpl(deviceReq, createNewDevice, chosenCaps, requestedCaps, chooser, new EGLDummyUpstreamSurfaceHook(width, height)); } @Override - public final ProxySurface createSurfacelessImpl(final AbstractGraphicsDevice deviceReq, final boolean createNewDevice, + public final EGLSurface createSurfacelessImpl(final AbstractGraphicsDevice deviceReq, final boolean createNewDevice, GLCapabilitiesImmutable chosenCaps, final GLCapabilitiesImmutable requestedCaps, final GLCapabilitiesChooser chooser, final int width, final int height) { chosenCaps = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(chosenCaps); final boolean[] ownDevice = { false }; @@ -1019,11 +1124,10 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } @Override - protected ProxySurface createProxySurfaceImpl(final AbstractGraphicsDevice deviceReq, final int screenIdx, final long windowHandle, + protected EGLSurface createProxySurfaceImpl(final AbstractGraphicsDevice deviceReq, final int screenIdx, final long windowHandle, final GLCapabilitiesImmutable capsRequested, final GLCapabilitiesChooser chooser, final UpstreamSurfaceHook upstream) { - final EGLGraphicsDevice eglDeviceReq = (EGLGraphicsDevice) deviceReq; - final EGLGraphicsDevice device = EGLDisplayUtil.eglCreateEGLGraphicsDevice(eglDeviceReq.getNativeDisplayID(), deviceReq.getConnection(), deviceReq.getUnitID()); + final EGLGraphicsDevice device = EGLDisplayUtil.eglCreateEGLGraphicsDevice(deviceReq); device.open(); final DefaultGraphicsScreen screen = new DefaultGraphicsScreen(device, screenIdx); final EGLGraphicsConfiguration cfg = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsRequested, capsRequested, chooser, screen, VisualIDHolder.VID_UNDEFINED, false); diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDummyUpstreamSurfaceHook.java b/src/jogl/classes/jogamp/opengl/egl/EGLDummyUpstreamSurfaceHook.java index 6c11b3bdc..890dab8f7 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDummyUpstreamSurfaceHook.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDummyUpstreamSurfaceHook.java @@ -1,5 +1,6 @@ package jogamp.opengl.egl; +import com.jogamp.common.ExceptionUtils; import com.jogamp.nativewindow.NativeSurface; import com.jogamp.nativewindow.ProxySurface; import com.jogamp.nativewindow.UpstreamSurfaceHook; @@ -8,6 +9,8 @@ import com.jogamp.nativewindow.UpstreamSurfaceHookMutableSize; import com.jogamp.nativewindow.egl.EGLGraphicsDevice; import com.jogamp.opengl.egl.EGL; +import jogamp.nativewindow.ProxySurfaceImpl; + /** Uses a PBuffer offscreen surface */ public class EGLDummyUpstreamSurfaceHook extends UpstreamSurfaceHookMutableSize { /** @@ -50,6 +53,11 @@ public class EGLDummyUpstreamSurfaceHook extends UpstreamSurfaceHookMutableSize } eglDevice.lock(); try { + if( EGLDrawable.DEBUG ) { + System.err.println(EGLSurface.getThreadName()+": EGLDummyUpstreamSurfaceHook: EGL.eglDestroySurface: 0x"+Long.toHexString(s.getSurfaceHandle())); + ProxySurfaceImpl.dumpHierarchy(System.err, s); + ExceptionUtils.dumpStack(System.err); + } EGL.eglDestroySurface(eglDevice.getHandle(), s.getSurfaceHandle()); s.setSurfaceHandle(EGL.EGL_NO_SURFACE); s.clearUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java index d37efc455..038194d58 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java @@ -31,6 +31,8 @@ package jogamp.opengl.egl; import java.util.ArrayList; import java.util.List; +import jogamp.nativewindow.BcmVCArtifacts; + /** * <p> * Covering ES3 and ES2. @@ -41,12 +43,20 @@ public final class EGLES2DynamicLibraryBundleInfo extends EGLDynamicLibraryBundl super(); } + @Override public final List<List<String>> getToolLibNames() { + final List<List<String>> libsList = new ArrayList<List<String>>(); { final List<String> libsGL = new ArrayList<String>(); + /** + * Prefer libGLESv2.so over libGLESv2.so.2 for proprietary + * Broadcom graphics when the VC4 DRM Xorg driver isn't present + */ + final boolean bcm_vc_iv_quirk = BcmVCArtifacts.guessVCIVUsed(); + // ES3: This is the default lib name, according to the spec libsGL.add("libGLESv3.so.3"); @@ -63,12 +73,18 @@ public final class EGLES2DynamicLibraryBundleInfo extends EGLDynamicLibraryBundl libsGL.add("libGLES30"); // ES2: This is the default lib name, according to the spec - libsGL.add("libGLESv2.so.2"); + if (!bcm_vc_iv_quirk) { + libsGL.add("libGLESv2.so.2"); + } // ES2: Try these as well, if spec fails libsGL.add("libGLESv2.so"); libsGL.add("GLESv2"); + if (bcm_vc_iv_quirk) { + libsGL.add("libGLESv2.so.2"); + } + // ES2: Alternative names libsGL.add("GLES20"); libsGL.add("GLESv2_CM"); diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java index d10263f22..5505fed52 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java @@ -242,7 +242,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact } ownEGLDisplay = false; } else { - eglDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(absDevice.getHandle(), absDevice.getConnection(), absDevice.getUnitID()); + eglDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(absDevice); eglDevice.open(); ownEGLDisplay = true; } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLSurface.java b/src/jogl/classes/jogamp/opengl/egl/EGLSurface.java index e4e692fb2..8956bcbd9 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLSurface.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLSurface.java @@ -35,7 +35,7 @@ import com.jogamp.nativewindow.ProxySurface; import com.jogamp.nativewindow.UpstreamSurfaceHook; import com.jogamp.opengl.GLCapabilitiesImmutable; import com.jogamp.opengl.GLException; - +import com.jogamp.common.ExceptionUtils; import com.jogamp.common.nio.Buffers; import com.jogamp.nativewindow.GenericUpstreamSurfacelessHook; import com.jogamp.opengl.egl.EGL; @@ -101,16 +101,22 @@ public class EGLSurface extends WrappedSurface { final boolean isPBuffer = ((GLCapabilitiesImmutable) config.getChosenCapabilities()).isPBuffer(); long eglSurface = createEGLSurfaceHandle(isPBuffer, true /* useSurfaceHandle */, config, nativeSurface); + if( DEBUG ) { + System.err.println(getThreadName() + ": EGLSurface: EGL.eglCreateSurface.0: 0x"+Long.toHexString(eglSurface)); + ProxySurfaceImpl.dumpHierarchy(System.err, this); + } + if ( EGL.EGL_NO_SURFACE == eglSurface ) { final int eglError0 = EGL.eglGetError(); if( EGL.EGL_BAD_NATIVE_WINDOW == eglError0 && !isPBuffer ) { // Try window handle if available and differs (Windows HDC / HWND). // ANGLE impl. required HWND on Windows. if( hasUniqueNativeWindowHandle(nativeSurface) ) { - if(DEBUG) { + eglSurface = createEGLSurfaceHandle(isPBuffer, false /* useSurfaceHandle */, config, nativeSurface); + if( DEBUG ) { System.err.println(getThreadName() + ": Info: Creation of window surface w/ surface handle failed: "+config+", error "+GLDrawableImpl.toHexString(eglError0)+", retry w/ windowHandle"); + System.err.println(getThreadName() + ": EGLSurface: EGL.eglCreateSurface.1: 0x"+Long.toHexString(eglSurface)); } - eglSurface = createEGLSurfaceHandle(isPBuffer, false /* useSurfaceHandle */, config, nativeSurface); if (EGL.EGL_NO_SURFACE == eglSurface) { throw new GLException("Creation of window surface w/ window handle failed: "+config+", "+this+", error "+GLDrawableImpl.toHexString(EGL.eglGetError())); } |