diff options
author | Sven Gothel <[email protected]> | 2014-01-14 07:37:26 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-01-14 07:37:26 +0100 |
commit | 7c5483d5b20aed9c87c5ce3f6bc840b6546edcd1 (patch) | |
tree | d991b71ce688d981eb14c1ef2174f2140b564467 /src/jogl/classes/jogamp/opengl/GLContextImpl.java | |
parent | 6c971f91fbe6a7e3bc45563d80d42a753586d629 (diff) |
Bug 942 - Share GLBufferStateTracker ; Unify GLBufferStateTracker and GLBufferSizeTracker (simplification)
Due to future mapped buffer tracking, the GLBufferStateTracker instance shall be shared
across shared GLContextImpl instances similar to GLSizeStateTracker!
This allows us to merge GLSizeStateTracker code into GLBufferStateTracker
to simplify the implementation.
+++
Clear the GLBufferStateTracker (@destruction) only if no more
created shares are left!
+++
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/GLContextImpl.java')
-rw-r--r-- | src/jogl/classes/jogamp/opengl/GLContextImpl.java | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 8f1ba4585..8bbc82b5a 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -102,8 +102,7 @@ public abstract class GLContextImpl extends GLContext { // Tracks creation and initialization of buffer objects to avoid // repeated glGet calls upon glMapBuffer operations - private GLBufferSizeTracker bufferSizeTracker; // Singleton - Set by GLContextShareSet - private final GLBufferStateTracker bufferStateTracker = new GLBufferStateTracker(); + private final GLBufferStateTracker bufferStateTracker; private final GLStateTracker glStateTracker = new GLStateTracker(); private GLDebugMessageHandler glDebugHandler = null; private final int[] boundFBOTarget = new int[] { 0, 0 }; // { draw, read } @@ -138,10 +137,13 @@ public abstract class GLContextImpl extends GLContext { public GLContextImpl(GLDrawableImpl drawable, GLContext shareWith) { super(); - if (shareWith != null) { + if ( null != shareWith ) { 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; @@ -150,15 +152,9 @@ public abstract class GLContextImpl extends GLContext { } private final void clearStates() { - // 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(); + if( !GLContextShareSet.hasCreatedSharedLeft(this) ) { + bufferStateTracker.clear(); } - bufferStateTracker.clearBufferObjectState(); glStateTracker.setEnabled(false); glStateTracker.clearStates(); } @@ -2123,14 +2119,6 @@ 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; } |