From 2e1484f4c25605c6dc0307f12f3e4e434c429a37 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 31 Jul 2014 00:54:24 +0200 Subject: Bug 830 - Refine Heuristics for to query whether GLDrawableUtil.swapGLContextAndAllGLEventListener is safe: Add Accumulator Buffer bits --- .../com/jogamp/opengl/util/GLDrawableUtil.java | 39 ++++++++++++++++------ 1 file changed, 28 insertions(+), 11 deletions(-) (limited to 'src/jogl/classes/com/jogamp') diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java b/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java index 8473a6e27..956693c4a 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java @@ -28,7 +28,6 @@ package com.jogamp.opengl.util; import javax.media.nativewindow.AbstractGraphicsDevice; - import javax.media.nativewindow.NativeSurface; import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLAutoDrawable; @@ -158,23 +157,41 @@ public class GLDrawableUtil { * * Otherwise method returns true *

- *

+ *

      * [1] See Bug 830: swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX
-     * 

+ * On NVidia GPUs w/ it's proprietary driver context swapping does not work if MSAA is involved + * and when swapping on- to offscreen. + *
+ *
+     * [2] On AMD GPUs w/ it's proprietary driver, requesting an accumulator buffer leads to receive an accumulator buffer configuration,
+     *     for which context swapping does not work when swapping on- to offscreen and vice-versa, i.e. cannot make context current.
+     *     With AMD and Mesa drivers we only receive an accumulator buffer if requested,
+     *     where on NVidia drivers all configurations contain the accumulator buffer.
+     *     On both drivers, NVidia and Mesa, context swapping with accumulator buffer works.
+     * 
+ * @param requestedCaps requested {@link GLCapabilitiesImmutable} which are intended for usage by both {@link GLAutoDrawable}s A and B + * @param chosenCapsA chosen {@link GLCapabilitiesImmutable} of {@link GLAutoDrawable} A, which {@link GLContext} is intended to be swapped + * @param chosenCapsB chosen {@link GLCapabilitiesImmutable} of {@link GLAutoDrawable} B, which {@link GLContext} is intended to be swapped * @see #swapGLContext(GLAutoDrawable, GLAutoDrawable) * @see #swapGLContextAndAllGLEventListener(GLAutoDrawable, GLAutoDrawable) */ - public static boolean isSwapGLContextSafe(final GLCapabilitiesImmutable a, final GLCapabilitiesImmutable b) { - if( ( a.isOnscreen() && !b.isOnscreen() || !a.isOnscreen() && b.isOnscreen() ) && // switching between on- and offscreen + public static boolean isSwapGLContextSafe(final GLCapabilitiesImmutable requestedCaps, final GLCapabilitiesImmutable chosenCapsA, final GLCapabilitiesImmutable chosenCapsB) { + final boolean usingAccumulatorBuffer = requestedCaps.getAccumAlphaBits() > 0 || + requestedCaps.getAccumRedBits() > 0 || + requestedCaps.getAccumGreenBits() > 0 || + requestedCaps.getAccumBlueBits() > 0; + if( ( chosenCapsA.isOnscreen() && !chosenCapsB.isOnscreen() || !chosenCapsA.isOnscreen() && chosenCapsB.isOnscreen() ) && // switching between on- and offscreen ( - ( a.getSampleBuffers() || b.getSampleBuffers() ) || // MSAA involved - ( a.getStereo() || b.getStereo() ) // Stereo involved + ( chosenCapsA.getSampleBuffers() || chosenCapsB.getSampleBuffers() ) || // MSAA involved + ( chosenCapsA.getStereo() || chosenCapsB.getStereo() ) || // Stereo involved + usingAccumulatorBuffer // Using accumulator buffer ) ) { @@ -207,7 +224,7 @@ public class GLDrawableUtil { * e.g. via {@link Threading#invokeOnOpenGLThread(boolean, Runnable)}. *

* @throws GLException if the {@link AbstractGraphicsDevice} are incompatible w/ each other. - * @see #isSwapGLContextSafe(GLCapabilitiesImmutable, GLCapabilitiesImmutable) + * @see #isSwapGLContextSafe(GLCapabilitiesImmutable, GLCapabilitiesImmutable, GLCapabilitiesImmutable) */ public static final void swapGLContextAndAllGLEventListener(final GLAutoDrawable a, final GLAutoDrawable b) { final GLEventListenerState gllsA = GLEventListenerState.moveFrom(a, true); @@ -249,7 +266,7 @@ public class GLDrawableUtil { *

* @param a * @param b - * @see #isSwapGLContextSafe(GLCapabilitiesImmutable, GLCapabilitiesImmutable) + * @see #isSwapGLContextSafe(GLCapabilitiesImmutable, GLCapabilitiesImmutable, GLCapabilitiesImmutable) */ public static final void swapGLContext(final GLAutoDrawable a, final GLAutoDrawable b) { final GLAnimatorControl aAnim = a.getAnimator(); -- cgit v1.2.3