diff options
author | Sven Gothel <[email protected]> | 2015-08-30 04:55:12 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2015-08-30 04:55:12 +0200 |
commit | 2db11ad80582af8715071b47b5331b79001d511c (patch) | |
tree | b21c5a684068b20b8e7bcaea890182b4f9e06f10 /src | |
parent | 3ac457a3a9074a70bf428bb6a5674b8f70d268b1 (diff) |
Bug 1207 - GLDebugMessageHandler: Support GL_KHR_debug for Desktop and ES profile
GL_KHR_debug <https://www.opengl.org/registry/specs/KHR/debug.txt>
GL_KHR_debug shall be favorized before
- GL_ARB_debug_output
- GL_AMD_debug_output
Allow GL_KHR_debug for GL2GL3 and GL2ES2 profiles,
i.e. including ES profiles: GLES2, GLES3.
GL_ARB_debug_output and GL_AMD_debug_output
are only allowed for desktop GL2GL3 profiles.
Diffstat (limited to 'src')
6 files changed, 200 insertions, 54 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/GLExtensions.java b/src/jogl/classes/com/jogamp/opengl/GLExtensions.java index 1bf8071ea..dc1a4e010 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLExtensions.java +++ b/src/jogl/classes/com/jogamp/opengl/GLExtensions.java @@ -36,6 +36,7 @@ public class GLExtensions { public static final String VERSION_1_5 = "GL_VERSION_1_5"; public static final String VERSION_2_0 = "GL_VERSION_2_0"; + public static final String GL_KHR_debug = "GL_KHR_debug"; public static final String ARB_debug_output = "GL_ARB_debug_output"; public static final String AMD_debug_output = "GL_AMD_debug_output"; diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 45cfc6bcc..6e904d0ed 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -693,7 +693,7 @@ public abstract class GLContextImpl extends GLContext { // throws an GLException if not // FIXME: drawable.getGLProfile().verifyEquality(gl.getGLProfile()); - glDebugHandler.init( isGL2GL3() && isGLDebugEnabled() ); + glDebugHandler.init( isGLDebugEnabled() ); if(DEBUG_GL) { setGL( GLPipelineFactory.create("com.jogamp.opengl.Debug", null, gl, null) ); @@ -2820,8 +2820,8 @@ public abstract class GLContextImpl extends GLContext { @Override public final void glDebugMessageControl(final int source, final int type, final int severity, final int count, final IntBuffer ids, final boolean enabled) { - if(glDebugHandler.isExtensionARB()) { - gl.getGL2GL3().glDebugMessageControl(source, type, severity, count, ids, enabled); + if(glDebugHandler.isExtensionKHRARB()) { + gl.getGL2ES2().glDebugMessageControl(source, type, severity, count, ids, enabled); } else if(glDebugHandler.isExtensionAMD()) { gl.getGL2GL3().glDebugMessageEnableAMD(GLDebugMessage.translateARB2AMDCategory(source, type), severity, count, ids, enabled); } @@ -2829,8 +2829,8 @@ public abstract class GLContextImpl extends GLContext { @Override public final void glDebugMessageControl(final int source, final int type, final int severity, final int count, final int[] ids, final int ids_offset, final boolean enabled) { - if(glDebugHandler.isExtensionARB()) { - gl.getGL2GL3().glDebugMessageControl(source, type, severity, count, ids, ids_offset, enabled); + if(glDebugHandler.isExtensionKHRARB()) { + gl.getGL2ES2().glDebugMessageControl(source, type, severity, count, ids, ids_offset, enabled); } else if(glDebugHandler.isExtensionAMD()) { gl.getGL2GL3().glDebugMessageEnableAMD(GLDebugMessage.translateARB2AMDCategory(source, type), severity, count, ids, ids_offset, enabled); } @@ -2839,8 +2839,8 @@ public abstract class GLContextImpl extends GLContext { @Override public final void glDebugMessageInsert(final int source, final int type, final int id, final int severity, final String buf) { final int len = (null != buf) ? buf.length() : 0; - if(glDebugHandler.isExtensionARB()) { - gl.getGL2GL3().glDebugMessageInsert(source, type, id, severity, len, buf); + if(glDebugHandler.isExtensionKHRARB()) { + gl.getGL2ES2().glDebugMessageInsert(source, type, id, severity, len, buf); } else if(glDebugHandler.isExtensionAMD()) { gl.getGL2GL3().glDebugMessageInsertAMD(GLDebugMessage.translateARB2AMDCategory(source, type), severity, id, len, buf); } diff --git a/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java b/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java index cd31d02fd..fb4529da4 100644 --- a/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java +++ b/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java @@ -61,8 +61,9 @@ import com.jogamp.opengl.GLExtensions; public class GLDebugMessageHandler { private static final boolean DEBUG = Debug.debug("GLDebugMessageHandler"); - private static final int EXT_ARB = 1; - private static final int EXT_AMD = 2; + private static final int EXT_KHR = 1; + private static final int EXT_ARB = 2; + private static final int EXT_AMD = 3; static { if ( !initIDs0() ) { @@ -75,6 +76,7 @@ public class GLDebugMessageHandler { // licefycle: init - EOL private String extName; + private String extSuffix; private int extType; private long glDebugMessageCallbackProcAddress; private boolean extAvailable; @@ -92,6 +94,7 @@ public class GLDebugMessageHandler { this.listenerImpl = new ListenerSyncedImplStub<GLDebugListener>(); this.glDebugMessageCallbackProcAddress = 0; this.extName = null; + this.extSuffix = null; this.extType = 0; this.extAvailable = false; this.handle = 0; @@ -143,43 +146,68 @@ public class GLDebugMessageHandler { } return; } - if( ctx.isExtensionAvailable(GLExtensions.ARB_debug_output) ) { + if( ctx.isExtensionAvailable(GLExtensions.GL_KHR_debug) ) { + extName = GLExtensions.GL_KHR_debug; + extSuffix = ctx.isGLES() ? "KHR" : ""; // See SPEC! + extType = EXT_KHR; + } else if( ctx.isExtensionAvailable(GLExtensions.ARB_debug_output) ) { extName = GLExtensions.ARB_debug_output; + extSuffix = "ARB"; extType = EXT_ARB; } else if( ctx.isExtensionAvailable(GLExtensions.AMD_debug_output) ) { extName = GLExtensions.AMD_debug_output; + extSuffix = "AMD"; extType = EXT_AMD; } - if(DEBUG) { - System.err.println("GLDebugMessageHandler: Using extension: <"+extName+">"); + + // Validate GL Profile, just to be sure + switch(extType) { + case EXT_KHR: + if( !ctx.isGL2ES2() ) { + if(DEBUG) { + System.err.println("Non GL2ES2 context not supported, has "+ctx.getGLVersion()); + } + extType = 0; + } + break; + case EXT_ARB: + // fall through intended + case EXT_AMD: + if( !ctx.isGL2GL3() ) { + if(DEBUG) { + System.err.println("Non GL2GL3 context not supported, has "+ctx.getGLVersion()); + } + extType = 0; + } + break; } if(0 == extType) { + extName = null; + extSuffix = null; if(DEBUG) { System.err.println("GLDebugMessageHandler: No extension available! "+ctx.getGLVersion()); System.err.println("GL_EXTENSIONS "+ctx.getGLExtensionCount()); System.err.println(ctx.getGLExtensionsString()); } return; + } else if(DEBUG) { + System.err.println("GLDebugMessageHandler: Using extension: <"+extName+"> with suffix <"+extSuffix+">"); } final ProcAddressTable procAddressTable = ctx.getGLProcAddressTable(); - if( !ctx.isGLES1() && !ctx.isGLES2() ) { - switch(extType) { - case EXT_ARB: - glDebugMessageCallbackProcAddress = getAddressFor(procAddressTable, "glDebugMessageCallbackARB"); - break; - case EXT_AMD: - glDebugMessageCallbackProcAddress = getAddressFor(procAddressTable, "glDebugMessageCallbackAMD"); - break; - } - } else { - glDebugMessageCallbackProcAddress = 0; - if(DEBUG) { - System.err.println("Non desktop context not supported"); - } + switch(extType) { + case EXT_KHR: + glDebugMessageCallbackProcAddress = getAddressFor(procAddressTable, "glDebugMessageCallback"+extSuffix); + break; + case EXT_ARB: + glDebugMessageCallbackProcAddress = getAddressFor(procAddressTable, "glDebugMessageCallback"+extSuffix); + break; + case EXT_AMD: + glDebugMessageCallbackProcAddress = getAddressFor(procAddressTable, "glDebugMessageCallback"+extSuffix); + break; } - extAvailable = 0 < extType && null != extName && 0 != glDebugMessageCallbackProcAddress; + extAvailable = 0 < extType && null != extName && null != extSuffix && 0 != glDebugMessageCallbackProcAddress; if(DEBUG) { System.err.println("GLDebugMessageHandler: extAvailable: "+extAvailable+", glDebugMessageCallback* : 0x"+Long.toHexString(glDebugMessageCallbackProcAddress)); @@ -203,12 +231,20 @@ public class GLDebugMessageHandler { return extName; } + public final boolean isExtensionKHRARB() { + return EXT_KHR == extType || EXT_ARB == extType; + } + + public final boolean isExtensionKHR() { + return EXT_KHR == extType; + } + public final boolean isExtensionARB() { - return extName == GLExtensions.ARB_debug_output; + return EXT_ARB == extType; } public final boolean isExtensionAMD() { - return extName == GLExtensions.AMD_debug_output; + return EXT_AMD == extType; } /** @@ -226,7 +262,7 @@ public class GLDebugMessageHandler { } } private final void setSynchronousImpl() { - if(isExtensionARB()) { + if(isExtensionKHRARB()) { if(synchronous) { ctx.getGL().glEnable(GL2ES2.GL_DEBUG_OUTPUT_SYNCHRONOUS); } else { diff --git a/src/jogl/native/GLDebugMessageHandler.c b/src/jogl/native/GLDebugMessageHandler.c index 5c18b94b1..e524df9bf 100644 --- a/src/jogl/native/GLDebugMessageHandler.c +++ b/src/jogl/native/GLDebugMessageHandler.c @@ -17,6 +17,7 @@ #define DBG_PRINT(...) #endif +// Note: 'ARB' is also used for 'KHR'! static jmethodID glDebugMessageARB = NULL; // int source, int type, int id, int severity, String msg static jmethodID glDebugMessageAMD = NULL; // int id, int category, int severity, String msg @@ -120,7 +121,8 @@ JNIEXPORT jlong JNICALL Java_jogamp_opengl_GLDebugMessageHandler_register0 handle->extType = extType; DBG_PRINT("GLDebugMessageHandler.register0: jobject %p, extType %d\n", (void*)handle->obj, handle->extType); - if(jogamp_opengl_GLDebugMessageHandler_EXT_ARB == extType) { + if(jogamp_opengl_GLDebugMessageHandler_EXT_KHR == extType || + jogamp_opengl_GLDebugMessageHandler_EXT_ARB == extType) { _local_PFNGLDEBUGMESSAGECALLBACKARBPROC ptr_glDebugMessageCallbackARB; ptr_glDebugMessageCallbackARB = (_local_PFNGLDEBUGMESSAGECALLBACKARBPROC) (intptr_t) procAddress; ptr_glDebugMessageCallbackARB((_local_GLDEBUGPROCARB)GLDebugMessageARBCallback, handle); @@ -151,7 +153,8 @@ JNIEXPORT void JNICALL Java_jogamp_opengl_GLDebugMessageHandler_unregister0 JoglCommon_throwNewRuntimeException(env, "wrong handle (obj doesn't match)"); } - if(jogamp_opengl_GLDebugMessageHandler_EXT_ARB == handle->extType) { + if(jogamp_opengl_GLDebugMessageHandler_EXT_KHR == handle->extType || + jogamp_opengl_GLDebugMessageHandler_EXT_ARB == handle->extType) { _local_PFNGLDEBUGMESSAGECALLBACKARBPROC ptr_glDebugMessageCallbackARB; ptr_glDebugMessageCallbackARB = (_local_PFNGLDEBUGMESSAGECALLBACKARBPROC) (intptr_t) procAddress; ptr_glDebugMessageCallbackARB((_local_GLDEBUGPROCARB)NULL, NULL); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug00NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug00NEWT.java index dcee114e5..8319a1c22 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug00NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug00NEWT.java @@ -32,7 +32,6 @@ import java.io.IOException; import com.jogamp.opengl.GL; import com.jogamp.opengl.GL2ES2; -import com.jogamp.opengl.GL2GL3; import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLContext; import com.jogamp.opengl.GLDebugListener; @@ -58,6 +57,14 @@ public class TestGLDebug00NEWT extends UITestCase { static String dbgTstMsg0 = "Hello World"; static int dbgTstId0 = 42; + static GLProfile getGLProfile(final String profile) { + if( !GLProfile.isAvailable(profile) ) { + System.err.println("Profile "+profile+" n/a"); + return null; + } + return GLProfile.get(profile); + } + public static class WindowContext { public final Window window; public final GLContext context; @@ -115,9 +122,7 @@ public class TestGLDebug00NEWT extends UITestCase { } - void test01GLDebug01EnableDisable(final boolean enable) throws InterruptedException { - final GLProfile glp = GLProfile.getDefault(); - + void testX1GLDebugEnableDisable(final GLProfile glp, final boolean enable) throws InterruptedException { final WindowContext winctx = createWindow(glp, enable); final String glDebugExt = winctx.context.getGLDebugMessageExtension(); System.err.println("glDebug extension: "+glDebugExt); @@ -131,19 +136,42 @@ public class TestGLDebug00NEWT extends UITestCase { } @Test - public void test01GLDebugDisabled() throws InterruptedException { - test01GLDebug01EnableDisable(false); + public void test01GL2GL3DebugDisabled() throws InterruptedException { + final GLProfile glp = getGLProfile(GLProfile.GL2GL3); + if( null == glp ) { + return; + } + testX1GLDebugEnableDisable(glp, false); } @Test - public void test01GLDebugEnabled() throws InterruptedException { - test01GLDebug01EnableDisable(true); + public void test02GL2GL3DebugEnabled() throws InterruptedException { + final GLProfile glp = getGLProfile(GLProfile.GL2GL3); + if( null == glp ) { + return; + } + testX1GLDebugEnableDisable(glp, true); } @Test - public void test02GLDebugError() throws InterruptedException { - final GLProfile glp = GLProfile.getDefault(); + public void test11GLES2DebugDisabled() throws InterruptedException { + final GLProfile glp = getGLProfile(GLProfile.GLES2); + if( null == glp ) { + return; + } + testX1GLDebugEnableDisable(glp, false); + } + + @Test + public void test12GLES2DebugEnabled() throws InterruptedException { + final GLProfile glp = getGLProfile(GLProfile.GLES2); + if( null == glp ) { + return; + } + testX1GLDebugEnableDisable(glp, true); + } + void testX2GLDebugError(final GLProfile glp) throws InterruptedException { final WindowContext winctx = createWindow(glp, true); final MyGLDebugListener myGLDebugListener = new MyGLDebugListener( @@ -164,8 +192,24 @@ public class TestGLDebug00NEWT extends UITestCase { } @Test - public void test03GLDebugInsert() throws InterruptedException { - final GLProfile glp = GLProfile.getDefault(); + public void test03GL2GL3DebugError() throws InterruptedException { + final GLProfile glp = getGLProfile(GLProfile.GL2GL3); + if( null == glp ) { + return; + } + testX2GLDebugError(glp); + } + + @Test + public void test13GLES2DebugError() throws InterruptedException { + final GLProfile glp = getGLProfile(GLProfile.GLES2); + if( null == glp ) { + return; + } + testX2GLDebugError(glp); + } + + void testX3GLDebugInsert(final GLProfile glp) throws InterruptedException { final WindowContext winctx = createWindow(glp, true); final MyGLDebugListener myGLDebugListener = new MyGLDebugListener(dbgTstMsg0, dbgTstId0); winctx.context.addGLDebugListener(myGLDebugListener); @@ -184,6 +228,23 @@ public class TestGLDebug00NEWT extends UITestCase { destroyWindow(winctx); } + @Test + public void test04GL2GL3DebugInsert() throws InterruptedException { + final GLProfile glp = getGLProfile(GLProfile.GL2GL3); + if( null == glp ) { + return; + } + testX3GLDebugInsert(glp); + } + + @Test + public void test14GLES2DebugInsert() throws InterruptedException { + final GLProfile glp = getGLProfile(GLProfile.GLES2); + if( null == glp ) { + return; + } + testX3GLDebugInsert(glp); + } public static void main(final String args[]) throws IOException { final String tstname = TestGLDebug00NEWT.class.getName(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug01NEWT.java index 66733209c..43d207a0d 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDebug01NEWT.java @@ -31,7 +31,6 @@ package com.jogamp.opengl.test.junit.jogl.acore; import java.io.IOException; import com.jogamp.opengl.GL2ES2; -import com.jogamp.opengl.GL2GL3; import com.jogamp.opengl.GLAutoDrawable; import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLContext; @@ -54,6 +53,14 @@ public class TestGLDebug01NEWT extends UITestCase { static String dbgTstMsg0 = "Hello World"; static int dbgTstId0 = 42; + static GLProfile getGLProfile(final String profile) { + if( !GLProfile.isAvailable(profile) ) { + System.err.println("Profile "+profile+" n/a"); + return null; + } + return GLProfile.get(profile); + } + GLWindow createWindow(final GLProfile glp, final boolean debugGL) { final GLCapabilities caps = new GLCapabilities(glp); // @@ -76,9 +83,7 @@ public class TestGLDebug01NEWT extends UITestCase { } - void test01GLDebug01EnableDisable(final boolean enable, final String dbgTstMsg, final int dbgTstId) throws InterruptedException { - final GLProfile glp = GLProfile.getDefault(); - + void testX1GLDebugEnableDisable(final GLProfile glp, final boolean enable, final String dbgTstMsg, final int dbgTstId) throws InterruptedException { final GLWindow window = createWindow(glp, enable); final GLContext ctx = window.getContext(); final MyGLDebugListener myGLDebugListener = new MyGLDebugListener(dbgTstMsg, dbgTstId); @@ -109,19 +114,42 @@ public class TestGLDebug01NEWT extends UITestCase { } @Test - public void test01GLDebug01Disabled() throws InterruptedException { - test01GLDebug01EnableDisable(false, null, -1); + public void test01GL2GL3DebugDisabled() throws InterruptedException { + final GLProfile glp = getGLProfile(GLProfile.GL2GL3); + if( null == glp ) { + return; + } + testX1GLDebugEnableDisable(glp, false, null, -1); } @Test - public void test01GLDebug01Enabled() throws InterruptedException { - test01GLDebug01EnableDisable(true, dbgTstMsg0, dbgTstId0); + public void test02GL2GL3DebugEnabled() throws InterruptedException { + final GLProfile glp = getGLProfile(GLProfile.GL2GL3); + if( null == glp ) { + return; + } + testX1GLDebugEnableDisable(glp, true, dbgTstMsg0, dbgTstId0); } @Test - public void test02GLDebug01Error() throws InterruptedException { - final GLProfile glp = GLProfile.getDefault(); + public void test11GLES2DebugDisabled() throws InterruptedException { + final GLProfile glp = getGLProfile(GLProfile.GLES2); + if( null == glp ) { + return; + } + testX1GLDebugEnableDisable(glp, false, null, -1); + } + @Test + public void test12GLES2DebugEnabled() throws InterruptedException { + final GLProfile glp = getGLProfile(GLProfile.GLES2); + if( null == glp ) { + return; + } + testX1GLDebugEnableDisable(glp, true, dbgTstMsg0, dbgTstId0); + } + + void testX3GLDebugError(final GLProfile glp) throws InterruptedException { final GLWindow window = createWindow(glp, true); final MyGLDebugListener myGLDebugListener = new MyGLDebugListener( @@ -144,6 +172,23 @@ public class TestGLDebug01NEWT extends UITestCase { destroyWindow(window); } + @Test + public void test03GL2GL3DebugError() throws InterruptedException { + final GLProfile glp = getGLProfile(GLProfile.GL2GL3); + if( null == glp ) { + return; + } + testX3GLDebugError(glp); + } + + @Test + public void test13GLES2DebugError() throws InterruptedException { + final GLProfile glp = getGLProfile(GLProfile.GLES2); + if( null == glp ) { + return; + } + testX3GLDebugError(glp); + } public static void main(final String args[]) throws IOException { final String tstname = TestGLDebug01NEWT.class.getName(); |