From 3ce0aa6e36d9474ac3105cab491a60327860757d Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 29 Dec 2012 23:37:36 +0100 Subject: Fix Bug 658 (Mesa 9.0 3.1 Intel compat quirk, 3.1 core only) ; No PROFILE_ALIASING compat -> core ; Fix setGLFunctionAvailability(..) failure path @ profile query - Add GLRendererQuirks.GLNonCompliant, marking a GL context/profile non compliant. Currently: 'Mesa DRI Intel(R) Sandybridge Desktop' && 3.1 compat profile - Fix Bug 658 (Mesa 9.0 3.1 Intel compat quirk, 3.1 core only) Detect case using new GLRendererQuirks.GLNonCompliant in setGLFunctionAvailability() and return 'false'. - No PROFILE_ALIASING compat -> core Use true core GL profiles / context if available to ensure proper API behavior across platforms due to different functionality. E.g. don't use GL3bc if GL3 is requested. - Fix setGLFunctionAvailability(..) failure path @ profile query Destroy temp context & zero result to cont. iterating through GL versions. This missing cleanup lead to returning the faulty GL context handle and it's mapping/usage. --- .../junit/jogl/acore/TestGLMesaBug651NEWT.java | 222 +++++++++++++++++++++ .../junit/jogl/acore/TestGLMesaBug658NEWT.java | 200 +++++++++++++++++++ .../test/junit/jogl/acore/TestGLUnitsNEWT.java | 210 ------------------- 3 files changed, 422 insertions(+), 210 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLMesaBug651NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLMesaBug658NEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLUnitsNEWT.java (limited to 'src/test/com/jogamp') diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLMesaBug651NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLMesaBug651NEWT.java new file mode 100644 index 000000000..90f0c5414 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLMesaBug651NEWT.java @@ -0,0 +1,222 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.GLExtensions; +import com.jogamp.opengl.test.junit.util.UITestCase; + +import javax.media.opengl.GL; +import javax.media.opengl.GL2ES2; +import javax.media.opengl.GL2GL3; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.AfterClass; +import org.junit.Test; + +/** + * Some GL state values are broken w/ Mesa 9.0 w/ multiple different context. + *

+ * This bug lies within Mesa3D (any renderer) and is fixed in + * commit 8dc79ae7d73cf6711c2182ff9a5d37ef6c989d23. + *

+ *

+ * Mesa3D Version 9.0 still exposes this bug, + * where 9.0.1 has it fixed w/ above commit. + *

+ * + */ +public class TestGLMesaBug651NEWT extends UITestCase { + static int width, height; + + @BeforeClass + public static void initClass() { + width = 512; + height = 512; + } + + @AfterClass + public static void releaseClass() { + } + + class UnitTester implements GLEventListener { + @Override + public void init(GLAutoDrawable drawable) { + final GL gl = drawable.getGL(); + System.err.println("GL UnitTester"); + System.err.println(" GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR)); + System.err.println(" GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER)); + System.err.println(" GL_VERSION: " + gl.glGetString(GL.GL_VERSION)); + System.err.println(" GL GLSL: "+gl.hasGLSL()+", has-compiler: "+gl.isFunctionAvailable("glCompileShader")+", version "+(gl.hasGLSL() ? gl.glGetString(GL2ES2.GL_SHADING_LANGUAGE_VERSION) : "none")+", "+gl.getContext().getGLSLVersionNumber()); + System.err.println(" GL FBO: basic "+ gl.hasBasicFBOSupport()+", full "+gl.hasFullFBOSupport()); + System.err.println(" GL Profile: "+gl.getGLProfile()); + System.err.println(" GL Renderer Quirks:" + gl.getContext().getRendererQuirks().toString()); + System.err.println(" GL:" + gl + ", " + gl.getContext().getGLVersion()); + + final int _glerr = gl.glGetError(); // clear pre-error + System.err.println(" - pre GL-Error 0x"+Integer.toHexString(_glerr)); + + final int[] val = new int[1]; + final int[] glerr = new int[] { GL.GL_NO_ERROR, GL.GL_NO_ERROR, GL.GL_NO_ERROR, GL.GL_NO_ERROR, GL.GL_NO_ERROR }; + int i=0; + + val[0]=0; + gl.glGetIntegerv(GL.GL_MAX_TEXTURE_SIZE, val, 0); + System.out.println(" - GL_MAX_TEXTURE_SIZE: " + val[0]); + glerr[i] = gl.glGetError(); // clear pre-error + System.err.println(" - GL-Error 0x"+Integer.toHexString(glerr[i])); + i++; + + val[0]=0; + gl.glGetIntegerv(GL2ES2.GL_ACTIVE_TEXTURE, val, 0); + System.out.println(" - GL_ACTIVE_TEXTURE: " + val[0]); + glerr[i] = gl.glGetError(); // clear pre-error + System.err.println(" - GL-Error 0x"+Integer.toHexString(glerr[i])); + i++; + + if(gl.isGL2ES2()) { + val[0]=0; + gl.glGetIntegerv(GL2ES2.GL_MAX_TEXTURE_IMAGE_UNITS, val, 0); + System.out.println(" - GL_MAX_TEXTURE_IMAGE_UNITS: " + val[0]); + glerr[i] = gl.glGetError(); // clear pre-error + System.err.println(" - GL-Error 0x"+Integer.toHexString(glerr[i])); + } + i++; + + if( gl.hasFullFBOSupport() || gl.isExtensionAvailable(GLExtensions.NV_fbo_color_attachments) ) { + val[0]=0; + gl.glGetIntegerv(GL2ES2.GL_MAX_COLOR_ATTACHMENTS, val, 0); + System.out.println(" - GL_MAX_COLOR_ATTACHMENTS: " + val[0]); + glerr[i] = gl.glGetError(); // clear pre-error + System.err.println(" - GL-Error 0x"+Integer.toHexString(glerr[i])); + } + i++; + + if( gl.hasFullFBOSupport() ) { + val[0]=0; + gl.glGetIntegerv(GL2GL3.GL_MAX_SAMPLES, val, 0); + System.out.println(" - GL_MAX_SAMPLES: " + val[0]); + glerr[i] = gl.glGetError(); // clear pre-error + System.err.println(" - GL-Error 0x"+Integer.toHexString(glerr[i])); + } + i++; + + boolean ok = true; + String res=""; + for(int j=0; j= 9.0 seems to be broken. + *

+ * This bug lies within Mesa3D (any renderer) and is fixed in + * commit ??? (not yet). + *

+ *

+ * Mesa3D Version 9.0 still exposes this bug, + * where 9.?.? has it fixed w/ above commit. + *

+ * + */ +public class TestGLMesaBug658NEWT extends UITestCase { + + @Test + public void test00ShowAvailProfiles() { + System.err.println(JoglVersion.getDefaultOpenGLInfo(null, null, false).toString()); + } + + @Test + public void test10GL2PolygonModeFailure() { + testGLNPolygonModeFailureImpl(GLProfile.GL2); + } + + @Test + public void test11GL3bcPolygonModeFailure() { + testGLNPolygonModeFailureImpl(GLProfile.GL3bc); + } + + @Test + public void test12GL3PolygonModeFailure() { + testGLNPolygonModeFailureImpl(GLProfile.GL3); + } + + private void testGLNPolygonModeFailureImpl(String profile) { + if(!GLProfile.isAvailable(profile)) { System.err.println(profile+" n/a"); return; } + + final GLProfile pro = GLProfile.get(profile); + final GLCapabilities caps = new GLCapabilities(pro); + final GLWindow window = GLWindow.create(caps); + + window.setSize(640, 480); + window.addGLEventListener(new GLEventListener() { + public void reshape( + final GLAutoDrawable drawable, + final int x, + final int y, + final int width, + final int height) + { + // Nothing. + } + + public void init( + final GLAutoDrawable drawable) + { + final GLContext context = drawable.getContext(); + System.err.println("CTX: "+context.getGLVersion()); + + final GL2GL3 gl = drawable.getGL().getGL2GL3(); + System.err.println("GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR)); + System.err.println("GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER)); + System.err.println("GL_VERSION: " + gl.glGetString(GL.GL_VERSION)); + System.err.println("GL Renderer Quirks:" + gl.getContext().getRendererQuirks().toString()); + + if( gl.isGL2() || gl.isGLES2() ) { // compatibility profile || ES2 + gl.glPolygonMode(GL.GL_FRONT, GL2GL3.GL_FILL); + } else { + gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL2GL3.GL_FILL); + } + + final int e = gl.glGetError(); + Assert.assertTrue(e == GL.GL_NO_ERROR); // // FIXME On Mesa 9.0.1 w/ GL 3.1 -> GL.GL_INVALID_OPERATION ? + } + + public void dispose( + final GLAutoDrawable drawable) + { + // Nothing. + } + + public void display( + final GLAutoDrawable drawable) + { + // Nothing. + } + }); + + try { + window.setVisible(true); + } finally { + window.destroy(); + } + } + + @Test + public void test20GL2BindArrayAttributeFails() { + testGLNBindArrayAttributeFailsImpl(GLProfile.GL2); + } + + @Test + public void test21GL3bcBindArrayAttributeFails() { + testGLNBindArrayAttributeFailsImpl(GLProfile.GL3bc); + } + + @Test + public void test22GL3BindArrayAttributeFails() { + testGLNBindArrayAttributeFailsImpl(GLProfile.GL3); + } + + private void testGLNBindArrayAttributeFailsImpl(String profile) { + if(!GLProfile.isAvailable(profile)) { System.err.println(profile+ " n/a"); return; } + + final GLProfile pro = GLProfile.get(profile); + final GLCapabilities caps = new GLCapabilities(pro); + final GLWindow window = GLWindow.create(caps); + + window.setSize(640, 480); + window.addGLEventListener(new GLEventListener() { + public void reshape( + final GLAutoDrawable drawable, + final int x, + final int y, + final int width, + final int height) + { + // Nothing. + } + + public void init( + final GLAutoDrawable drawable) + { + final GLContext context = drawable.getContext(); + System.err.println("CTX: "+context.getGLVersion()); + + final GL2GL3 gl = drawable.getGL().getGL2GL3(); + System.err.println("GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR)); + System.err.println("GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER)); + System.err.println("GL_VERSION: " + gl.glGetString(GL.GL_VERSION)); + System.err.println("GL Renderer Quirks:" + gl.getContext().getRendererQuirks().toString()); + + final int[] name = new int[] { 0 }; + gl.glGenBuffers(1, name, 0); + Assert.assertTrue(gl.glGetError() == GL.GL_NO_ERROR); + + gl.glBindBuffer(GL.GL_ARRAY_BUFFER, name[0]); + Assert.assertTrue(gl.glGetError() == 0); + gl.glBufferData(GL.GL_ARRAY_BUFFER, 4 * 32, null, GL.GL_STATIC_DRAW); + Assert.assertTrue(gl.glGetError() == 0); + + Assert.assertTrue(gl.glGetBoundBuffer(GL.GL_ARRAY_BUFFER) == name[0]); + gl.glEnableVertexAttribArray(1); + Assert.assertTrue(gl.glGetError() == GL.GL_NO_ERROR); + gl.glVertexAttribPointer(1, 4, GL.GL_FLOAT, false, 0, 0L); + Assert.assertTrue(gl.glGetError() == GL.GL_NO_ERROR); // FIXME On Mesa 9.0.1 w/ GL 3.1 -> GL.GL_INVALID_OPERATION ? + } + + public void dispose( + final GLAutoDrawable drawable) + { + // Nothing. + } + + public void display( + final GLAutoDrawable drawable) + { + // Nothing. + } + }); + + try { + window.setVisible(true); + } finally { + window.destroy(); + } + } + + public static void main(String args[]) { + org.junit.runner.JUnitCore.main(TestGLMesaBug658NEWT.class.getName()); + } + +} + diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLUnitsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLUnitsNEWT.java deleted file mode 100644 index c699e6304..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLUnitsNEWT.java +++ /dev/null @@ -1,210 +0,0 @@ -/** - * Copyright 2012 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.jogl.acore; - -import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.opengl.GLExtensions; -import com.jogamp.opengl.test.junit.util.UITestCase; - -import javax.media.opengl.GL; -import javax.media.opengl.GL2ES2; -import javax.media.opengl.GL2GL3; -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLEventListener; -import javax.media.opengl.GLProfile; - -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.AfterClass; -import org.junit.Test; - -public class TestGLUnitsNEWT extends UITestCase { - static int width, height; - - @BeforeClass - public static void initClass() { - width = 512; - height = 512; - } - - @AfterClass - public static void releaseClass() { - } - - class UnitTester implements GLEventListener { - @Override - public void init(GLAutoDrawable drawable) { - final GL gl = drawable.getGL(); - System.err.println("GL UnitTester"); - System.err.println(" GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR)); - System.err.println(" GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER)); - System.err.println(" GL_VERSION: " + gl.glGetString(GL.GL_VERSION)); - System.err.println(" GL GLSL: "+gl.hasGLSL()+", has-compiler: "+gl.isFunctionAvailable("glCompileShader")+", version "+(gl.hasGLSL() ? gl.glGetString(GL2ES2.GL_SHADING_LANGUAGE_VERSION) : "none")+", "+gl.getContext().getGLSLVersionNumber()); - System.err.println(" GL FBO: basic "+ gl.hasBasicFBOSupport()+", full "+gl.hasFullFBOSupport()); - System.err.println(" GL Profile: "+gl.getGLProfile()); - System.err.println(" GL Renderer Quirks:" + gl.getContext().getRendererQuirks().toString()); - System.err.println(" GL:" + gl + ", " + gl.getContext().getGLVersion()); - - final int _glerr = gl.glGetError(); // clear pre-error - System.err.println(" - pre GL-Error 0x"+Integer.toHexString(_glerr)); - - final int[] val = new int[1]; - final int[] glerr = new int[] { GL.GL_NO_ERROR, GL.GL_NO_ERROR, GL.GL_NO_ERROR, GL.GL_NO_ERROR, GL.GL_NO_ERROR }; - int i=0; - - val[0]=0; - gl.glGetIntegerv(GL.GL_MAX_TEXTURE_SIZE, val, 0); - System.out.println(" - GL_MAX_TEXTURE_SIZE: " + val[0]); - glerr[i] = gl.glGetError(); // clear pre-error - System.err.println(" - GL-Error 0x"+Integer.toHexString(glerr[i])); - i++; - - val[0]=0; - gl.glGetIntegerv(GL2ES2.GL_ACTIVE_TEXTURE, val, 0); - System.out.println(" - GL_ACTIVE_TEXTURE: " + val[0]); - glerr[i] = gl.glGetError(); // clear pre-error - System.err.println(" - GL-Error 0x"+Integer.toHexString(glerr[i])); - i++; - - if(gl.isGL2ES2()) { - val[0]=0; - gl.glGetIntegerv(GL2ES2.GL_MAX_TEXTURE_IMAGE_UNITS, val, 0); - System.out.println(" - GL_MAX_TEXTURE_IMAGE_UNITS: " + val[0]); - glerr[i] = gl.glGetError(); // clear pre-error - System.err.println(" - GL-Error 0x"+Integer.toHexString(glerr[i])); - } - i++; - - if( gl.hasFullFBOSupport() || gl.isExtensionAvailable(GLExtensions.NV_fbo_color_attachments) ) { - val[0]=0; - gl.glGetIntegerv(GL2ES2.GL_MAX_COLOR_ATTACHMENTS, val, 0); - System.out.println(" - GL_MAX_COLOR_ATTACHMENTS: " + val[0]); - glerr[i] = gl.glGetError(); // clear pre-error - System.err.println(" - GL-Error 0x"+Integer.toHexString(glerr[i])); - } - i++; - - if( gl.hasFullFBOSupport() ) { - val[0]=0; - gl.glGetIntegerv(GL2GL3.GL_MAX_SAMPLES, val, 0); - System.out.println(" - GL_MAX_SAMPLES: " + val[0]); - glerr[i] = gl.glGetError(); // clear pre-error - System.err.println(" - GL-Error 0x"+Integer.toHexString(glerr[i])); - } - i++; - - boolean ok = true; - String res=""; - for(int j=0; j