diff options
Diffstat (limited to 'src')
6 files changed, 80 insertions, 65 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java index cd121979a..2c07b4668 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java @@ -67,9 +67,9 @@ public abstract class GLContextImpl extends GLContext { /** * Context full qualified name: display_type + display_connection + major + minor + ctp. - * This is the key for all cached ProcAddressTables, etc, to support multi display/device setups. + * This is the key for all cached GL ProcAddressTables, etc, to support multi display/device setups. */ - protected String contextFQN; + private String contextFQN; // Cache of the functions that are available to be called at the current // moment in time @@ -810,7 +810,6 @@ public abstract class GLContextImpl extends GLContext { * * @see #setContextVersion */ - protected final void setGLFunctionAvailability(boolean force, int major, int minor, int ctp) { if(null!=this.gl && null!=glProcAddressTable && !force) { return; // already done and not forced @@ -819,6 +818,8 @@ public abstract class GLContextImpl extends GLContext { setGL(createGL(getGLDrawable().getGLProfile())); } + updateGLXProcAddressTable(); + AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration(); AbstractGraphicsDevice adevice = aconfig.getScreen().getDevice(); contextFQN = getContextFQN(adevice, major, minor, ctp); @@ -826,8 +827,6 @@ public abstract class GLContextImpl extends GLContext { System.err.println(getThreadName() + ": !!! Context FQN: "+contextFQN); } - updateGLXProcAddressTable(major, minor, ctp); - // // UpdateGLProcAddressTable functionality // @@ -899,7 +898,7 @@ public abstract class GLContextImpl extends GLContext { /** * Updates the platform's 'GLX' function cache */ - protected abstract void updateGLXProcAddressTable(int major, int minor, int ctp); + protected abstract void updateGLXProcAddressTable(); protected boolean hasNativeES2Methods = false; @@ -992,6 +991,14 @@ public abstract class GLContextImpl extends GLContext { return false; } + protected static String getContextFQN(AbstractGraphicsDevice device, int major, int minor, int ctp) { + return device.getUniqueID() + "-" + toHexString(compose8bit(major, minor, ctp, 0)); + } + + protected String getContextFQN() { + return contextFQN; + } + /** Indicates which floating-point pbuffer implementation is in use. Returns one of GLPbuffer.APPLE_FLOAT, GLPbuffer.ATI_FLOAT, or GLPbuffer.NV_FLOAT. */ @@ -1008,6 +1015,7 @@ public abstract class GLContextImpl extends GLContext { /** Only called for offscreen contexts; needed by glReadPixels */ public abstract int getOffscreenContextPixelDataType(); + //---------------------------------------------------------------------- // Helpers for buffer object optimizations diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLContext.java index 246814537..107d7fbbb 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLContext.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLContext.java @@ -41,6 +41,8 @@ import com.jogamp.gluegen.runtime.ProcAddressTable; import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver; import java.nio.*; import java.util.*; +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.AbstractGraphicsDevice; public abstract class EGLContext extends GLContextImpl { private boolean eglQueryStringInitialized; @@ -191,21 +193,24 @@ public abstract class EGLContext extends GLContextImpl { return true; } - protected final void updateGLXProcAddressTable(int major, int minor, int ctp) { + protected final void updateGLXProcAddressTable() { + AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration(); + AbstractGraphicsDevice adevice = aconfig.getScreen().getDevice(); + String key = adevice.getUniqueID(); if (DEBUG) { - System.err.println(getThreadName() + ": !!! Initializing EGL extension address table"); + System.err.println(getThreadName() + ": !!! Initializing EGLextension address table: "+key); } eglQueryStringInitialized = false; eglQueryStringAvailable = false; EGLExtProcAddressTable table = null; synchronized(mappedContextTypeObjectLock) { - table = (EGLExtProcAddressTable) mappedGLXProcAddress.get( contextFQN ); + table = (EGLExtProcAddressTable) mappedGLXProcAddress.get( key ); } if(null != table) { eglExtProcAddressTable = table; if(DEBUG) { - System.err.println(getThreadName() + ": !!! GLContext EGL ProcAddressTable reusing key("+contextFQN+") -> "+table.hashCode()); + System.err.println(getThreadName() + ": !!! GLContext EGL ProcAddressTable reusing key("+key+") -> "+table.hashCode()); } } else { if (eglExtProcAddressTable == null) { @@ -215,9 +220,9 @@ public abstract class EGLContext extends GLContextImpl { } resetProcAddressTable(getEGLExtProcAddressTable()); synchronized(mappedContextTypeObjectLock) { - mappedGLXProcAddress.put(contextFQN, getEGLExtProcAddressTable()); + mappedGLXProcAddress.put(key, getEGLExtProcAddressTable()); if(DEBUG) { - System.err.println(getThreadName() + ": !!! GLContext EGL ProcAddressTable mapping key("+contextFQN+") -> "+getEGLExtProcAddressTable().hashCode()); + System.err.println(getThreadName() + ": !!! GLContext EGL ProcAddressTable mapping key("+key+") -> "+getEGLExtProcAddressTable().hashCode()); } } } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java index 6a916765a..3450c456e 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java @@ -223,18 +223,21 @@ public abstract class MacOSXCGLContext extends GLContextImpl } } - protected final void updateGLXProcAddressTable(int major, int minor, int ctp) { + protected final void updateGLXProcAddressTable() { + AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration(); + AbstractGraphicsDevice adevice = aconfig.getScreen().getDevice(); + String key = adevice.getUniqueID(); if (DEBUG) { - System.err.println(getThreadName() + ": !!! Initializing CGL extension address table"); + System.err.println(getThreadName() + ": !!! Initializing CGL extension address table: "+key); } CGLExtProcAddressTable table = null; synchronized(mappedContextTypeObjectLock) { - table = (CGLExtProcAddressTable) mappedGLXProcAddress.get( contextFQN ); + table = (CGLExtProcAddressTable) mappedGLXProcAddress.get( key ); } if(null != table) { cglExtProcAddressTable = table; if(DEBUG) { - System.err.println(getThreadName() + ": !!! GLContext CGL ProcAddressTable reusing key("+contextFQN+") -> "+table.hashCode()); + System.err.println(getThreadName() + ": !!! GLContext CGL ProcAddressTable reusing key("+key+") -> "+table.hashCode()); } } else { if (cglExtProcAddressTable == null) { @@ -244,9 +247,9 @@ public abstract class MacOSXCGLContext extends GLContextImpl } resetProcAddressTable(getCGLExtProcAddressTable()); synchronized(mappedContextTypeObjectLock) { - mappedGLXProcAddress.put(contextFQN, getCGLExtProcAddressTable()); + mappedGLXProcAddress.put(key, getCGLExtProcAddressTable()); if(DEBUG) { - System.err.println(getThreadName() + ": !!! GLContext CGL ProcAddressTable mapping key("+contextFQN+") -> "+getCGLExtProcAddressTable().hashCode()); + System.err.println(getThreadName() + ": !!! GLContext CGL ProcAddressTable mapping key("+key+") -> "+getCGLExtProcAddressTable().hashCode()); } } } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java index e85308371..111557e5a 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java @@ -162,15 +162,13 @@ public class WindowsWGLContext extends GLContextImpl { } protected long createContextARBImpl(long share, boolean direct, int ctp, int major, int minor) { - WindowsWGLDrawableFactory factory = (WindowsWGLDrawableFactory)drawable.getFactoryImpl(); - AbstractGraphicsConfiguration config = drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration(); - AbstractGraphicsDevice device = config.getScreen().getDevice(); - WindowsWGLContext sharedContext = (WindowsWGLContext) factory.getOrCreateSharedContextImpl(device); - WGLExt _wglExt; - if(null==sharedContext) { - _wglExt = getWGLExt(); - } else { - _wglExt = sharedContext.getWGLExt(); + WGLExt _wglExt = getWGLExt(); + updateGLXProcAddressTable(); + if(DEBUG) { + System.err.println("WindowWGLContext.createContextARBImpl: "+getGLVersion(major, minor, ctp, "@creation") + + ", handle "+toHexString(drawable.getHandle()) + ", share "+toHexString(share)+", direct "+direct+ + ", wglCreateContextAttribsARB: "+toHexString(wglExtProcAddressTable._addressof_wglCreateContextAttribsARB)); + Thread.dumpStack(); } boolean ctBwdCompat = 0 != ( CTX_PROFILE_COMPAT & ctp ) ; @@ -221,8 +219,7 @@ public class WindowsWGLContext extends GLContextImpl { } if(0!=ctx) { - // cannot use wglMakeContextCurrent since WGLExt ProcAddressTable is not ready yet. - if( !WGL.wglMakeCurrent(drawable.getHandle(), ctx) ) { + if (!wglMakeContextCurrent(drawable.getHandle(), drawableRead.getHandle(), ctx)) { if(DEBUG) { System.err.println("WindowsWGLContext.createContextARB couldn't make current "+getGLVersion(major, minor, ctp, "@creation")); } @@ -231,7 +228,7 @@ public class WindowsWGLContext extends GLContextImpl { ctx = 0; } else { if (DEBUG) { - System.err.println(getThreadName() + ": createContextARBImpl: OK "+getGLVersion(major, minor, ctp, "@creation")+", share "+share+", direct "+direct+", hasSharedContext "+(null!=sharedContext)); + System.err.println(getThreadName() + ": createContextARBImpl: OK "+getGLVersion(major, minor, ctp, "@creation")+", share "+share+", direct "+direct); } // the following is issued by the caller 'GLContextImpl.createContextARB()' // setGLFunctionAvailability(true, major, minor, ctp); @@ -315,12 +312,12 @@ public class WindowsWGLContext extends GLContextImpl { if(0!=contextHandle) { share = 0; // mark as shared thx to the ARB create method - WGL.wglMakeCurrent(0, 0); // the ARB create method used WGL.wglMakeCurrent(0, 0) - if(0!=temp_ctx) { + if(0!=temp_ctx) { + WGL.wglMakeCurrent(0, 0); WGL.wglDeleteContext(temp_ctx); - } - if (!wglMakeContextCurrent(drawable.getHandle(), drawableRead.getHandle(), contextHandle)) { - throw new GLException("Cannot make previous verified context current: 0x" + toHexString(contextHandle) + ", werr: " + GDI.GetLastError()); + if (!wglMakeContextCurrent(drawable.getHandle(), drawableRead.getHandle(), contextHandle)) { + throw new GLException("Cannot make previous verified context current: 0x" + toHexString(contextHandle) + ", werr: " + GDI.GetLastError()); + } } } else { if(glCaps.getGLProfile().isGL3()) { @@ -385,9 +382,12 @@ public class WindowsWGLContext extends GLContextImpl { } } - protected final void updateGLXProcAddressTable(int major, int minor, int ctp) { + protected final void updateGLXProcAddressTable() { + AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration(); + AbstractGraphicsDevice adevice = aconfig.getScreen().getDevice(); + String key = adevice.getUniqueID(); if (DEBUG) { - System.err.println(getThreadName() + ": !!! Initializing WGL extension address table for " + this); + System.err.println(getThreadName() + ": !!! Initializing WGL extension address table: "+key); } wglGetExtensionsStringEXTInitialized=false; wglGetExtensionsStringEXTAvailable=false; @@ -396,12 +396,12 @@ public class WindowsWGLContext extends GLContextImpl { WGLExtProcAddressTable table = null; synchronized(mappedContextTypeObjectLock) { - table = (WGLExtProcAddressTable) mappedGLXProcAddress.get( contextFQN ); + table = (WGLExtProcAddressTable) mappedGLXProcAddress.get( key ); } if(null != table) { wglExtProcAddressTable = table; if(DEBUG) { - System.err.println(getThreadName() + ": !!! GLContext WGL ProcAddressTable reusing key("+contextFQN+") -> "+table.hashCode()); + System.err.println(getThreadName() + ": !!! GLContext WGL ProcAddressTable reusing key("+key+") -> "+table.hashCode()); } } else { if (wglExtProcAddressTable == null) { @@ -411,9 +411,9 @@ public class WindowsWGLContext extends GLContextImpl { } resetProcAddressTable(getWGLExtProcAddressTable()); synchronized(mappedContextTypeObjectLock) { - mappedGLXProcAddress.put(contextFQN, getWGLExtProcAddressTable()); + mappedGLXProcAddress.put(key, getWGLExtProcAddressTable()); if(DEBUG) { - System.err.println(getThreadName() + ": !!! GLContext WGL ProcAddressTable mapping key("+contextFQN+") -> "+getWGLExtProcAddressTable().hashCode()); + System.err.println(getThreadName() + ": !!! GLContext WGL ProcAddressTable mapping key("+key+") -> "+getWGLExtProcAddressTable().hashCode()); } } } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java index fddfb4cd1..32d70ad6b 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java @@ -173,18 +173,13 @@ public abstract class X11GLXContext extends GLContextImpl { } protected long createContextARBImpl(long share, boolean direct, int ctp, int major, int minor) { - X11GLXDrawableFactory factory = (X11GLXDrawableFactory)drawable.getFactoryImpl(); - - X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration(); - AbstractGraphicsDevice device = config.getScreen().getDevice(); - X11GLXContext sharedContext = (X11GLXContext) factory.getOrCreateSharedContextImpl(device); - long display = device.getHandle(); - - GLXExt glXExt; - if(null==sharedContext) { - glXExt = getGLXExt(); - } else { - glXExt = sharedContext.getGLXExt(); + updateGLXProcAddressTable(); + GLXExt _glXExt = getGLXExt(); + if(DEBUG) { + System.err.println("X11GLXContext.createContextARBImpl: "+getGLVersion(major, minor, ctp, "@creation") + + ", handle "+toHexString(drawable.getHandle()) + ", share "+toHexString(share)+", direct "+direct+ + ", glXCreateContextAttribsARB: "+toHexString(glXExtProcAddressTable._addressof_glXCreateContextAttribsARB)); + Thread.dumpStack(); } boolean ctBwdCompat = 0 != ( CTX_PROFILE_COMPAT & ctp ) ; @@ -224,11 +219,15 @@ public abstract class X11GLXContext extends GLContextImpl { } } + X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration(); + AbstractGraphicsDevice device = config.getScreen().getDevice(); + long display = device.getHandle(); + try { // critical path, a remote display might not support this command, // hence we need to catch the X11 Error within this block. X11Util.XSync(display, false); - ctx = glXExt.glXCreateContextAttribsARB(display, config.getFBConfig(), share, direct, attribs, 0); + ctx = _glXExt.glXCreateContextAttribsARB(display, config.getFBConfig(), share, direct, attribs, 0); X11Util.XSync(display, false); } catch (RuntimeException re) { if(DEBUG) { @@ -247,7 +246,7 @@ public abstract class X11GLXContext extends GLContextImpl { ctx = 0; } else { if (DEBUG) { - System.err.println(getThreadName() + ": createContextARBImpl: OK "+getGLVersion(major, minor, ctp, "@creation")+", share "+share+", direct "+direct+", hasSharedContext "+(null!=sharedContext)); + System.err.println(getThreadName() + ": createContextARBImpl: OK "+getGLVersion(major, minor, ctp, "@creation")+", share "+share+", direct "+direct); } // the following is issued by the caller 'GLContextImpl.createContextARB()' // setGLFunctionAvailability(true, major, minor, ctp); @@ -458,21 +457,24 @@ public abstract class X11GLXContext extends GLContextImpl { // Should check for X errors and raise GLException } - protected final void updateGLXProcAddressTable(int major, int minor, int ctp) { + protected final void updateGLXProcAddressTable() { + AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration(); + AbstractGraphicsDevice adevice = aconfig.getScreen().getDevice(); + String key = adevice.getUniqueID(); if (DEBUG) { - System.err.println(getThreadName() + ": !!! Initializing GLX extension address table"); + System.err.println(getThreadName() + ": !!! Initializing GLX extension address table: "+key); } glXQueryExtensionsStringInitialized = false; glXQueryExtensionsStringAvailable = false; GLXExtProcAddressTable table = null; synchronized(mappedContextTypeObjectLock) { - table = (GLXExtProcAddressTable) mappedGLXProcAddress.get( contextFQN ); + table = (GLXExtProcAddressTable) mappedGLXProcAddress.get( key ); } if(null != table) { glXExtProcAddressTable = table; if(DEBUG) { - System.err.println(getThreadName() + ": !!! GLContext GLX ProcAddressTable reusing key("+contextFQN+") -> "+table.hashCode()); + System.err.println(getThreadName() + ": !!! GLContext GLX ProcAddressTable reusing key("+key+") -> "+table.hashCode()); } } else { if (glXExtProcAddressTable == null) { @@ -480,9 +482,10 @@ public abstract class X11GLXContext extends GLContextImpl { } resetProcAddressTable(getGLXExtProcAddressTable()); synchronized(mappedContextTypeObjectLock) { - mappedGLXProcAddress.put(contextFQN, getGLXExtProcAddressTable()); + mappedGLXProcAddress.put(key, getGLXExtProcAddressTable()); if(DEBUG) { - System.err.println(getThreadName() + ": !!! GLContext GLX ProcAddressTable mapping key("+contextFQN+") -> "+getGLXExtProcAddressTable().hashCode()); + System.err.println(getThreadName() + ": !!! GLContext GLX ProcAddressTable mapping key("+key+") -> "+getGLXExtProcAddressTable().hashCode()); + Thread.dumpStack(); } } } diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index 72073deef..8c06acfd6 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -579,10 +579,6 @@ public abstract class GLContext { */ private static /*final*/ HashSet/*<UniqueDeviceString>*/ deviceVersionsAvailableSet = new HashSet(); - protected static String getContextFQN(AbstractGraphicsDevice device, int major, int minor, int ctp) { - return device.getUniqueID() + "-" + toHexString(compose8bit(major, minor, ctp, 0)); - } - protected static String getDeviceVersionAvailableKey(AbstractGraphicsDevice device, int major, int profile) { return device.getUniqueID() + "-" + toHexString(compose8bit(major, profile, 0, 0)); } |