diff options
author | Sven Gothel <[email protected]> | 2012-07-06 01:20:48 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-07-06 01:20:48 +0200 |
commit | e85e3ec2a73ac35aaf911f0b1e34b234be1622da (patch) | |
tree | 4b6f6b01581da278e8efd19ea07c833484a1cb57 /src/jogl/classes/javax/media/opengl/GLProfile.java | |
parent | b2e6ceed92da95130d0f37234c43712c7f9a98db (diff) |
Enhance Bootsrapping of JOGL around 37% - 40% (1st start in new JVM) - GLProfile and GLContext*
GLProfile: Enhance bootsrapping performance of loading GL*Impl class
- Offthread classloading of all GL*Impl via reflection at startup
reduces startup time here around 12% (800ms down to 700ms).
GLContext*: Enhance bootsrapping performance of querying available GL profiles
- Add PROFILE_ALIASING mode, defaults to true - can be disabled w/ property 'jogl.debug.GLContext.NoProfileAliasing'
- PROFILE_ALIASING:
If true (default), bootstrapping the available GL profiles
will use the highest compatible GL context for each profile,
hence skipping querying lower profiles if a compatible higher one is found.
Linux x86_64 - Nvidia: 28%, 700ms down to 500ms
Linux x86_64 - AMD : 40%, 1500ms down to 900ms
- GL*Impl:
- make fields final: glProfile, _context, buffer*Tracker and glStateTracker
- allow null _context/glProfile in initialization (bootstrapping)
- JoglVersion.getDefaultOpenGLInfo(..)
- add arg: 'boolean withCapabilitiesInfo', allowing to suppres the list of caps
Diffstat (limited to 'src/jogl/classes/javax/media/opengl/GLProfile.java')
-rw-r--r-- | src/jogl/classes/javax/media/opengl/GLProfile.java | 81 |
1 files changed, 42 insertions, 39 deletions
diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java index cc4f6c517..a7200b560 100644 --- a/src/jogl/classes/javax/media/opengl/GLProfile.java +++ b/src/jogl/classes/javax/media/opengl/GLProfile.java @@ -39,6 +39,7 @@ package javax.media.opengl; import jogamp.nativewindow.NWJNILibLoader; import jogamp.opengl.Debug; +import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLDrawableFactoryImpl; import jogamp.opengl.DesktopGLDynamicLookupHelper; @@ -131,6 +132,23 @@ public class GLProfile { public Object run() { Platform.initSingleton(); + // Performance hack to trigger classloading of the GL classes impl, which makes up to 12%, 800ms down to 700ms + new Thread(new Runnable() { + public void run() { + final ClassLoader cl = GLProfile.class.getClassLoader(); + try { + ReflectionUtil.createInstance(getGLImplBaseClassName(GL4bc)+"Impl", new Class[] { GLProfile.class, GLContextImpl.class }, new Object[] { null, null }, cl); + } catch (Throwable t) {} + try { + ReflectionUtil.createInstance(getGLImplBaseClassName(GLES2)+"Impl", new Class[] { GLProfile.class, GLContextImpl.class }, new Object[] { null, null }, cl); + } catch (Throwable t) {} + try { + ReflectionUtil.createInstance(getGLImplBaseClassName(GLES1)+"Impl", new Class[] { GLProfile.class, GLContextImpl.class }, new Object[] { null, null }, cl); + } catch (Throwable t) {} + } + }, "GLProfile-GL_Bootstrapping").start(); + + if(TempJarCache.isInitialized()) { final ClassLoader cl = GLProfile.class.getClassLoader(); // either: [jogl-all.jar, jogl-all-noawt.jar, jogl-all-mobile.jar] -> jogl-all-natives-<os.and.arch>.jar @@ -914,6 +932,22 @@ public class GLProfile { return getGLImplBaseClassName(getImplName()); } + private static final String getGLImplBaseClassName(String profileImpl) { + if( GLES2 == profileImpl ) { + return "jogamp.opengl.es2.GLES2"; + } else if( GLES1 == profileImpl ) { + return "jogamp.opengl.es1.GLES1"; + } else if ( GL4bc == profileImpl || + GL4 == profileImpl || + GL3bc == profileImpl || + GL3 == profileImpl || + GL2 == profileImpl ) { + return "jogamp.opengl.gl4.GL4bc"; + } else { + throw new GLException("unsupported profile \"" + profileImpl + "\""); + } + } + /** * @param o GLProfile object to compare with * @return true if given Object is a GLProfile and @@ -922,8 +956,8 @@ public class GLProfile { public final boolean equals(Object o) { if(this==o) { return true; } if(o instanceof GLProfile) { - GLProfile glp = (GLProfile)o; - return getName().equals(glp.getName()) && getImplName().equals(glp.getImplName()) ; + final GLProfile glp = (GLProfile)o; + return getName() == glp.getName() && getImplName() == glp.getImplName() ; } return false; } @@ -1363,7 +1397,6 @@ public class GLProfile { */ private static void initProfilesForDefaultDevices(boolean firstUIActionOnProcess) { NativeWindowFactory.initSingleton(firstUIActionOnProcess); - if(DEBUG) { System.err.println("GLProfile.init firstUIActionOnProcess: "+ firstUIActionOnProcess + ", thread: " + Thread.currentThread().getName()); @@ -1509,7 +1542,7 @@ public class GLProfile { System.err.println("GLProfile.init defaultDevice "+defaultDevice); System.err.println("GLProfile.init profile order "+array2String(GL_PROFILE_LIST_ALL)); if(hasGL234Impl || hasGLES1Impl || hasGLES2Impl) { // avoid deadlock - System.err.println(JoglVersion.getDefaultOpenGLInfo(null)); + System.err.println(JoglVersion.getDefaultOpenGLInfo(null, true)); } } } @@ -1553,9 +1586,9 @@ public class GLProfile { boolean addedDesktopProfile = false; boolean addedEGLProfile = false; - - final boolean deviceIsDesktopCompatible = hasDesktopGLFactory && desktopFactory.getIsDeviceCompatible(device); - + + final boolean deviceIsDesktopCompatible = hasDesktopGLFactory && desktopFactory.getIsDeviceCompatible(device); + if( deviceIsDesktopCompatible ) { // 1st pretend we have all Desktop and EGL profiles .. computeProfileMap(device, true /* desktopCtxUndef*/, true /* esCtxUndef */); @@ -1628,8 +1661,8 @@ public class GLProfile { } } addedEGLProfile = computeProfileMap(device, false /* desktopCtxUndef*/, false /* esCtxUndef */); - } - + } + if( !addedDesktopProfile && !addedEGLProfile ) { setProfileMap(device, new HashMap<String /*GLProfile_name*/, GLProfile>()); // empty if(DEBUG) { @@ -1858,42 +1891,12 @@ public class GLProfile { return GL2; } else if(GLES2.equals(profile) && hasGLES2Impl && ( esCtxUndef || GLContext.isGLES2Available(device, isHardwareRasterizer))) { return GLES2; - /** - * TODO: GLES2_TRUE_DESKTOP (see: GLContextImpl, GLProfile) - * Hack to enable GLES2 for desktop profiles w/ ES2 compatibility, - * however .. a consequent implementation would need to have all GL2ES2 - * implementing profile to also implement GLES2! - * Let's rely on GL2ES2 and let the user/impl. query isGLES2Compatible() - } else if(GLES2.equals(profile)) { - if(hasGL234Impl || hasGLES2Impl) { - if(esCtxUndef) { - return GLES2; - } - return GLContext.getAvailableGLProfile(device, 2, GLContext.CTX_PROFILE_ES); - } - */ } else if(GLES1.equals(profile) && hasGLES1Impl && ( esCtxUndef || GLContext.isGLES1Available(device, isHardwareRasterizer))) { return GLES1; } return null; } - private static String getGLImplBaseClassName(String profileImpl) { - if ( GL4bc.equals(profileImpl) || - GL4.equals(profileImpl) || - GL3bc.equals(profileImpl) || - GL3.equals(profileImpl) || - GL2.equals(profileImpl) ) { - return "jogamp.opengl.gl4.GL4bc"; - } else if(GLES1.equals(profileImpl) || GL2ES1.equals(profileImpl)) { - return "jogamp.opengl.es1.GLES1"; - } else if(GLES2.equals(profileImpl) || GL2ES2.equals(profileImpl)) { - return "jogamp.opengl.es2.GLES2"; - } else { - throw new GLException("unsupported profile \"" + profileImpl + "\""); - } - } - private static /*final*/ HashMap<String /*device_connection*/, HashMap<String /*GLProfile_name*/, GLProfile>> deviceConn2ProfileMap = new HashMap<String /*device_connection*/, HashMap<String /*GLProfile_name*/, GLProfile>>(); |