aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/com/sun/opengl/impl/GLContextImpl.java
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2006-11-26 06:02:27 +0000
committerKenneth Russel <[email protected]>2006-11-26 06:02:27 +0000
commit3d445e164c242fb050dc6ecc8ca736731f7bcc67 (patch)
tree70b7ad77ca6090583fb6bc8a016c6b8ffaad1b40 /src/classes/com/sun/opengl/impl/GLContextImpl.java
parent643849d65648411b55281ea5c87878e148dda97b (diff)
Fixed another performance problem related to buffer objects pointed
out by John Burkey. glGetBufferParameterivARB call in glMapBuffer was too expensive at least with Apple's multithreaded OpenGL implementation. Now track both bound buffer state (refactored into GLBufferStateTracker) as well as cache created buffers' sizes (expressed in GLBufferSizeTracker) and query the cache instead of OpenGL directly. Verified with VertexBufferObject demo that now no glGet queries are made at run-time. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@1003 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/classes/com/sun/opengl/impl/GLContextImpl.java')
-rw-r--r--src/classes/com/sun/opengl/impl/GLContextImpl.java27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/classes/com/sun/opengl/impl/GLContextImpl.java b/src/classes/com/sun/opengl/impl/GLContextImpl.java
index fcd1e58be..21e6d6598 100644
--- a/src/classes/com/sun/opengl/impl/GLContextImpl.java
+++ b/src/classes/com/sun/opengl/impl/GLContextImpl.java
@@ -68,6 +68,10 @@ public abstract class GLContextImpl extends GLContext {
// OpenGL functions.
private GLProcAddressTable glProcAddressTable;
+ // Tracks creation and initialization of buffer objects to avoid
+ // repeated glGet calls upon glMapBuffer operations
+ private GLBufferSizeTracker bufferSizeTracker;
+
// Tracks creation and deletion of server-side OpenGL objects when
// the Java2D/OpenGL pipeline is active and using FBOs to render
private GLObjectTracker tracker;
@@ -81,7 +85,6 @@ public abstract class GLContextImpl extends GLContext {
}
public GLContextImpl(GLContext shareWith, boolean dontShareWithJava2D) {
- setGL(createGL());
functionAvailability = new FunctionAvailabilityCache(this);
GLContext shareContext = shareWith;
if (!dontShareWithJava2D) {
@@ -95,6 +98,10 @@ public abstract class GLContextImpl extends GLContext {
shareContext = Java2D.filterShareContext(shareWith);
}
GLContextShareSet.registerForObjectTracking(shareWith, this, shareContext);
+ GLContextShareSet.registerForBufferObjectSharing(shareWith, this);
+ // This must occur after the above calls into the
+ // GLContextShareSet, which set up state needed by the GL object
+ setGL(createGL());
}
public int makeCurrent() throws GLException {
@@ -184,6 +191,13 @@ public abstract class GLContextImpl extends GLContext {
}
}
+ // 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
+ bufferSizeTracker.clearCachedBufferSizes();
+
// Must hold the lock around the destroy operation to make sure we
// don't destroy the context out from under another thread rendering to it
lock.lock();
@@ -361,6 +375,17 @@ public abstract class GLContextImpl extends GLContext {
return "0x" + Long.toHexString(hex);
}
+ //----------------------------------------------------------------------
+ // Helpers for buffer object optimizations
+
+ public void setBufferSizeTracker(GLBufferSizeTracker bufferSizeTracker) {
+ this.bufferSizeTracker = bufferSizeTracker;
+ }
+
+ public GLBufferSizeTracker getBufferSizeTracker() {
+ return bufferSizeTracker;
+ }
+
//---------------------------------------------------------------------------
// Helpers for integration with Java2D/OpenGL pipeline when FBOs are
// being used