diff options
author | Sven Gothel <[email protected]> | 2019-09-07 02:20:55 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2019-09-07 02:20:55 +0200 |
commit | 56a9f30fde429663514c6d5c810af2c43cb7ebf3 (patch) | |
tree | 0191fde8771314004642d85b2d5736d50d0200fe /src/jogl/classes/jogamp/opengl/egl | |
parent | 2ab629205c88978891271dd51cfa2a1669a6eec2 (diff) |
Bug 1391 Bug 1392: Implement GLRendererQuirks DontChooseFBConfigBestMatch and No10BitColorCompOffscreen
Further enhance unit tests TestGLProfile03NEWTOffscreen,
i.e. test all meta profile types on all offscreen drawable types (fbo, pbuffer and bitmap).
Align unit test name numbers of TestGLProfile01NEWT to TestGLProfile03NEWTOffscreen.
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/egl')
-rw-r--r-- | src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java | 88 |
1 files changed, 52 insertions, 36 deletions
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java index 5505fed52..98d16a0d2 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java @@ -43,13 +43,16 @@ import com.jogamp.nativewindow.AbstractGraphicsConfiguration; import com.jogamp.nativewindow.AbstractGraphicsDevice; import com.jogamp.nativewindow.AbstractGraphicsScreen; import com.jogamp.nativewindow.CapabilitiesChooser; +import com.jogamp.nativewindow.CapabilitiesFilter; import com.jogamp.nativewindow.CapabilitiesImmutable; import com.jogamp.nativewindow.GraphicsConfigurationFactory; import com.jogamp.nativewindow.NativeWindowFactory; import com.jogamp.nativewindow.VisualIDHolder; +import com.jogamp.nativewindow.CapabilitiesFilter.RemovalCriteria; import com.jogamp.nativewindow.VisualIDHolder.VIDType; import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLCapabilitiesChooser; +import com.jogamp.opengl.GLCapabilitiesFilter; import com.jogamp.opengl.GLCapabilitiesImmutable; import com.jogamp.opengl.GLContext; import com.jogamp.opengl.GLDrawableFactory; @@ -331,8 +334,9 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact final int nativeVisualID, final boolean forceTransparentFlag) { final long eglDisplay = device.getHandle(); final GLProfile glp = capsChosen.getGLProfile(); + final GLRendererQuirks glrq = GLDrawableFactory.getEGLFactory().getRendererQuirks(device, glp); final int winattrmask = GLGraphicsConfigurationUtil.getExclusiveWinAttributeBits(capsChosen); - List<GLCapabilitiesImmutable> availableCaps = null; + ArrayList<GLCapabilitiesImmutable> availableCaps = null; int recommendedIndex = -1; final IntBuffer numConfigs = Buffers.newDirectIntBuffer(1); @@ -375,25 +379,33 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact } hasEGLChosenCaps = false; } - final boolean useRecommendedIndex = hasEGLChosenCaps && !forceTransparentFlag && capsChosen.isBackgroundOpaque(); // only use recommended idx if not translucent - final boolean skipCapsChooser = null == chooser && useRecommendedIndex; // fast path: skip choosing if using recommended idx and null chooser is used + final boolean isPBufferOrBitmap = capsChosen.isBitmap() || capsChosen.isPBuffer(); + final boolean dontChooseFBConfigBestMatch = GLRendererQuirks.exist(glrq, GLRendererQuirks.DontChooseFBConfigBestMatch) || + ( isPBufferOrBitmap && GLRendererQuirks.exist(glrq, GLRendererQuirks.No10BitColorCompOffscreen) ); + final boolean useRecommendedIndex = !dontChooseFBConfigBestMatch && + hasEGLChosenCaps && !forceTransparentFlag && capsChosen.isBackgroundOpaque(); + final boolean shallSkipCapsChooser = null == chooser && useRecommendedIndex; if( hasEGLChosenCaps ) { - availableCaps = eglConfigs2GLCaps(device, glp, configs, numConfigs.get(0), winattrmask, forceTransparentFlag, skipCapsChooser /* onlyFirsValid */); + availableCaps = eglConfigs2GLCaps(device, glp, configs, numConfigs.get(0), winattrmask, forceTransparentFlag, shallSkipCapsChooser /* onlyFirsValid */); if(availableCaps.size() > 0) { - final long recommendedEGLConfig = configs.get(0); - recommendedIndex = 0; + if( useRecommendedIndex ) { + recommendedIndex = 0; + } if (DEBUG) { + final long recommendedEGLConfig = configs.get(0); System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #1 eglChooseConfig: recommended fbcfg " + toHexString(recommendedEGLConfig) + ", idx " + recommendedIndex); - System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #1 useRecommendedIndex "+useRecommendedIndex+", skipCapsChooser "+skipCapsChooser); - System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #1 fbcfg caps " + availableCaps.get(recommendedIndex)); + System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #1 useRecommendedIndex "+useRecommendedIndex+", shallSkipCapsChooser "+shallSkipCapsChooser); + if( 0 <= recommendedIndex ) { + System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #1 fbcfg recommended caps " + availableCaps.get(recommendedIndex)); + } } } else if (DEBUG) { System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #1 eglChooseConfig: no caps for recommended fbcfg " + toHexString(configs.get(0))); - System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #1 useRecommendedIndex "+useRecommendedIndex+", skipCapsChooser "+skipCapsChooser); + System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #1 useRecommendedIndex "+useRecommendedIndex+", shallSkipCapsChooser "+shallSkipCapsChooser); } } else if (DEBUG) { System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #1 eglChooseConfig: no configs"); - System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #1 useRecommendedIndex "+useRecommendedIndex+", skipCapsChooser "+skipCapsChooser); + System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #1 useRecommendedIndex "+useRecommendedIndex+", shallSkipCapsChooser "+shallSkipCapsChooser); } // 2nd choice: get all GLCapabilities available, no preferred recommendedIndex available @@ -419,43 +431,47 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact return null; } + final boolean skipCapsChooser = shallSkipCapsChooser && 0 <= recommendedIndex; if(DEBUG) { System.err.println("EGLGraphicsConfiguration.eglChooseConfig: got configs: "+availableCaps.size()); for(int i=0; i<availableCaps.size(); i++) { System.err.println(i+": "+availableCaps.get(i)); } } - - if( VisualIDHolder.VID_UNDEFINED != nativeVisualID ) { // implies !hasEGLChosenCaps - final List<GLCapabilitiesImmutable> removedCaps = new ArrayList<GLCapabilitiesImmutable>(); - for(int i=0; i<availableCaps.size(); ) { - final GLCapabilitiesImmutable aCap = availableCaps.get(i); - if(aCap.getVisualID(VIDType.NATIVE) != nativeVisualID) { - if(DEBUG) { System.err.println("Remove["+i+"] (mismatch VisualID): "+aCap); } - removedCaps.add(availableCaps.remove(i)); - } else if( 0 == aCap.getDepthBits() && 0 < capsChosen.getDepthBits() ) { - // Hack for HiSilicon/Vivante/Immersion.16 Renderer .. - if(DEBUG) { System.err.println("Remove["+i+"] (mismatch depth-bits): "+aCap); } - removedCaps.add(availableCaps.remove(i)); - } else { - i++; - } + // Filter availableCaps + { + final ArrayList<RemovalCriteria<GLCapabilitiesImmutable>> criteria = new ArrayList<RemovalCriteria<GLCapabilitiesImmutable>>(); + if( !skipCapsChooser && isPBufferOrBitmap && GLRendererQuirks.exist(glrq, GLRendererQuirks.No10BitColorCompOffscreen) ) { + criteria.add(new CapabilitiesFilter.RemoveMoreColorCompBits<GLCapabilitiesImmutable>(8)); } - if(0==availableCaps.size()) { - availableCaps = removedCaps; - if(DEBUG) { - System.err.println("EGLGraphicsConfiguration.eglChooseConfig: post filter nativeVisualID "+toHexString(nativeVisualID)+" no config found, revert to all"); + if( VisualIDHolder.VID_UNDEFINED != nativeVisualID) { + criteria.add(new CapabilitiesFilter.RemoveUnmatchedNativeVisualID<GLCapabilitiesImmutable>(nativeVisualID)); + } + if( 0 < capsChosen.getDepthBits() ) { + // Hack for HiSilicon/Vivante/Immersion.16 Renderer .. + criteria.add(new GLCapabilitiesFilter.RemoveLessDepthBits<GLCapabilitiesImmutable>(1)); + } + if( criteria.size() > 0 ) { + final ArrayList<GLCapabilitiesImmutable> removedCaps = CapabilitiesFilter.removeMatching(availableCaps, criteria); + if( removedCaps.size() > 0 ) { + if(DEBUG) { + System.err.println("EGLGraphicsConfiguration.eglChooseConfig: filtered configs: "+availableCaps.size()); + for(int i=0; i<availableCaps.size(); i++) { + System.err.println(i+": "+availableCaps.get(i)); + } + } } - } else if(DEBUG) { - System.err.println("EGLGraphicsConfiguration.eglChooseConfig: post filter nativeVisualID "+toHexString(nativeVisualID)+" got configs: "+availableCaps.size()); - for(int i=0; i<availableCaps.size(); i++) { - System.err.println(i+": "+availableCaps.get(i)); + if(0==availableCaps.size()) { + availableCaps = removedCaps; + if(DEBUG) { + System.err.println("EGLGraphicsConfiguration.eglChooseConfig: post filter visualID "+toHexString(nativeVisualID )+" no config found, revert to all"); + } } } } final int chosenIndex; - if( skipCapsChooser && 0 <= recommendedIndex ) { + if( skipCapsChooser ) { chosenIndex = recommendedIndex; } else { chosenIndex = chooseCapabilities(chooser, capsChosen, availableCaps, recommendedIndex); @@ -474,9 +490,9 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact return res; } - static List<GLCapabilitiesImmutable> eglConfigs2GLCaps(final EGLGraphicsDevice device, final GLProfile glp, final PointerBuffer configs, final int num, final int winattrmask, final boolean forceTransparentFlag, final boolean onlyFirstValid) { + static ArrayList<GLCapabilitiesImmutable> eglConfigs2GLCaps(final EGLGraphicsDevice device, final GLProfile glp, final PointerBuffer configs, final int num, final int winattrmask, final boolean forceTransparentFlag, final boolean onlyFirstValid) { final GLRendererQuirks defaultQuirks = GLRendererQuirks.getStickyDeviceQuirks( GLDrawableFactory.getEGLFactory().getDefaultDevice() ); - final List<GLCapabilitiesImmutable> bucket = new ArrayList<GLCapabilitiesImmutable>(num); + final ArrayList<GLCapabilitiesImmutable> bucket = new ArrayList<GLCapabilitiesImmutable>(num); for(int i=0; i<num; i++) { final GLCapabilitiesImmutable caps = EGLGraphicsConfiguration.EGLConfig2Capabilities(defaultQuirks, device, glp, configs.get(i), winattrmask, forceTransparentFlag); if(null != caps) { |