diff options
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/egl')
4 files changed, 59 insertions, 26 deletions
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java index b2f06dce6..967b88358 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java @@ -44,6 +44,7 @@ import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; @@ -187,7 +188,11 @@ public class EGLContext extends GLContextImpl { { if ( glProfile.usesNativeGLES3() ) { contextVersionReq = 3; - contextVersionAttr = 3; + if( GLRendererQuirks.existStickyDeviceQuirk( GLDrawableFactory.getEGLFactory().getDefaultDevice(), GLRendererQuirks.GLES3ViaEGLES2Config) ) { + contextVersionAttr = 2; + } else { + contextVersionAttr = 3; + } } else if ( glProfile.usesNativeGLES2() ) { contextVersionReq = 2; contextVersionAttr = 2; diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java index f7799f1ec..3c8531730 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java @@ -362,10 +362,10 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { return new ArrayList<GLCapabilitiesImmutable>(0); } - private boolean mapAvailableEGLESConfig(AbstractGraphicsDevice adevice, int esProfile, + private boolean mapAvailableEGLESConfig(AbstractGraphicsDevice adevice, int[] esProfile, boolean[] hasPBuffer, GLRendererQuirks[] rendererQuirks, int[] ctp) { final String profileString; - switch( esProfile ) { + switch( esProfile[0] ) { case 3: profileString = GLProfile.GLES3; break; case 2: @@ -413,7 +413,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { if(null == defaultSharedResource) { return false; } - switch(esProfile) { + switch(esProfile[0]) { case 3: if( !defaultSharedResource.wasES3ContextCreated ) { return false; @@ -436,7 +436,10 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { ctp[0] = defaultSharedResource.ctpES1; break; } - EGLContext.mapStaticGLVersion(adevice, esProfile, 0, ctp[0]); + if( null != rendererQuirks[0] ) { + GLRendererQuirks.addStickyDeviceQuirks(adevice, rendererQuirks[0]); + } + EGLContext.mapStaticGLVersion(adevice, esProfile[0], 0, ctp[0]); return true; } @@ -491,6 +494,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } rendererQuirks[0] = context.getRendererQuirks(); ctp[0] = context.getContextOptions(); + esProfile[0] = context.getGLVersionNumber().getMajor(); success = true; } else { // Oops .. something is wrong @@ -499,10 +503,10 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } } } - } catch (GLException gle) { + } catch (Throwable t) { if (DEBUG) { System.err.println("EGLDrawableFactory.mapAvailableEGLESConfig: INFO: context create/makeCurrent failed"); - gle.printStackTrace(); + t.printStackTrace(); } } finally { context.destroy(); @@ -594,8 +598,6 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { private SharedResource createEGLSharedResourceImpl(AbstractGraphicsDevice adevice) { final boolean madeCurrentES1; - final boolean madeCurrentES2; - final boolean madeCurrentES3; boolean[] hasPBufferES1 = new boolean[] { false }; boolean[] hasPBufferES3ES2 = new boolean[] { false }; // EGLContext[] eglCtxES1 = new EGLContext[] { null }; @@ -611,18 +613,27 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } if( null != eglES1DynamicLookupHelper ) { - madeCurrentES1 = mapAvailableEGLESConfig(adevice, 1, hasPBufferES1, rendererQuirksES1, ctpES1); + final int[] esProfile = { 1 }; + madeCurrentES1 = mapAvailableEGLESConfig(adevice, esProfile, hasPBufferES1, rendererQuirksES1, ctpES1) && 1 == esProfile[0]; } else { madeCurrentES1 = false; } + boolean madeCurrentES2 = false; + boolean madeCurrentES3 = false; if( null != eglES2DynamicLookupHelper ) { - madeCurrentES3 = mapAvailableEGLESConfig(adevice, 3, hasPBufferES3ES2, rendererQuirksES3ES2, ctpES3ES2); - madeCurrentES2 = mapAvailableEGLESConfig(adevice, 2, hasPBufferES3ES2, rendererQuirksES3ES2, ctpES3ES2); - } else { - madeCurrentES2 = false; - madeCurrentES3 = false; + // ES3 Query + final int[] esProfile = { 3 }; + madeCurrentES3 = mapAvailableEGLESConfig(adevice, esProfile, hasPBufferES3ES2, rendererQuirksES3ES2, ctpES3ES2) && 3 == esProfile[0]; + // ES2 Query, may result in ES3 + esProfile[0] = 2; + if( mapAvailableEGLESConfig(adevice, esProfile, hasPBufferES3ES2, rendererQuirksES3ES2, ctpES3ES2) ) { + switch( esProfile[0] ) { + case 2: madeCurrentES2 = true; break; + case 3: madeCurrentES3 = true; break; + default: throw new InternalError("XXXX Got "+esProfile[0]); + } + } } - if( !EGLContext.getAvailableGLVersionsSet(adevice) ) { // Even though we override the non EGL native mapping intentionally, // avoid exception due to double 'set' - carefull exception of the rule. @@ -640,9 +651,9 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } if (DEBUG) { System.err.println("EGLDrawableFactory.createShared: devices: queried nativeTK "+QUERY_EGL_ES_NATIVE_TK+", adevice " + adevice + ", defaultDevice " + defaultDevice); - System.err.println("EGLDrawableFactory.createShared: context ES1: " + madeCurrentES1 + ", hasPBuffer "+hasPBufferES1[0]); - System.err.println("EGLDrawableFactory.createShared: context ES2: " + madeCurrentES2 + ", hasPBuffer "+hasPBufferES3ES2[0]); - System.err.println("EGLDrawableFactory.createShared: context ES3: " + madeCurrentES3 + ", hasPBuffer "+hasPBufferES3ES2[0]); + System.err.println("EGLDrawableFactory.createShared: context ES1: " + madeCurrentES1 + ", hasPBuffer "+hasPBufferES1[0]+", quirks "+rendererQuirksES1[0]); + System.err.println("EGLDrawableFactory.createShared: context ES2: " + madeCurrentES2 + ", hasPBuffer "+hasPBufferES3ES2[0]+", quirks "+rendererQuirksES3ES2[0]); + System.err.println("EGLDrawableFactory.createShared: context ES3: " + madeCurrentES3 + ", hasPBuffer "+hasPBufferES3ES2[0]+", quirks "+rendererQuirksES3ES2[0]); dumpMap(); } return sr; diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java index 0e5551b8e..88ed0be92 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java @@ -46,6 +46,7 @@ import javax.media.nativewindow.VisualIDHolder; import javax.media.opengl.DefaultGLCapabilitiesChooser; import javax.media.opengl.GLCapabilitiesChooser; import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; @@ -55,6 +56,7 @@ import com.jogamp.common.nio.Buffers; import com.jogamp.common.nio.PointerBuffer; import com.jogamp.nativewindow.MutableGraphicsConfiguration; import com.jogamp.nativewindow.egl.EGLGraphicsDevice; +import com.jogamp.opengl.GLRendererQuirks; public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration implements Cloneable { @@ -94,8 +96,9 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple } final long cfg = EGLConfigId2EGLConfig(dpy, eglConfigID); if(0 < cfg) { + final GLRendererQuirks defaultQuirks = GLRendererQuirks.getStickyDeviceQuirks( GLDrawableFactory.getEGLFactory().getDefaultDevice() ); final int winattrmask = GLGraphicsConfigurationUtil.getExclusiveWinAttributeBits(capsRequested); - final EGLGLCapabilities caps = EGLConfig2Capabilities((EGLGraphicsDevice)absDevice, capsRequested.getGLProfile(), cfg, winattrmask, false); + final EGLGLCapabilities caps = EGLConfig2Capabilities(defaultQuirks, (EGLGraphicsDevice)absDevice, capsRequested.getGLProfile(), cfg, winattrmask, false); return new EGLGraphicsConfiguration(absScreen, caps, capsRequested, new DefaultGLCapabilitiesChooser()); } return null; @@ -179,6 +182,7 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple } /** + * @param defaultQuirks GLRendererQuirks of the EGLDrawableFactory's defaultDevice * @param device * @param glp desired GLProfile, may be null * @param config @@ -186,8 +190,8 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple * @param forceTransparentFlag * @return */ - public static EGLGLCapabilities EGLConfig2Capabilities(EGLGraphicsDevice device, GLProfile glp, long config, - int winattrmask, boolean forceTransparentFlag) { + public static EGLGLCapabilities EGLConfig2Capabilities(GLRendererQuirks defaultQuirks, EGLGraphicsDevice device, GLProfile glp, + long config, int winattrmask, boolean forceTransparentFlag) { final long display = device.getHandle(); final int cfgID; final int rType; @@ -232,7 +236,14 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple } return null; } - rType = values.get(1); + { + final int rTypeOrig = values.get(1); + if( defaultQuirks.exist(GLRendererQuirks.GLES3ViaEGLES2Config) && 0 != ( EGL.EGL_OPENGL_ES2_BIT & rTypeOrig ) ) { + rType = rTypeOrig | EGLExt.EGL_OPENGL_ES3_BIT_KHR; + } else { + rType = rTypeOrig; + } + } if( EGL.EGL_NATIVE_VISUAL_ID == attributes.get(2) ) { visualID = values.get(2); @@ -251,7 +262,7 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple if(!EGLGLCapabilities.isCompatible(glp, rType)) { if(DEBUG) { System.err.println("config "+toHexString(config)+": Requested GLProfile "+glp+ - " not compatible with EGL-RenderableType["+EGLGLCapabilities.renderableTypeToString(null, rType)+"]"); + " with quirks "+defaultQuirks+" not compatible with EGL-RenderableType["+EGLGLCapabilities.renderableTypeToString(null, rType)+"]"); } return null; } @@ -453,7 +464,11 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple } else if(caps.getGLProfile().usesNativeGLES2()) { attrs.put(idx++, EGL.EGL_OPENGL_ES2_BIT); } else if(caps.getGLProfile().usesNativeGLES3()) { - attrs.put(idx++, EGLExt.EGL_OPENGL_ES3_BIT_KHR); + if( GLRendererQuirks.existStickyDeviceQuirk(GLDrawableFactory.getEGLFactory().getDefaultDevice(), GLRendererQuirks.GLES3ViaEGLES2Config) ) { + attrs.put(idx++, EGL.EGL_OPENGL_ES2_BIT); + } else { + attrs.put(idx++, EGLExt.EGL_OPENGL_ES3_BIT_KHR); + } } else { attrs.put(idx++, EGL.EGL_OPENGL_BIT); } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java index 568fede45..8802c3c7d 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java @@ -53,6 +53,7 @@ import javax.media.opengl.GLDrawableFactory; import com.jogamp.common.nio.Buffers; import com.jogamp.common.nio.PointerBuffer; import com.jogamp.nativewindow.egl.EGLGraphicsDevice; +import com.jogamp.opengl.GLRendererQuirks; import jogamp.opengl.GLGraphicsConfigurationFactory; import jogamp.opengl.GLGraphicsConfigurationUtil; @@ -476,9 +477,10 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact } static List<GLCapabilitiesImmutable> eglConfigs2GLCaps(EGLGraphicsDevice device, GLProfile glp, PointerBuffer configs, int num, int winattrmask, boolean forceTransparentFlag, boolean onlyFirstValid) { + final GLRendererQuirks defaultQuirks = GLRendererQuirks.getStickyDeviceQuirks( GLDrawableFactory.getEGLFactory().getDefaultDevice() ); List<GLCapabilitiesImmutable> bucket = new ArrayList<GLCapabilitiesImmutable>(num); for(int i=0; i<num; i++) { - final GLCapabilitiesImmutable caps = EGLGraphicsConfiguration.EGLConfig2Capabilities(device, glp, configs.get(i), winattrmask, forceTransparentFlag); + final GLCapabilitiesImmutable caps = EGLGraphicsConfiguration.EGLConfig2Capabilities(defaultQuirks, device, glp, configs.get(i), winattrmask, forceTransparentFlag); if(null != caps) { bucket.add(caps); if(onlyFirstValid) { |