28package com.jogamp.opengl;
30import java.lang.reflect.Field;
31import java.util.IdentityHashMap;
33import com.jogamp.nativewindow.AbstractGraphicsDevice;
34import com.jogamp.opengl.GLCapabilitiesImmutable;
36import com.jogamp.common.os.Platform;
37import com.jogamp.common.util.PropertyAccess;
38import com.jogamp.opengl.egl.EGL;
39import com.jogamp.opengl.egl.EGLExt;
542 private static final String[] _names =
new String[] {
"NoDoubleBufferedPBuffer",
"NoDoubleBufferedBitmap",
"NoSetSwapInterval",
543 "NoOffscreenBitmap",
"NoSetSwapIntervalPostRetarget",
"GLSLBuggyDiscard",
544 "GL3CompatNonCompliant",
"GLFlushBeforeRelease",
"DontCloseX11Display",
545 "NeedCurrCtx4ARBPixFmtQueries",
"NeedCurrCtx4ARBCreateContext",
546 "NoFullFBOSupport",
"GLSLNonCompliant",
"GL4NeedsGL3Request",
547 "GLSharedContextBuggy",
"GLES3ViaEGLES2Config",
"SingletonEGLDisplayOnly",
548 "NoMultiSamplingBuffers",
"BuggyColorRenderbuffer",
"NoPBufferWithAccum",
549 "NeedSharedObjectSync",
"NoARBCreateContext",
"NoSurfacelessCtx",
550 "NoFBOSupport",
"DontChooseFBConfigBestMatch",
"No10BitColorCompOffscreen"
553 private static final IdentityHashMap<String, GLRendererQuirks> stickyDeviceQuirks =
new IdentityHashMap<String, GLRendererQuirks>();
571 stickyDeviceQuirks.put(key, res);
632 if( 0 != ( ( 1 << quirkBit ) & _bitmaskOverrideForce ) ) {
635 if( 0 != ( ( 1 << quirkBit ) & _bitmaskOverrideIgnore ) ) {
640 private static int _bitmaskOverrideForce = 0;
641 private static int _bitmaskOverrideIgnore = 0;
643 _bitmaskOverrideForce = _queryQuirkMaskOfPropertyList(
"jogl.quirks.force", Override.FORCE);
644 _bitmaskOverrideIgnore = _queryQuirkMaskOfPropertyList(
"jogl.quirks.ignore", Override.IGNORE);
649 final int uniqueTest = _bitmaskOverrideForce & _bitmaskOverrideIgnore;
650 if( 0 != uniqueTest ) {
651 throw new InternalError(
"Override properties force 0x"+Integer.toHexString(_bitmaskOverrideForce)+
652 " and ignore 0x"+Integer.toHexString(_bitmaskOverrideIgnore)+
653 " have intersecting bits 0x"+Integer.toHexString(uniqueTest)+
" "+Integer.toBinaryString(uniqueTest));
656 private static int _queryQuirkMaskOfPropertyList(
final String propertyName,
final Override override) {
657 final String quirkNameList = PropertyAccess.getProperty(propertyName,
true);
658 if(
null == quirkNameList ) {
662 final String quirkNames[] = quirkNameList.split(
",");
663 for(
int i=0; i<quirkNames.length; i++) {
664 final String name = quirkNames[i].trim();
667 final int quirkBit = field.getInt(
null);
668 final Override preOverride =
getOverride(quirkBit);
669 if( Override.NONE != preOverride ) {
670 System.err.println(
"Warning: Quirk '"+name+
"' bit "+quirkBit+
" skipped for override "+override+
" mask, already set for override "+preOverride+
". Has been included in given property "+propertyName);
672 res |= 1 << quirkBit;
673 System.err.println(
"Info: Quirk '"+name+
"' bit "+quirkBit+
" has been added to Override."+override+
" mask as included in given property "+propertyName);
675 }
catch (
final NoSuchFieldException e) {
676 System.err.println(
"Warning: Failed to match given property "+propertyName+
"'s quirk '"+name+
"' with any supported quirk! "+e.getMessage());
677 }
catch (SecurityException | IllegalAccessException e) {
678 System.err.println(
"Warning: Failed to access given property "+propertyName+
"'s quirk '"+name+
"' bit value! "+e.getMessage());
684 private int _bitmask;
694 public final void addQuirk(
final int quirkBit)
throws IllegalArgumentException {
696 _bitmask |= 1 << quirkBit;
703 _bitmask |= quirks._bitmask;
717 public final boolean exist(
final int quirkBit)
throws IllegalArgumentException {
719 return 0 != ( ( 1 << quirkBit ) & ( ~_bitmaskOverrideIgnore & ( _bitmask | _bitmaskOverrideForce ) ) );
732 return null != quirks && quirks.exist(quirkBit);
735 public final StringBuilder
toString(StringBuilder sb) {
737 sb =
new StringBuilder();
743 if( 0 != ( ( 1 << i ) & ( _bitmask | _bitmaskOverrideForce ) ) ) {
744 if(!first) { sb.append(
", "); }
748 sb.append(
"(").append(override.name().toLowerCase()).append(
"d)");
766 public static void validateQuirk(
final int quirkBit)
throws IllegalArgumentException {
767 if( !( 0 <= quirkBit && quirkBit <
getCount() ) ) {
768 throw new IllegalArgumentException(
"Quirks must be in range [0.."+
getCount()+
"[, but quirk: "+quirkBit);
777 public static final String
toString(
final int quirkBit)
throws IllegalArgumentException {
779 return _names[quirkBit];
GLRendererQuirks contains information of known bugs of various GL renderer.
final boolean exist(final int quirkBit)
Method tests whether the given quirk exists.
static final String toString(final int quirkBit)
static final int NoOffscreenBitmap
No offscreen bitmap available, currently true for JOGL's OSX implementation.
static final int NoFBOSupport
No FBO support at all.
static final int GL4NeedsGL3Request
GL4 context needs to be requested via GL3 profile attribute.
static final int NoSetSwapInterval
Crashes application when trying to set EGL swap interval on Android 4.0.3 / Pandaboard ES / PowerVR S...
static void pushStickyDeviceQuirks(final AbstractGraphicsDevice device, final GLRendererQuirks dest)
Pushing the sticky AbstractGraphicsDevice's GLRendererQuirks to the given destination.
static final int GLSLNonCompliant
GLSL is not compliant or even not stable (crash)
static final int DontCloseX11Display
Closing X11 displays may cause JVM crashes or X11 errors with some buggy drivers while being used in ...
static GLRendererQuirks getStickyDeviceQuirks(final AbstractGraphicsDevice device)
Retrieval of sticky AbstractGraphicsDevice's GLRendererQuirks.
static final int NoDoubleBufferedBitmap
On Windows no double buffered bitmaps are guaranteed to be available.
static final int GLES3ViaEGLES2Config
Bug 925 - Accept an ES3 Context, if reported via GL-Version-String w/o EGLExt#EGL_OPENGL_ES3_BIT_KHR.
static final int NeedCurrCtx4ARBPixFmtQueries
Need current GL context when calling new ARB pixel format query functions, otherwise driver crashes t...
static boolean areSameStickyDevice(final AbstractGraphicsDevice device1, final AbstractGraphicsDevice device2)
Returns true if both devices have the same AbstractGraphicsDevice#getUniqueID(), otherwise false.
static final int NoFullFBOSupport
No full FBO support, i.e.
static final int NeedSharedObjectSync
Need GL objects (VBO, ..) to be synchronized when utilized concurrently from multiple threads via a s...
static void validateQuirk(final int quirkBit)
static final int NoSurfacelessCtx
No support for ES or desktop GL >= 3.0 current context without surface, i.e.
static final int NoMultiSamplingBuffers
No reliable MSAA / FSAA multi sampling available, i.e.
final StringBuilder toString(StringBuilder sb)
static final int getCount()
Return the number of known quirks, aka quirk bit count.
static final int SingletonEGLDisplayOnly
Bug 948 - NVIDIA 331.38 (Linux X11) EGL impl.
static boolean existStickyDeviceQuirk(final AbstractGraphicsDevice device, final int quirkBit)
Query of sticky AbstractGraphicsDevice's GLRendererQuirks.
final void addQuirk(final int quirkBit)
static void addStickyDeviceQuirks(final AbstractGraphicsDevice device, final GLRendererQuirks quirks)
Adding given quirks of sticky AbstractGraphicsDevice's GLRendererQuirks.
static final int GLFlushBeforeRelease
The OpenGL context needs a glFlush() before releasing it, otherwise driver may freeze:
static final int BuggyColorRenderbuffer
Buggy FBO color renderbuffer target, i.e.
static final int DontChooseFBConfigBestMatch
Don't use the ChooseFBConfig's best match, instead utilize the given GLCapabilitiesChooser or Default...
static boolean exist(final GLRendererQuirks quirks, final int quirkBit)
Convenient static method to call exist(int) on the given quirks with an added null check.
static final int NeedCurrCtx4ARBCreateContext
Need current GL context when calling new ARB CreateContext function, otherwise driver crashes the VM.
static final int NoARBCreateContext
No reliable ARB_create_context implementation, even if driver claims otherwise.
static void addStickyDeviceQuirk(final AbstractGraphicsDevice device, final int quirk)
Adding given quirk of sticky AbstractGraphicsDevice's GLRendererQuirks.
static final int No10BitColorCompOffscreen
On Mesa >= 18.0.0, glXChooseFBConfig selects better GLCapabilities FBConfig than actually supported b...
static final int NoPBufferWithAccum
No pbuffer supporting accumulation buffers available, even if driver claims otherwise.
static final Override getOverride(final int quirkBit)
static final int NoSetSwapIntervalPostRetarget
SIGSEGV on setSwapInterval() after changing the context's drawable w/ Mesa >= 8.0....
static final int GL3CompatNonCompliant
Non compliant OpenGL 3.1+ compatibility profile due to a buggy implementation not suitable for use.
static final int GLSharedContextBuggy
Buggy shared OpenGL context support within a multithreaded use-case, not suitable for stable usage.
static final int GLSLBuggyDiscard
GLSL discard command leads to undefined behavior or won't get compiled if being used.
final void addQuirks(final GLRendererQuirks quirks)
static final int NoDoubleBufferedPBuffer
Crashes XServer when using double buffered PBuffer with hardware GL_RENDERER on Mesa < 18....
Allow overriding any quirk settings via the two properties:
FORCE
Enforce the quirk, i.e.
IGNORE
Ignore the quirk, i.e.
A interface describing a graphics device in a toolkit-independent manner.
String getUniqueID()
Returns a unique ID object of this device using type, connection and unitID as it's key components.