aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-02-13 12:37:52 +0100
committerSven Gothel <[email protected]>2012-02-13 12:37:52 +0100
commit03b15ec0efc5af944da7d65aadab3a4bdf2e6c68 (patch)
tree5de9e1a688b1842e6461d304def24622f4528950 /src/jogl/classes/jogamp
parente213836e39a1c0a909dbe47a25ec5bc10de06196 (diff)
Fix JOGL GLContextImpl ProcAddressTable and Extension Caching
Bug caused using wrong extension cache and probably the wrong procAddress table. - do not reuse local field value if not cached - issue resetState() after each createContextARBMapVersionsAvailable(..) query - remove cache entry for extension (copy/paste bug) - resetState() shall clean platform extProcAddressTable in specializations
Diffstat (limited to 'src/jogl/classes/jogamp')
-rw-r--r--src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java4
-rw-r--r--src/jogl/classes/jogamp/opengl/GLContextImpl.java26
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLContext.java11
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java9
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java10
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java8
6 files changed, 29 insertions, 39 deletions
diff --git a/src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java b/src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java
index a35137f15..41366c9a8 100644
--- a/src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java
+++ b/src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java
@@ -83,6 +83,10 @@ final class ExtensionAvailabilityCache {
return initialized && !availableExtensionCache.isEmpty() ;
}
+ final int getSize() {
+ return initialized ? availableExtensionCache.size() : 0 ;
+ }
+
final boolean isExtensionAvailable(String glExtensionName) {
initAvailableExtensions();
return availableExtensionCache.contains(mapGLExtensionName(glExtensionName));
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
index 02ac2428f..7766214b4 100644
--- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
@@ -660,7 +660,6 @@ public abstract class GLContextImpl extends GLContext {
createContextARBMapVersionsAvailable(4, false /* core */); // GL4
createContextARBMapVersionsAvailable(3, false /* core */); // GL3
GLContext.setAvailableGLVersionsSet(device);
- resetStates();
}
}
@@ -737,6 +736,7 @@ public abstract class GLContextImpl extends GLContext {
} else if (DEBUG) {
System.err.println(getThreadName() + ": !!! createContextARBMapVersionsAvailable NOPE: "+reqMajor+"."+reqProfile);
}
+ resetStates();
}
private final long createContextARBVersions(long share, boolean direct, int ctxOptionFlags,
@@ -971,19 +971,17 @@ public abstract class GLContextImpl extends GLContext {
if(null != table) {
glProcAddressTable = table;
if(DEBUG) {
- System.err.println(getThreadName() + ": !!! GLContext GL ProcAddressTable reusing key("+contextFQN+") -> "+table.hashCode());
+ System.err.println(getThreadName() + ": !!! GLContext GL ProcAddressTable reusing key("+contextFQN+") -> "+toHexString(table.hashCode()));
}
} else {
- if (glProcAddressTable == null) {
- glProcAddressTable = (ProcAddressTable) createInstance(gl.getGLProfile(), "ProcAddressTable",
- new Class[] { FunctionAddressResolver.class } ,
- new Object[] { new GLProcAddressResolver() } );
- }
+ glProcAddressTable = (ProcAddressTable) createInstance(gl.getGLProfile(), "ProcAddressTable",
+ new Class[] { FunctionAddressResolver.class } ,
+ new Object[] { new GLProcAddressResolver() } );
resetProcAddressTable(getGLProcAddressTable());
synchronized(mappedContextTypeObjectLock) {
mappedGLProcAddress.put(contextFQN, getGLProcAddressTable());
if(DEBUG) {
- System.err.println(getThreadName() + ": !!! GLContext GL ProcAddressTable mapping key("+contextFQN+") -> "+getGLProcAddressTable().hashCode());
+ System.err.println(getThreadName() + ": !!! GLContext GL ProcAddressTable mapping key("+contextFQN+") -> "+toHexString(getGLProcAddressTable().hashCode()));
}
}
}
@@ -998,17 +996,15 @@ public abstract class GLContextImpl extends GLContext {
if(null != eCache) {
extensionAvailability = eCache;
if(DEBUG) {
- System.err.println(getThreadName() + ": !!! GLContext GL ExtensionAvailabilityCache reusing key("+contextFQN+") -> "+eCache.hashCode());
+ System.err.println(getThreadName() + ": !!! GLContext GL ExtensionAvailabilityCache reusing key("+contextFQN+") -> "+toHexString(eCache.hashCode()) + " - entries: "+eCache.getSize());
}
} else {
- if(null==extensionAvailability) {
- extensionAvailability = new ExtensionAvailabilityCache(this);
- }
+ extensionAvailability = new ExtensionAvailabilityCache(this);
extensionAvailability.reset();
synchronized(mappedContextTypeObjectLock) {
mappedExtensionAvailabilityCache.put(contextFQN, extensionAvailability);
if(DEBUG) {
- System.err.println(getThreadName() + ": !!! GLContext GL ExtensionAvailabilityCache mapping key("+contextFQN+") -> "+extensionAvailability.hashCode());
+ System.err.println(getThreadName() + ": !!! GLContext GL ExtensionAvailabilityCache mapping key("+contextFQN+") -> "+toHexString(extensionAvailability.hashCode()) + " - entries: "+extensionAvailability.getSize());
}
}
}
@@ -1039,9 +1035,9 @@ public abstract class GLContextImpl extends GLContext {
}
synchronized(mappedContextTypeObjectLock) {
- ExtensionAvailabilityCache eCache = mappedExtensionAvailabilityCache.get( contextFQN );
+ ExtensionAvailabilityCache eCache = mappedExtensionAvailabilityCache.remove( contextFQN );
if(DEBUG) {
- System.err.println(getThreadName() + ": !!! RM GLContext GL ExtensionAvailabilityCache reusing key("+contextFQN+") -> "+eCache.hashCode());
+ System.err.println(getThreadName() + ": !!! RM GLContext GL ExtensionAvailabilityCache mapping key("+contextFQN+") -> "+eCache.hashCode());
}
}
}
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java
index 1dc4a81aa..60766a57d 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java
@@ -67,6 +67,7 @@ public abstract class EGLContext extends GLContextImpl {
protected void resetStates() {
eglQueryStringInitialized = false;
eglQueryStringAvailable = false;
+ eglExtProcAddressTable = null;
// no inner state _eglExt = null;
super.resetStates();
}
@@ -233,19 +234,15 @@ public abstract class EGLContext extends GLContextImpl {
if(null != table) {
eglExtProcAddressTable = (EGLExtProcAddressTable) table;
if(DEBUG) {
- System.err.println(getThreadName() + ": !!! GLContext EGL ProcAddressTable reusing key("+key+") -> "+table.hashCode());
+ System.err.println(getThreadName() + ": !!! GLContext EGL ProcAddressTable reusing key("+key+") -> "+toHexString(table.hashCode()));
}
} else {
- if (eglExtProcAddressTable == null) {
- // FIXME: cache ProcAddressTables by capability bits so we can
- // share them among contexts with the same capabilities
- eglExtProcAddressTable = new EGLExtProcAddressTable(new GLProcAddressResolver());
- }
+ eglExtProcAddressTable = new EGLExtProcAddressTable(new GLProcAddressResolver());
resetProcAddressTable(getEGLExtProcAddressTable());
synchronized(mappedContextTypeObjectLock) {
mappedGLXProcAddress.put(key, getEGLExtProcAddressTable());
if(DEBUG) {
- System.err.println(getThreadName() + ": !!! GLContext EGL ProcAddressTable mapping key("+key+") -> "+getEGLExtProcAddressTable().hashCode());
+ System.err.println(getThreadName() + ": !!! GLContext EGL ProcAddressTable mapping key("+key+") -> "+toHexString(getEGLExtProcAddressTable().hashCode()));
}
}
}
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
index ea30c59cf..1503aa73d 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
@@ -142,6 +142,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl
@Override
protected void resetStates() {
// no inner state _cglExt = null;
+ cglExtProcAddressTable = null;
super.resetStates();
}
@@ -307,17 +308,15 @@ public abstract class MacOSXCGLContext extends GLContextImpl
if(null != table) {
cglExtProcAddressTable = (CGLExtProcAddressTable) table;
if(DEBUG) {
- System.err.println(getThreadName() + ": !!! GLContext CGL ProcAddressTable reusing key("+key+") -> "+table.hashCode());
+ System.err.println(getThreadName() + ": !!! GLContext CGL ProcAddressTable reusing key("+key+") -> "+toHexString(table.hashCode()));
}
} else {
- if (cglExtProcAddressTable == null) {
- cglExtProcAddressTable = new CGLExtProcAddressTable(new GLProcAddressResolver());
- }
+ cglExtProcAddressTable = new CGLExtProcAddressTable(new GLProcAddressResolver());
resetProcAddressTable(getCGLExtProcAddressTable());
synchronized(mappedContextTypeObjectLock) {
mappedGLXProcAddress.put(key, getCGLExtProcAddressTable());
if(DEBUG) {
- System.err.println(getThreadName() + ": !!! GLContext CGL ProcAddressTable mapping key("+key+") -> "+getCGLExtProcAddressTable().hashCode());
+ System.err.println(getThreadName() + ": !!! GLContext CGL ProcAddressTable mapping key("+key+") -> "+toHexString(getCGLExtProcAddressTable().hashCode()));
}
}
}
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
index ff59e1518..b2be87f4f 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
@@ -407,19 +407,15 @@ public class WindowsWGLContext extends GLContextImpl {
if(null != table) {
wglExtProcAddressTable = (WGLExtProcAddressTable) table;
if(DEBUG) {
- System.err.println(getThreadName() + ": !!! GLContext WGL ProcAddressTable reusing key("+key+") -> "+table.hashCode());
+ System.err.println(getThreadName() + ": !!! GLContext WGL ProcAddressTable reusing key("+key+") -> "+toHexString(table.hashCode()));
}
} else {
- if (wglExtProcAddressTable == null) {
- // FIXME: cache ProcAddressTables by OpenGL context type bits so we can
- // share them among contexts classes (GL4, GL4bc, GL3, GL3bc, ..)
- wglExtProcAddressTable = new WGLExtProcAddressTable(new GLProcAddressResolver());
- }
+ wglExtProcAddressTable = new WGLExtProcAddressTable(new GLProcAddressResolver());
resetProcAddressTable(wglExtProcAddressTable);
synchronized(mappedContextTypeObjectLock) {
mappedGLXProcAddress.put(key, getWGLExtProcAddressTable());
if(DEBUG) {
- System.err.println(getThreadName() + ": !!! GLContext WGL ProcAddressTable mapping key("+key+") -> "+getWGLExtProcAddressTable().hashCode());
+ System.err.println(getThreadName() + ": !!! GLContext WGL ProcAddressTable mapping key("+key+") -> "+toHexString(getWGLExtProcAddressTable().hashCode()));
}
}
}
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
index c86001969..9b154af95 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
@@ -450,17 +450,15 @@ public abstract class X11GLXContext extends GLContextImpl {
if(null != table) {
glXExtProcAddressTable = (GLXExtProcAddressTable) table;
if(DEBUG) {
- System.err.println(getThreadName() + ": !!! GLContext GLX ProcAddressTable reusing key("+key+") -> "+table.hashCode());
+ System.err.println(getThreadName() + ": !!! GLContext GLX ProcAddressTable reusing key("+key+") -> "+toHexString(table.hashCode()));
}
} else {
- if (glXExtProcAddressTable == null) {
- glXExtProcAddressTable = new GLXExtProcAddressTable(new GLProcAddressResolver());
- }
+ glXExtProcAddressTable = new GLXExtProcAddressTable(new GLProcAddressResolver());
resetProcAddressTable(getGLXExtProcAddressTable());
synchronized(mappedContextTypeObjectLock) {
mappedGLXProcAddress.put(key, getGLXExtProcAddressTable());
if(DEBUG) {
- System.err.println(getThreadName() + ": !!! GLContext GLX ProcAddressTable mapping key("+key+") -> "+getGLXExtProcAddressTable().hashCode());
+ System.err.println(getThreadName() + ": !!! GLContext GLX ProcAddressTable mapping key("+key+") -> "+toHexString(getGLXExtProcAddressTable().hashCode()));
Thread.dumpStack();
}
}