aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/GLContextImpl.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-10-19 02:49:15 +0200
committerSven Gothel <[email protected]>2013-11-13 16:08:20 +0100
commit71f256693ddb6c383f382e99149f752c84d17075 (patch)
tree91722cb232fa38c730f17368c55ccc8f4c63c9a8 /src/jogl/classes/jogamp/opengl/GLContextImpl.java
parentcbd7bf1d65a253381b0775d57c0c949c75aef008 (diff)
Fix Bug 862: Fix GL Version Validation / NVidia GTX550 driver 331.13 - 64bit Linux - No compatibility GLProfile (GL2, >= GL3bc)
(Backport of 34b35c5a0a379a6b4c0b23b9d347a0b1338f0239) Fix GL Version Validation: We shall not rely on our known good versions when validating a queried GL context version, but allow some 'room' for a higher version post JOGL release while still cutting off 'odd versions'. While GL version detection, we always iterate from the highest known version down to the lowest. Hence 'GLContext.isValidGLVersion(..)' is satisfied by validating the lowest version number but allowing a higher than known one. Now we would return 'invalid' for a version >= 6. It is enough to clip to the maximum known version when iterating, allowing the highest unknown version to be available. GLContext.isValidGLVersion(..): Returns true, if the major.minor is not inferior to the lowest valid version and does not exceed the highest known major number by more than one. The minor version number is ignored by the upper limit validation and the major version number may exceed by one. The upper limit check is relaxed since we don't want to cut-off unforseen new GL version since the release of JOGL. Hence it is important to iterate through GL version from the upper limit and 'decrementGLVersion(..)' until invalid. Add GL Version 4.4 to valid known versions. Remove ES3 desktop detection, which is impossible Regression of commit 3a0d7703da32e9a5ddf08a334f18588a78038d88 (ES3 support) Conflicts: make/scripts/tests-win.bat make/scripts/tests.sh src/jogl/classes/javax/media/opengl/GLContext.java src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java src/jogl/classes/jogamp/opengl/GLContextImpl.java
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/GLContextImpl.java')
-rw-r--r--src/jogl/classes/jogamp/opengl/GLContextImpl.java90
1 files changed, 36 insertions, 54 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
index cab629c3a..a9e63d2f2 100644
--- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
@@ -834,7 +834,7 @@ public abstract class GLContextImpl extends GLContext {
boolean hasGL2 = false;
boolean hasGL4 = false;
boolean hasGL3 = false;
-
+
// Even w/ PROFILE_ALIASING, try to use true core GL profiles
// ensuring proper user behavior across platforms due to different feature sets!
//
@@ -899,7 +899,7 @@ public abstract class GLContextImpl extends GLContext {
hasGL2 = createContextARBMapVersionsAvailable(2, CTX_PROFILE_COMPAT); // GL2
success |= hasGL2;
if(hasGL2) {
- resetStates(); // clean this context states, since creation was temporary
+ resetStates(false); // clean this context states, since creation was temporary
}
}
if(success) {
@@ -1001,8 +1001,7 @@ public abstract class GLContextImpl extends GLContext {
minor[0]=minorMax;
long _context=0;
- while ( GLContext.isValidGLVersion(major[0], minor[0]) &&
- ( major[0]>majorMin || major[0]==majorMin && minor[0] >=minorMin ) ) {
+ do {
if (DEBUG) {
System.err.println(getThreadName() + ": createContextARBVersions: share "+share+", direct "+direct+", version "+major[0]+"."+minor[0]);
}
@@ -1017,10 +1016,8 @@ public abstract class GLContextImpl extends GLContext {
}
}
- if(!GLContext.decrementGLVersion(major, minor)) {
- break;
- }
- }
+ } while ( ( major[0]>majorMin || major[0]==majorMin && minor[0] >=minorMin ) &&
+ GLContext.decrementGLVersion(ctxOptionFlags, major, minor) );
return _context;
}
@@ -1038,9 +1035,6 @@ public abstract class GLContextImpl extends GLContext {
throw new GLException("Invalid GL Version "+major+"."+minor+", ctp "+toHexString(ctp));
}
- if (!GLContext.isValidGLVersion(major, minor)) {
- throw new GLException("Invalid GL Version "+major+"."+minor+", ctp "+toHexString(ctp));
- }
ctxVersion = new VersionNumber(major, minor, 0);
ctxVersionString = getGLVersion(major, minor, ctxOptions, glVersion);
ctxVendorVersion = glVendorVersion;
@@ -1195,16 +1189,6 @@ public abstract class GLContextImpl extends GLContext {
}
/**
- * We cannot promote a non ARB context to >= 3.1, reduce it to 3.0 then.
- */
- private static void limitNonARBContextVersion(int[] major, int[] minor, int ctp) {
- if ( 0 == (ctp & CTX_IS_ARB_CREATED) && ( major[0] > 3 || major[0] == 3 && minor[0] >= 1 ) ) {
- major[0] = 3;
- minor[0] = 0;
- }
- }
-
- /**
* Returns null if version string is invalid, otherwise a valid instance.
* <p>
* Note: Non ARB ctx is limited to GL 3.0.
@@ -1216,8 +1200,7 @@ public abstract class GLContextImpl extends GLContext {
if ( version.isValid() ) {
int[] major = new int[] { version.getMajor() };
int[] minor = new int[] { version.getMinor() };
- limitNonARBContextVersion(major, minor, ctp);
- if ( GLContext.isValidGLVersion(major[0], minor[0]) ) {
+ if ( GLContext.isValidGLVersion(ctp, major[0], minor[0]) ) {
return new VersionNumber(major[0], minor[0], 0);
}
}
@@ -1248,8 +1231,7 @@ public abstract class GLContextImpl extends GLContext {
} else {
glGetIntegervInt(GL2GL3.GL_MAJOR_VERSION, glIntMajor, 0, _glGetIntegerv);
glGetIntegervInt(GL2GL3.GL_MINOR_VERSION, glIntMinor, 0, _glGetIntegerv);
- limitNonARBContextVersion(glIntMajor, glIntMinor, ctp);
- return true;
+ return true;
}
}
@@ -1341,67 +1323,67 @@ public abstract class GLContextImpl extends GLContext {
}
}
if (DEBUG) {
- System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: version verification (Int): "+glVersion+", "+glIntMajor[0]+"."+glIntMinor[0]);
+ System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: Version verification (Int): "+glVersion+", "+glIntMajor[0]+"."+glIntMinor[0]);
}
// Only validate if a valid int version was fetched, otherwise cont. w/ version-string method -> 3.0 > Version || Version > MAX!
- if ( GLContext.isValidGLVersion(glIntMajor[0], glIntMinor[0]) ) {
- if( glIntMajor[0]<major || ( glIntMajor[0]==major && glIntMinor[0]<minor ) || 0 == major ) {
- if( strictMatch && 2 < major ) { // relaxed match for versions major < 3 requests, last resort!
- if(DEBUG) {
- System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: FAIL, GL version mismatch (Int): "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+" -> "+glVersion+", "+glIntMajor[0]+"."+glIntMinor[0]);
- }
- return false;
+ if ( GLContext.isValidGLVersion(ctxProfileBits, glIntMajor[0], glIntMinor[0]) ) {
+ // relaxed match for versions major < 3 requests, last resort!
+ if( strictMatch && major >= 3 && glIntMajor[0]<major || ( glIntMajor[0]==major && glIntMinor[0]<minor ) ) {
+ if(DEBUG) {
+ System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: FAIL, GL version mismatch (Int): "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+" -> "+glVersion+", "+glIntMajor[0]+"."+glIntMinor[0]);
}
- major = glIntMajor[0];
- minor = glIntMinor[0];
+ return false;
}
+ // Use returned GL version!
+ major = glIntMajor[0];
+ minor = glIntMinor[0];
versionValidated = true;
} else {
versionGL3IntFailed = true;
}
}
if( !versionValidated ) {
- // Validate the requested version w/ the GL-version from the version string.
- final VersionNumber setGLVersionNumber = new VersionNumber(major, minor, 0);
- final VersionNumber strGLVersionNumber = getGLVersionNumber(ctxProfileBits, glVersion);
+ // Validate the requested version w/ the GL-version from the version string.
+ final VersionNumber expGLVersionNumber = new VersionNumber(major, minor, 0);
+ final VersionNumber hasGLVersionNumber = getGLVersionNumber(ctxProfileBits, glVersion);
if (DEBUG) {
- System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: version verification (String): "+glVersion+", "+strGLVersionNumber);
+ System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: Version verification (String): "+glVersion+", "+hasGLVersionNumber);
}
// Only validate if a valid string version was fetched -> MIN > Version || Version > MAX!
- if( null != strGLVersionNumber ) {
- if( strGLVersionNumber.compareTo(setGLVersionNumber) < 0 || 0 == major ) {
- if( strictMatch && 2 < major ) { // relaxed match for versions major < 3 requests, last resort!
- if(DEBUG) {
- System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: FAIL, GL version mismatch (String): "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+" -> "+glVersion+", "+strGLVersionNumber);
- }
- return false;
+ if( null != hasGLVersionNumber ) {
+ // relaxed match for versions major < 3 requests, last resort!
+ if( strictMatch && major >= 3 && hasGLVersionNumber.compareTo(expGLVersionNumber) < 0 ) {
+ if(DEBUG) {
+ System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: FAIL, GL version mismatch (String): "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+" -> "+glVersion+", "+hasGLVersionNumber);
}
- major = strGLVersionNumber.getMajor();
- minor = strGLVersionNumber.getMinor();
+ return false;
}
if( strictMatch && versionGL3IntFailed && major >= 3 ) {
if(DEBUG) {
- System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: FAIL, GL3 version Int failed, String: "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+" -> "+glVersion+", "+strGLVersionNumber);
+ System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: FAIL, GL3 version Int failed, String: "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+" -> "+glVersion+", "+hasGLVersionNumber);
}
return false;
}
+ // Use returned GL version!
+ major = hasGLVersionNumber.getMajor();
+ minor = hasGLVersionNumber.getMinor();
versionValidated = true;
}
}
- if( strictMatch && !versionValidated && 0 < major ) {
+ if( strictMatch && !versionValidated ) {
if(DEBUG) {
System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: FAIL, No GL version validation possible: "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+" -> "+glVersion);
}
return false;
}
if (DEBUG) {
- System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: post version verification "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+", strictMatch "+strictMatch+", versionValidated "+versionValidated+", versionGL3IntFailed "+versionGL3IntFailed);
+ System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: Post version verification "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+", strictMatch "+strictMatch+", versionValidated "+versionValidated+", versionGL3IntFailed "+versionGL3IntFailed);
}
-
- if( 2 > major ) { // there is no ES2-compat for a profile w/ major < 2
- ctxProfileBits &= ~GLContext.CTX_IMPL_ES2_COMPAT;
+
+ if( major < 2 ) { // there is no ES2/3-compat for a profile w/ major < 2
+ ctxProfileBits &= ~ ( GLContext.CTX_IMPL_ES2_COMPAT | GLContext.CTX_IMPL_ES3_COMPAT ) ;
}
final VersionNumberString vendorVersion = GLVersionNumber.createVendorVersion(glVersion);