diff options
author | Sven Gothel <[email protected]> | 2013-12-21 14:40:36 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-12-21 14:40:36 +0100 |
commit | 972feb4be95d1c16c71b84694729952e91dda668 (patch) | |
tree | 6c73b547fc8e9dbd9e0855520cee221e05d7da95 /src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java | |
parent | bbb7f94c015fbfefdff672eb2d261fbd230c4e81 (diff) |
Bug 925 - Accept an ES3 Context, if reported via GL-Version-String w/o EGL_OPENGL_ES3_BIT_KHR
Add Quirk 'GLES3ViaEGLES2Config': ES3 Context is used via EGL_OPENGL_ES2_BIT and 'version 2' for create context attributes.
- GLContextImpl.setGLFunctionAvailability(..)'s ES version validation
only fails if requested major version == 1 and doesn't match.
Hence requesting major==2 and having version 3 is tolerated.
- GLContextImpl.setGLFunctionAvailability(..)'s Quirks:
requested-major < has-major -> Adding GLES3ViaEGLES2Config
- EGLDrawableFactory.mapAvailableEGLESConfig(..):
Reflects has-major version, i.e. GLES3ViaEGLES2Config situation where
an ES2 request leads to an ES3 version.
Note: All workarounds can be found via lookup of GLES3ViaEGLES2Config (as usual when using quirks).
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java')
-rw-r--r-- | src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java | 47 |
1 files changed, 29 insertions, 18 deletions
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; |