diff options
author | Sven Gothel <[email protected]> | 2014-07-30 04:51:14 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-07-30 04:51:14 +0200 |
commit | 830feb65f4c3d0c633556fd39787328834ee51d2 (patch) | |
tree | d15b97c176430f4ff4e1483dbc248b410de828fd /src/jogl/classes/jogamp/opengl | |
parent | 7314b47ae1e42997e9e6974b84709640f0ac2a1b (diff) |
Bug 1038 - Fix: Allow skipping detection of certain GLProfiles: Skip 'ARB_create_context'
Commit e5a55ede324ce500f50991d56491758803063a58 was incomplete,
i.e. it lacked the required mappings for the non ARB profile, i.e.:
GL4bc -> GL3bc, etc.
These profile mappings have been added now.
+++
Further more, GLContext's profile queries, isGL*()
test the ctxOptions for CTX_IS_ARB_CREATED.
This has to be removed to properly work w/ Skip 'ARB_create_context'.
To remove the risk of inconcistency, i.e. context created via ARB and non-ARB,
the 'GLX/WGL profile >= GL3 via non ARB' validation removed
in commit e5a55ede324ce500f50991d56491758803063a58 has been brought back
and refined. Note:
if( glp.isGL3() && createContextARBTried ) {
// We shall not allow context creation >= GL3 w/ non ARB methods if ARB is used,
// otherwise context of similar profile but different creation method may not be share-able.
.. THROW EXCEPTON ..
}
This limited validation removes the possibility of such having a context
of same profile, one created via ARB and one without.
Hence also validates the isGL*() change, where the CTX_IS_ARB_CREATED criteria is removed.
+++
Note regarding commit 7314b47ae1e42997e9e6974b84709640f0ac2a1b (revert):
While analyzing the mapping, it turns out that commit c8b99d197769eaec53c2def562c0ef3fc0e6a9d2
"Don't map compatibility profiles to core profile if the latter are not available (restrict profile aliasing)"
is not fully consistent with GLProfile's and GLContext's profile queries, i.e. isGL*().
We may reiterate over this change .. but have it be reverted for now.
Diffstat (limited to 'src/jogl/classes/jogamp/opengl')
3 files changed, 55 insertions, 14 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 4632aaadc..be0088f89 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -704,13 +704,32 @@ public abstract class GLContextImpl extends GLContext { } else { reqMajor = ctxVersion.getMajor(); } + final boolean isCompat; if( 0 != ( ctxOptions & GLContext.CTX_PROFILE_CORE) ) { reqProfile = GLContext.CTX_PROFILE_CORE; + isCompat = false; } else { reqProfile = GLContext.CTX_PROFILE_COMPAT; + isCompat = true; + } + GLContext.mapAvailableGLVersion(device, reqMajor, reqProfile, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); + // Perform all required profile mappings + if( isCompat ) { + // COMPAT via non ARB + GLContext.mapAvailableGLVersion(device, reqMajor, GLContext.CTX_PROFILE_CORE, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); + if( reqMajor >= 4 ) { + GLContext.mapAvailableGLVersion(device, 3, reqProfile, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); + GLContext.mapAvailableGLVersion(device, 3, GLContext.CTX_PROFILE_CORE, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); + } + if( reqMajor >= 3 ) { + GLContext.mapAvailableGLVersion(device, 2, reqProfile, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); + } + } else { + // CORE via non ARB, unlikely, however .. + if( reqMajor >= 4 ) { + GLContext.mapAvailableGLVersion(device, 3, reqProfile, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); + } } - GLContext.mapAvailableGLVersion(device, reqMajor, reqProfile, - ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); GLContext.setAvailableGLVersionsSet(device); if (DEBUG) { diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java index 00f5687a5..33980d663 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java @@ -51,6 +51,7 @@ import javax.media.nativewindow.NativeSurface; import javax.media.opengl.GLContext; import javax.media.opengl.GLException; import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLProfile; import com.jogamp.common.nio.Buffers; import com.jogamp.gluegen.runtime.ProcAddressTable; @@ -330,7 +331,7 @@ public class WindowsWGLContext extends GLContextImpl { isProcCreateContextAttribsARBAvailable = false; isExtARBCreateContextAvailable = false; } - if ( isProcCreateContextAttribsARBAvailable && isExtARBCreateContextAvailable ) { + if ( isProcCreateContextAttribsARBAvailable && isExtARBCreateContextAvailable && !GLProfile.disableOpenGLARBContext ) { // initial ARB context creation contextHandle = createContextARB(shareWithHandle, true); createContextARBTried=true; @@ -343,7 +344,9 @@ public class WindowsWGLContext extends GLContextImpl { } } else if (DEBUG) { System.err.println(getThreadName() + ": createContextImpl: NOT OK (ARB, initial) - extension not available - share "+toHexString(shareWithHandle)+ - ", isProcCreateContextAttribsARBAvailable "+isProcCreateContextAttribsARBAvailable+", isExtGLXARBCreateContextAvailable "+isExtARBCreateContextAvailable); + ", isProcCreateContextAttribsARBAvailable "+isProcCreateContextAttribsARBAvailable+ + ", isExtGLXARBCreateContextAvailable "+isExtARBCreateContextAvailable+ + ", disableOpenGLARBContext "+GLProfile.disableOpenGLARBContext); } } } else { @@ -360,8 +363,15 @@ public class WindowsWGLContext extends GLContextImpl { } } } else { + if( glCaps.getGLProfile().isGL3() && createContextARBTried ) { + // We shall not allow context creation >= GL3 w/ non ARB methods if ARB is used, + // otherwise context of similar profile but different creation method may not be share-able. + WGL.wglMakeCurrent(0, 0); + WGL.wglDeleteContext(temp_ctx); + throw new GLException(getThreadName()+": WindowsWGLContex.createContextImpl ctx !ARB but ARB is used, profile > GL2 requested (OpenGL >= 3.0.1). Requested: "+glCaps.getGLProfile()+", current: "+getGLVersion()); + } if(DEBUG) { - System.err.println("WindowsWGLContext.createContext via ARB failed, fall back to !ARB context "+getGLVersion()); + System.err.println("WindowsWGLContext.createContext ARB not used, fall back to !ARB context "+getGLVersion()); } // continue with temp context diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java index d93b2feb0..9631dbb5b 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java @@ -51,6 +51,7 @@ import javax.media.nativewindow.NativeSurface; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; import javax.media.opengl.GLException; +import javax.media.opengl.GLProfile; import jogamp.nativewindow.x11.X11Lib; import jogamp.nativewindow.x11.X11Util; @@ -297,11 +298,12 @@ public class X11GLXContext extends GLContextImpl { } final GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities(); + final GLProfile glp = glCaps.getGLProfile(); if( !config.hasFBConfig() ) { // not able to use FBConfig -> GLX 1.1 forceGLXVersionOneOne(); - if(glCaps.getGLProfile().isGL3()) { + if( glp.isGL3() ) { throw new GLException(getThreadName()+": Unable to create OpenGL >= 3.1 context w/o FBConfig"); } contextHandle = GLX.glXCreateContext(display, config.getXVisualInfo(), shareWithHandle, direct); @@ -341,7 +343,7 @@ public class X11GLXContext extends GLContextImpl { throw new GLException(getThreadName()+": Unable to create temp OpenGL context(1)"); } if ( !glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), temp_ctx) ) { - throw new GLException(getThreadName()+": Error making temp context(1) current: display "+toHexString(display)+", context "+toHexString(temp_ctx)+", drawable "+drawable); + throw new GLException(getThreadName()+": Error making temp context(1) current: display "+toHexString(display)+", context "+toHexString(temp_ctx)+", drawable "+drawable); } setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT, false /* strictMatch */, null == sharedContext /* withinGLVersionsMapping */); // use GL_VERSION glXMakeContextCurrent(display, 0, 0, 0); // release temp context @@ -349,7 +351,7 @@ public class X11GLXContext extends GLContextImpl { // is*Available calls are valid since setGLFunctionAvailability(..) was called final boolean isProcCreateContextAttribsARBAvailable = isFunctionAvailable("glXCreateContextAttribsARB"); final boolean isExtARBCreateContextAvailable = isExtensionAvailable("GLX_ARB_create_context"); - if ( isProcCreateContextAttribsARBAvailable && isExtARBCreateContextAvailable ) { + if ( isProcCreateContextAttribsARBAvailable && isExtARBCreateContextAvailable && !GLProfile.disableOpenGLARBContext ) { // initial ARB context creation contextHandle = createContextARB(shareWithHandle, direct); createContextARBTried=true; @@ -360,9 +362,11 @@ public class X11GLXContext extends GLContextImpl { System.err.println(getThreadName() + ": createContextImpl: NOT OK (ARB, initial) - creation failed - share "+toHexString(shareWithHandle)); } } - } else if (DEBUG) { + } else if( DEBUG ) { System.err.println(getThreadName() + ": createContextImpl: NOT OK (ARB, initial) - extension not available - share "+toHexString(shareWithHandle)+ - ", isProcCreateContextAttribsARBAvailable "+isProcCreateContextAttribsARBAvailable+", isExtGLXARBCreateContextAvailable "+isExtARBCreateContextAvailable); + ", isProcCreateContextAttribsARBAvailable "+isProcCreateContextAttribsARBAvailable+ + ", isExtGLXARBCreateContextAvailable "+isExtARBCreateContextAvailable+ + ", disableOpenGLARBContext "+GLProfile.disableOpenGLARBContext); } } } else { @@ -378,16 +382,24 @@ public class X11GLXContext extends GLContextImpl { } } } else { + if( glp.isGL3() && createContextARBTried ) { + // We shall not allow context creation >= GL3 w/ non ARB methods if ARB is used, + // otherwise context of similar profile but different creation method may not be share-able. + glXMakeContextCurrent(display, 0, 0, 0); + GLX.glXDestroyContext(display, temp_ctx); + throw new GLException(getThreadName()+": X11GLXContext.createContextImpl ctx !ARB but ARB is used, profile > GL2 requested (OpenGL >= 3.0.1). Requested: "+glp+", current: "+getGLVersion()); + } + if(DEBUG) { - System.err.println(getThreadName()+": X11GLXContext.createContextImpl via ARB failed, fall back to !ARB context "+getGLVersion()); + System.err.println(getThreadName()+": X11GLXContext.createContextImpl ARB not used, fall back to !ARB context "+getGLVersion()); } // continue with temp context contextHandle = temp_ctx; if ( !glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), contextHandle) ) { - glXMakeContextCurrent(display, 0, 0, 0); - GLX.glXDestroyContext(display, temp_ctx); - throw new GLException(getThreadName()+": Error making context(1) current: display "+toHexString(display)+", context "+toHexString(contextHandle)+", drawable "+drawable); + glXMakeContextCurrent(display, 0, 0, 0); + GLX.glXDestroyContext(display, temp_ctx); + throw new GLException(getThreadName()+": Error making context(1) current: display "+toHexString(display)+", context "+toHexString(contextHandle)+", drawable "+drawable); } if (DEBUG) { System.err.println(getThreadName() + ": createContextImpl: OK (old-2) share "+toHexString(shareWithHandle)); |