aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/GLContextImpl.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-01-14 19:38:49 +0100
committerSven Gothel <[email protected]>2014-01-14 19:38:49 +0100
commitf8a74c9831c65725a699320c27e62161a0378241 (patch)
treed98f024c84ab31404e4b8bb7608dd60941965f4b /src/jogl/classes/jogamp/opengl/GLContextImpl.java
parent961930f9e2cd40dc4de736201bcfa68c1ff09909 (diff)
Revert "Bug 942 - Share GLBufferStateTracker ; Unify GLBufferStateTracker and GLBufferSizeTracker (simplification)"
This reverts commit 7c5483d5b20aed9c87c5ce3f6bc840b6546edcd1.
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/GLContextImpl.java')
-rw-r--r--src/jogl/classes/jogamp/opengl/GLContextImpl.java28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
index 8bbc82b5a..8f1ba4585 100644
--- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
@@ -102,7 +102,8 @@ public abstract class GLContextImpl extends GLContext {
// Tracks creation and initialization of buffer objects to avoid
// repeated glGet calls upon glMapBuffer operations
- private final GLBufferStateTracker bufferStateTracker;
+ private GLBufferSizeTracker bufferSizeTracker; // Singleton - Set by GLContextShareSet
+ private final GLBufferStateTracker bufferStateTracker = new GLBufferStateTracker();
private final GLStateTracker glStateTracker = new GLStateTracker();
private GLDebugMessageHandler glDebugHandler = null;
private final int[] boundFBOTarget = new int[] { 0, 0 }; // { draw, read }
@@ -137,13 +138,10 @@ public abstract class GLContextImpl extends GLContext {
public GLContextImpl(GLDrawableImpl drawable, GLContext shareWith) {
super();
- if ( null != shareWith ) {
+ if (shareWith != null) {
GLContextShareSet.registerSharing(this, shareWith);
- bufferStateTracker = ((GLContextImpl)shareWith).getBufferStateTracker();
- assert (bufferStateTracker != null) : "shared context hash null bufferStateTracker: "+shareWith;
- } else {
- bufferStateTracker = new GLBufferStateTracker();
}
+ GLContextShareSet.synchronizeBufferObjectSharing(shareWith, this);
this.drawable = drawable;
this.drawableRead = drawable;
@@ -152,9 +150,15 @@ public abstract class GLContextImpl extends GLContext {
}
private final void clearStates() {
- if( !GLContextShareSet.hasCreatedSharedLeft(this) ) {
- bufferStateTracker.clear();
+ // Because we don't know how many other contexts we might be
+ // sharing with (and it seems too complicated to implement the
+ // GLObjectTracker's ref/unref scheme for the buffer-related
+ // optimizations), simply clear the cache of known buffers' sizes
+ // when we destroy contexts
+ if (bufferSizeTracker != null) {
+ bufferSizeTracker.clearCachedBufferSizes();
}
+ bufferStateTracker.clearBufferObjectState();
glStateTracker.setEnabled(false);
glStateTracker.clearStates();
}
@@ -2119,6 +2123,14 @@ public abstract class GLContextImpl extends GLContext {
//----------------------------------------------------------------------
// Helpers for buffer object optimizations
+ public final void setBufferSizeTracker(GLBufferSizeTracker bufferSizeTracker) {
+ this.bufferSizeTracker = bufferSizeTracker;
+ }
+
+ public final GLBufferSizeTracker getBufferSizeTracker() {
+ return bufferSizeTracker;
+ }
+
public final GLBufferStateTracker getBufferStateTracker() {
return bufferStateTracker;
}