diff options
author | Sven Gothel <[email protected]> | 2012-02-13 07:00:01 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-02-13 07:00:01 +0100 |
commit | 4011e70eed8c88aee0fcd051a50ab3f15bb94f68 (patch) | |
tree | e7fb1c33d4c0e75fc52dc3ec2d927f76c51de216 /src/jogl/classes/jogamp/opengl/GLContextImpl.java | |
parent | ddd375375025fb83aba90c80b9a089876dad5434 (diff) |
OpenGL ES/EGL Overhaul
- GLProfile properly detects native EGL/ES1/ES2 on the 'desktop' device factory.
This allows usage of Mesa's EGL/ES or Imageon's PVR emulation, etc.
- GLProfile drops getDefaultDesktopDevice() and getDefaultEGLDevice()
since both are aligned by getDefaultDevice().
- Fix GL_ARB_ES2_compatibility detection and utilize
resulting isGLES2Compatible() where possible.
This allows ES2 compatible desktop profiles to use core ES2 functionality
(glShaderBinary() .. etc) even with a GL2ES2 desktop implementation.
- EGLDrawable: If createSurface(..) fails (BAD_NATIVE_WINDOW) w/ surfaceHandle
it uses windowHandle if available and differs.
This allows the ANGLE impl. to work.
- Properly order of EGL/ES library lookup:
ES2: libGLESv2.so.2, libGLESv2.so, GLES20, GLESv2_CM
EGL: libEGL.so.1, libEGL.so, EGL
- *DynamicLookupHelper reference will be null if it's library is not complete
(all tool libs, all glue libs and a ProcAddressFunc lookup function - if named).
- Enhance GL version string (incl. ES2 compatible, hw/sw, ..)
- GLBase: Fix docs and remove redundancies
- Prepared (disabled) DesktopES2DynamicLibraryBundleInfo
to be used for a real EGL/ES2 implementation within the desktop GL lib (AMD).
Sadly it currenly crashed within eglGetDisplay(EGL_DEFAULT_DISPLAY),
hence it's disabled.
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/GLContextImpl.java')
-rw-r--r-- | src/jogl/classes/jogamp/opengl/GLContextImpl.java | 62 |
1 files changed, 37 insertions, 25 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index a7710e5bc..02ac2428f 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -653,11 +653,12 @@ public abstract class GLContextImpl extends GLContext { private final void mapGLVersions(AbstractGraphicsDevice device) { synchronized (GLContext.deviceVersionAvailable) { + // Following GLProfile.GL_PROFILE_LIST_ALL order of profile detection { GL4bc, GL3bc, GL2, GL4, GL3, GL2GL3, GLES2, GL2ES2, GLES1, GL2ES1 } createContextARBMapVersionsAvailable(4, true /* compat */); // GL4bc - createContextARBMapVersionsAvailable(4, false /* core */); // GL4 createContextARBMapVersionsAvailable(3, true /* compat */); // GL3bc + createContextARBMapVersionsAvailable(2, true /* compat */); // GL2 + createContextARBMapVersionsAvailable(4, false /* core */); // GL4 createContextARBMapVersionsAvailable(3, false /* core */); // GL3 - createContextARBMapVersionsAvailable(2, true /* compat */); // GL2 GLContext.setAvailableGLVersionsSet(device); resetStates(); } @@ -717,14 +718,21 @@ public abstract class GLContextImpl extends GLContext { } if(0!=_context) { AbstractGraphicsDevice device = drawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice(); - if( isExtensionAvailable("GL_ARB_ES2_compatibility") ) { - ctp |= CTX_PROFILE_ES2_COMPAT; - } - GLContext.mapAvailableGLVersion(device, reqMajor, reqProfile, major[0], minor[0], ctp); + // ctxMajorVersion, ctxMinorVersion, ctxOptions is being set by + // createContextARBVersions(..) -> setGLFunctionAvailbility(..) -> setContextVersion(..) + GLContext.mapAvailableGLVersion(device, reqMajor, reqProfile, ctxMajorVersion, ctxMinorVersion, ctxOptions); + /** + * 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() + if( isGLES2Compatible() && null == GLContext.getAvailableGLVersion(device, 2, GLContext.CTX_PROFILE_ES) ) { + GLContext.mapAvailableGLVersion(device, 2, GLContext.CTX_PROFILE_ES, ctxMajorVersion, ctxMinorVersion, ctxOptions); + }*/ destroyContextARBImpl(_context); if (DEBUG) { - System.err.println(getThreadName() + ": !!! createContextARBMapVersionsAvailable HAVE: "+ - GLContext.getAvailableGLVersionAsString(device, reqMajor, reqProfile)); + System.err.println(getThreadName() + ": !!! createContextARBMapVersionsAvailable HAVE: " + getGLVersion()); } } else if (DEBUG) { System.err.println(getThreadName() + ": !!! createContextARBMapVersionsAvailable NOPE: "+reqMajor+"."+reqProfile); @@ -929,24 +937,24 @@ public abstract class GLContextImpl extends GLContext { * @see #setContextVersion * @see javax.media.opengl.GLContext#CTX_OPTION_ANY * @see javax.media.opengl.GLContext#CTX_PROFILE_COMPAT + * @see javax.media.opengl.GLContext#CTX_IMPL_ES2_COMPAT */ protected final void setGLFunctionAvailability(boolean force, int major, int minor, int ctxProfileBits) { if(null!=this.gl && null!=glProcAddressTable && !force) { return; // already done and not forced } - + if(null==this.gl || !verifyInstance(gl.getGLProfile(), "Impl", this.gl)) { setGL(createGL(getGLDrawable().getGLProfile())); } - updateGLXProcAddressTable(); AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration(); AbstractGraphicsDevice adevice = aconfig.getScreen().getDevice(); - final int ctxImplBits = drawable.getChosenGLCapabilities().getHardwareAccelerated() ? GLContext.CTX_IMPL_ACCEL_HARD : GLContext.CTX_IMPL_ACCEL_SOFT; - contextFQN = getContextFQN(adevice, major, minor, ctxProfileBits, ctxImplBits); + ctxProfileBits |= drawable.getChosenGLCapabilities().getHardwareAccelerated() ? GLContext.CTX_IMPL_ACCEL_HARD : GLContext.CTX_IMPL_ACCEL_SOFT; + contextFQN = getContextFQN(adevice, major, minor, ctxProfileBits); if (DEBUG) { - System.err.println(getThreadName() + ": !!! Context FQN: "+contextFQN); + System.err.println(getThreadName() + ": !!! Context FQN: "+contextFQN+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)); } // @@ -956,8 +964,8 @@ public abstract class GLContextImpl extends GLContext { synchronized(mappedContextTypeObjectLock) { table = mappedGLProcAddress.get( contextFQN ); if(null != table && !verifyInstance(gl.getGLProfile(), "ProcAddressTable", table)) { - throw new InternalError("GLContext GL ProcAddressTable mapped key("+contextFQN+") -> "+ - table.getClass().getName()+" not matching "+gl.getGLProfile().getGLImplBaseClassName()); + throw new InternalError("GLContext GL ProcAddressTable mapped key("+contextFQN+" - " + GLContext.getGLVersion(major, minor, ctxProfileBits, null)+ + ") -> "+ table.getClass().getName()+" not matching "+gl.getGLProfile().getGLImplBaseClassName()); } } if(null != table) { @@ -981,11 +989,6 @@ public abstract class GLContextImpl extends GLContext { } // - // Set GL Version - // - setContextVersion(major, minor, ctxProfileBits); - - // // Update ExtensionAvailabilityCache // ExtensionAvailabilityCache eCache; @@ -1008,16 +1011,24 @@ public abstract class GLContextImpl extends GLContext { System.err.println(getThreadName() + ": !!! GLContext GL ExtensionAvailabilityCache mapping key("+contextFQN+") -> "+extensionAvailability.hashCode()); } } + } + if( isExtensionAvailable("GL_ARB_ES2_compatibility") ) { + ctxProfileBits |= CTX_IMPL_ES2_COMPAT; } + + // + // Set GL Version + // + setContextVersion(major, minor, ctxProfileBits); } protected final void removeCachedVersion(int major, int minor, int ctxProfileBits) { AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration(); AbstractGraphicsDevice adevice = aconfig.getScreen().getDevice(); - final int ctxImplBits = drawable.getChosenGLCapabilities().getHardwareAccelerated() ? GLContext.CTX_IMPL_ACCEL_HARD : GLContext.CTX_IMPL_ACCEL_SOFT; - contextFQN = getContextFQN(adevice, major, minor, ctxProfileBits, ctxImplBits); + ctxProfileBits |= drawable.getChosenGLCapabilities().getHardwareAccelerated() ? GLContext.CTX_IMPL_ACCEL_HARD : GLContext.CTX_IMPL_ACCEL_SOFT; + contextFQN = getContextFQN(adevice, major, minor, ctxProfileBits); if (DEBUG) { - System.err.println(getThreadName() + ": !!! RM Context FQN: "+contextFQN); + System.err.println(getThreadName() + ": !!! RM Context FQN: "+contextFQN+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)); } synchronized(mappedContextTypeObjectLock) { @@ -1129,8 +1140,9 @@ public abstract class GLContextImpl extends GLContext { return false; } - protected static String getContextFQN(AbstractGraphicsDevice device, int major, int minor, int ctxProfileBits, int ctxImplBits) { - return device.getUniqueID() + "-" + toHexString(compose8bit(major, minor, ctxProfileBits, ctxImplBits)); + protected static String getContextFQN(AbstractGraphicsDevice device, int major, int minor, int ctxProfileBits) { + ctxProfileBits &= ~GLContext.CTX_IMPL_ES2_COMPAT ; // remove non-key value + return device.getUniqueID() + "-" + toHexString(composeBits(major, minor, ctxProfileBits)); } protected String getContextFQN() { |