From 209bb2f0dc3418d168dc6887802bf4368b6d6f4e Mon Sep 17 00:00:00 2001
From: Sven Gothel GL_VENDOR
and GL_RENDERER
strings are
* listed here
+ * For testing purpose or otherwise, you may override the implemented + * quirk bit setting behavior using {@link GLRendererQuirks.Override}. + *
*/ public class GLRendererQuirks { + /** + * Allow overriding any quirk settings + * via the two properties: + *+ * java -Djogl.quirks.force=GL3CompatNonCompliant,NoFullFBOSupport -cp my_classpath some.main.Class + *+ *
+ * Naturally, one quirk can only be listed in one override list. + * Hence the two override sets force and ignore are unique. + *
+ */ + public static enum Override { + /** + * No override. + */ + NONE, + /** + * Enforce the quirk, i.e. allowing the code path to be injected w/o actual cause. + */ + FORCE, + /** + * Ignore the quirk, i.e. don't set the quirk if otherwise caused. + */ + IGNORE + } + /** * Crashes XServer when using double buffered PBuffer with GL_RENDERER: ** Currently, Mesa >= 9.1.3 (may extend back as far as 9.0) OpenGL 3.1 compatibility * context is not compliant. Most programs will give completely broken output (or no @@ -97,7 +137,7 @@ public class GLRendererQuirks { *
* It still has to be verified whether the AMD OpenGL 3.1 core driver is compliant enought.
*/
- public static final int GLNonCompliant = 6;
+ public static final int GL3CompatNonCompliant = 6;
/**
* The OpenGL context needs a glFlush()
before releasing it, otherwise driver may freeze:
@@ -447,12 +487,12 @@ public class GLRendererQuirks {
*/
public static final int NoSurfacelessCtx = 22;
- /** Return the number of known quirks. */
+ /** Return the number of known quirks, aka quirk bit count. */
public static final int getCount() { return 23; }
private static final String[] _names = new String[] { "NoDoubleBufferedPBuffer", "NoDoubleBufferedBitmap", "NoSetSwapInterval",
"NoOffscreenBitmap", "NoSetSwapIntervalPostRetarget", "GLSLBuggyDiscard",
- "GLNonCompliant", "GLFlushBeforeRelease", "DontCloseX11Display",
+ "GL3CompatNonCompliant", "GLFlushBeforeRelease", "DontCloseX11Display",
"NeedCurrCtx4ARBPixFmtQueries", "NeedCurrCtx4ARBCreateContext",
"NoFullFBOSupport", "GLSLNonCompliant", "GL4NeedsGL3Request",
"GLSharedContextBuggy", "GLES3ViaEGLES2Config", "SingletonEGLDisplayOnly",
@@ -504,17 +544,6 @@ public class GLRendererQuirks {
final GLRendererQuirks sq = getStickyDeviceQuirks(device);
sq.addQuirk(quirk);
}
- /**
- * {@link #addQuirks(int[], int, int) Adding given quirks} of sticky {@link AbstractGraphicsDevice}'s {@link GLRendererQuirks}.
- *
- * Not thread safe. - *
- * @see #getStickyDeviceQuirks(AbstractGraphicsDevice) - */ - public static void addStickyDeviceQuirks(final AbstractGraphicsDevice device, final int[] quirks, final int offset, final int len) throws IllegalArgumentException { - final GLRendererQuirks sq = getStickyDeviceQuirks(device); - sq.addQuirks(quirks, offset, len); - } /** * {@link #addQuirks(GLRendererQuirks) Adding given quirks} of sticky {@link AbstractGraphicsDevice}'s {@link GLRendererQuirks}. *@@ -533,8 +562,8 @@ public class GLRendererQuirks { *
* @see #getStickyDeviceQuirks(AbstractGraphicsDevice) */ - public static boolean existStickyDeviceQuirk(final AbstractGraphicsDevice device, final int quirk) { - return getStickyDeviceQuirks(device).exist(quirk); + public static boolean existStickyDeviceQuirk(final AbstractGraphicsDevice device, final int quirkBit) { + return getStickyDeviceQuirks(device).exist(quirkBit); } /** * {@link #addQuirks(GLRendererQuirks) Pushing} the sticky {@link AbstractGraphicsDevice}'s {@link GLRendererQuirks} @@ -548,6 +577,56 @@ public class GLRendererQuirks { dest.addQuirks(getStickyDeviceQuirks(device)); } + public static final Override getOverride(final int quirkBit) throws IllegalArgumentException { + validateQuirk(quirkBit); + if( 0 != ( ( 1 << quirkBit ) & _bitmaskOverrideForce ) ) { + return Override.FORCE; + } + if( 0 != ( ( 1 << quirkBit ) & _bitmaskOverrideIgnore ) ) { + return Override.IGNORE; + } + return Override.NONE; + } + private static int _bitmaskOverrideForce = 0; + private static int _bitmaskOverrideIgnore = 0; + static { + _bitmaskOverrideForce = _queryQuirkMaskOfPropertyList("jogl.quirks.force", Override.FORCE); + _bitmaskOverrideIgnore = _queryQuirkMaskOfPropertyList("jogl.quirks.ignore", Override.IGNORE); + final int uniqueTest = _bitmaskOverrideForce & _bitmaskOverrideIgnore; + if( 0 != uniqueTest ) { + throw new InternalError("Override properties force 0x"+Integer.toHexString(_bitmaskOverrideForce)+ + " and ignore 0x"+Integer.toHexString(_bitmaskOverrideIgnore)+ + " have intersecting bits 0x"+Integer.toHexString(uniqueTest)+" "+Integer.toBinaryString(uniqueTest)); + } + } + private static int _queryQuirkMaskOfPropertyList(final String propertyName, final Override override) { + final String quirkNameList = PropertyAccess.getProperty(propertyName, true); + if( null == quirkNameList ) { + return 0; + } + int res = 0; + final String quirkNames[] = quirkNameList.split(","); + for(int i=0; i