summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2009-10-17 13:44:12 -0700
committerSven Gothel <[email protected]>2009-10-17 13:44:12 -0700
commit4d493ac36bd5d763d2af3243e799bbaef3679594 (patch)
tree3017bab34a8824f706e3ba63f835aaffd3317222 /src
parent5ae314adc19c660f26f32839b2cc224cdccfbb59 (diff)
All tracker are aggregated in the GLContext now
and used within the GL*Impl. New GLStateTracker: - Tracking client/server states - Currently supports PixelStorei - Prologued in glPixelStorei and glGetIntegerv, the latter will return the tracked state if available and not call the GL method. Impacts performance and ES1 compatibility (supports ALIGNMENT). Fixed 'imageSizeInBytes' calculation: - skipPixels and skipRows is a static one time offset
Diffstat (limited to 'src')
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/GLBufferStateTracker.java12
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java20
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/GLStateTracker.java112
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/egl/EGLExternalContext.java1
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXExternalCGLContext.java1
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLContext.java1
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/x11/glx/X11ExternalGLXContext.java1
7 files changed, 90 insertions, 58 deletions
diff --git a/src/jogl/classes/com/sun/opengl/impl/GLBufferStateTracker.java b/src/jogl/classes/com/sun/opengl/impl/GLBufferStateTracker.java
index ddc82eba2..c61d3602d 100755
--- a/src/jogl/classes/com/sun/opengl/impl/GLBufferStateTracker.java
+++ b/src/jogl/classes/com/sun/opengl/impl/GLBufferStateTracker.java
@@ -45,10 +45,8 @@ import javax.media.opengl.*;
/**
* Tracks as closely as possible which OpenGL buffer object is bound
* to which binding target in the current OpenGL context.
- * GLBufferStateTracker objects are allocated on a per-GLImpl basis,
- * which is basically identical to a per-OpenGL-context basis
- * (assuming correct usage of the GLImpl objects, which is checked by
- * the DebugGL). This class is used to verify that e.g. the vertex
+ * GLBufferStateTracker objects are allocated on a per-OpenGL-context basis.
+ * This class is used to verify that e.g. the vertex
* buffer object extension is in use when the glVertexPointer variant
* taking a long as argument is called. <P>
*
@@ -101,8 +99,7 @@ public class GLBufferStateTracker {
}
public void setBoundBufferObject(int target, int buffer) {
- Integer key = box(target);
- bindingMap.put(key, box(buffer));
+ bindingMap.put(box(target), box(buffer));
}
/** Note: returns an unspecified value if the binding for the
@@ -110,8 +107,7 @@ public class GLBufferStateTracker {
You must use isBoundBufferObjectKnown() to see whether the
return value is valid. */
public int getBoundBufferObject(int target, GL caller) {
- Integer key = box(target);
- Integer value = (Integer) bindingMap.get(key);
+ Integer value = (Integer) bindingMap.get(box(target));
if (value == null) {
// User probably either called glPushClientAttrib /
// glPopClientAttrib or is querying an unknown target. See
diff --git a/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java
index 343ca7efe..97100208d 100644
--- a/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java
+++ b/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java
@@ -71,7 +71,9 @@ public abstract class GLContextImpl extends GLContext {
// Tracks creation and initialization of buffer objects to avoid
// repeated glGet calls upon glMapBuffer operations
- private GLBufferSizeTracker bufferSizeTracker;
+ private GLBufferSizeTracker bufferSizeTracker; // Singleton - Set by GLContextShareSet
+ private GLBufferStateTracker bufferStateTracker = new GLBufferStateTracker();
+ private GLStateTracker glStateTracker = new GLStateTracker();
protected GLDrawableImpl drawable;
protected GLDrawableImpl drawableRead;
@@ -232,6 +234,14 @@ public abstract class GLContextImpl extends GLContext {
if (bufferSizeTracker != null) {
bufferSizeTracker.clearCachedBufferSizes();
}
+
+ if (bufferStateTracker != null) {
+ bufferStateTracker.clearBufferObjectState();
+ }
+
+ if (glStateTracker != null) {
+ glStateTracker.clearStates();
+ }
destroyImpl();
} finally {
@@ -512,6 +522,14 @@ public abstract class GLContextImpl extends GLContext {
return bufferSizeTracker;
}
+ public GLBufferStateTracker getBufferStateTracker() {
+ return bufferStateTracker;
+ }
+
+ public GLStateTracker getGLStateTracker() {
+ return glStateTracker;
+ }
+
//---------------------------------------------------------------------------
// Helpers for context optimization where the last context is left
// current on the OpenGL worker thread
diff --git a/src/jogl/classes/com/sun/opengl/impl/GLStateTracker.java b/src/jogl/classes/com/sun/opengl/impl/GLStateTracker.java
index 997951faf..698d20c47 100755
--- a/src/jogl/classes/com/sun/opengl/impl/GLStateTracker.java
+++ b/src/jogl/classes/com/sun/opengl/impl/GLStateTracker.java
@@ -52,22 +52,6 @@ import javax.media.opengl.*;
public class GLStateTracker {
private static final boolean DEBUG = Debug.debug("GLStateTracker");
- private static final Integer GL_PACK_ALIGNMENT = new Integer(GL.GL_PACK_ALIGNMENT);
- private static final Integer GL_PACK_ROW_LENGTH = new Integer(GL2.GL_PACK_ROW_LENGTH);
- private static final Integer GL_PACK_SKIP_ROWS = new Integer(GL2.GL_PACK_SKIP_ROWS);
- private static final Integer GL_PACK_SKIP_PIXELS = new Integer(GL2.GL_PACK_SKIP_PIXELS);
- private static final Integer GL_PACK_IMAGE_HEIGHT = new Integer(GL2.GL_PACK_IMAGE_HEIGHT);
- private static final Integer GL_PACK_SKIP_IMAGES = new Integer(GL2.GL_PACK_SKIP_IMAGES);
-
- private static final Integer GL_UNPACK_ALIGNMENT = new Integer(GL.GL_UNPACK_ALIGNMENT);
- private static final Integer GL_UNPACK_ROW_LENGTH = new Integer(GL2.GL_UNPACK_ROW_LENGTH);
- private static final Integer GL_UNPACK_SKIP_ROWS = new Integer(GL2.GL_UNPACK_SKIP_ROWS);
- private static final Integer GL_UNPACK_SKIP_PIXELS = new Integer(GL2.GL_UNPACK_SKIP_PIXELS);
- private static final Integer GL_UNPACK_IMAGE_HEIGHT = new Integer(GL2.GL_UNPACK_IMAGE_HEIGHT);
- private static final Integer GL_UNPACK_SKIP_IMAGES = new Integer(GL2.GL_UNPACK_SKIP_IMAGES);
-
- private static final Integer zero = new Integer(0);
-
private boolean enabled = true;
private Map/*<Integer,Integer>*/ pixelStateMap = new HashMap/*<Integer,Integer>*/();
@@ -91,24 +75,6 @@ public class GLStateTracker {
resetStates();
}
- public void resetStates() {
- pixelStateMap.clear();
-
- pixelStateMap.put(GL_PACK_ALIGNMENT, new Integer(4));
- pixelStateMap.put(GL_PACK_ROW_LENGTH, zero);
- pixelStateMap.put(GL_PACK_SKIP_ROWS, zero);
- pixelStateMap.put(GL_PACK_SKIP_PIXELS, zero);
- pixelStateMap.put(GL_PACK_IMAGE_HEIGHT, zero);
- pixelStateMap.put(GL_PACK_SKIP_IMAGES, zero);
-
- pixelStateMap.put(GL_UNPACK_ALIGNMENT, new Integer(4));
- pixelStateMap.put(GL_UNPACK_ROW_LENGTH, zero);
- pixelStateMap.put(GL_UNPACK_SKIP_ROWS, zero);
- pixelStateMap.put(GL_UNPACK_SKIP_PIXELS, zero);
- pixelStateMap.put(GL_UNPACK_IMAGE_HEIGHT, zero);
- pixelStateMap.put(GL_UNPACK_SKIP_IMAGES, zero);
- }
-
public void clearStates() {
pixelStateMap.clear();
}
@@ -155,7 +121,7 @@ public class GLStateTracker {
public void pushAttrib(int flags) {
if(enabled) {
SavedState state = new SavedState();
- if( 0 != (flags&GL_CLIENT_PIXEL_STORE_BIT) ) {
+ if( 0 != (flags&GL2.GL_CLIENT_PIXEL_STORE_BIT) ) {
state.putPixelStateMap(pixelStateMap);
}
stack.add(0, state);
@@ -180,30 +146,78 @@ public class GLStateTracker {
}
}
+ private static final Integer GL_PACK_SWAP_BYTES = new Integer(GL2GL3.GL_PACK_SWAP_BYTES);
+ private static final Integer GL_PACK_LSB_FIRST = new Integer(GL2GL3.GL_PACK_LSB_FIRST);
+ private static final Integer GL_PACK_ROW_LENGTH = new Integer(GL2GL3.GL_PACK_ROW_LENGTH);
+ private static final Integer GL_PACK_SKIP_ROWS = new Integer(GL2GL3.GL_PACK_SKIP_ROWS);
+ private static final Integer GL_PACK_SKIP_PIXELS = new Integer(GL2GL3.GL_PACK_SKIP_PIXELS);
+ private static final Integer GL_PACK_ALIGNMENT = new Integer(GL.GL_PACK_ALIGNMENT);
+ private static final Integer GL_PACK_IMAGE_HEIGHT = new Integer(GL2GL3.GL_PACK_IMAGE_HEIGHT);
+ private static final Integer GL_PACK_SKIP_IMAGES = new Integer(GL2GL3.GL_PACK_SKIP_IMAGES);
+
+ private static final Integer GL_UNPACK_SWAP_BYTES = new Integer(GL2GL3.GL_UNPACK_SWAP_BYTES);
+ private static final Integer GL_UNPACK_LSB_FIRST = new Integer(GL2GL3.GL_UNPACK_LSB_FIRST);
+ private static final Integer GL_UNPACK_ROW_LENGTH = new Integer(GL2GL3.GL_UNPACK_ROW_LENGTH);
+ private static final Integer GL_UNPACK_SKIP_ROWS = new Integer(GL2GL3.GL_UNPACK_SKIP_ROWS);
+ private static final Integer GL_UNPACK_SKIP_PIXELS = new Integer(GL2GL3.GL_UNPACK_SKIP_PIXELS);
+ private static final Integer GL_UNPACK_ALIGNMENT = new Integer(GL.GL_UNPACK_ALIGNMENT);
+ private static final Integer GL_UNPACK_IMAGE_HEIGHT = new Integer(GL2GL3.GL_UNPACK_IMAGE_HEIGHT);
+ private static final Integer GL_UNPACK_SKIP_IMAGES = new Integer(GL2GL3.GL_UNPACK_SKIP_IMAGES);
+
+ private static final Integer zero = new Integer(0);
+ private static final Integer one = new Integer(1);
+
private static Integer boxKey(int key) {
switch (key) {
case 0: return zero;
- case GL.GL_PACK_ALIGNMENT: return GL_PACK_ALIGNMENT;
- case GL2.GL_PACK_ROW_LENGTH: return GL_PACK_ROW_LENGTH;
- case GL2.GL_PACK_SKIP_ROWS: return GL_PACK_SKIP_ROWS;
- case GL2.GL_PACK_SKIP_PIXELS: return GL_PACK_SKIP_PIXELS;
- case GL2.GL_PACK_IMAGE_HEIGHT: return GL_PACK_IMAGE_HEIGHT;
- case GL2.GL_PACK_SKIP_IMAGES: return GL_PACK_SKIP_IMAGES;
-
- case GL.GL_UNPACK_ALIGNMENT: return GL_UNPACK_ALIGNMENT;
- case GL2.GL_UNPACK_ROW_LENGTH: return GL_UNPACK_ROW_LENGTH;
- case GL2.GL_UNPACK_SKIP_ROWS: return GL_UNPACK_SKIP_ROWS;
- case GL2.GL_UNPACK_SKIP_PIXELS: return GL_UNPACK_SKIP_PIXELS;
- case GL2.GL_UNPACK_IMAGE_HEIGHT: return GL_UNPACK_IMAGE_HEIGHT;
- case GL2.GL_UNPACK_SKIP_IMAGES: return GL_UNPACK_SKIP_IMAGES;
+ case GL2GL3.GL_PACK_SWAP_BYTES: return GL_PACK_SWAP_BYTES;
+ case GL2GL3.GL_PACK_LSB_FIRST: return GL_PACK_LSB_FIRST;
+ case GL2GL3.GL_PACK_ROW_LENGTH: return GL_PACK_ROW_LENGTH;
+ case GL2GL3.GL_PACK_SKIP_ROWS: return GL_PACK_SKIP_ROWS;
+ case GL2GL3.GL_PACK_SKIP_PIXELS: return GL_PACK_SKIP_PIXELS;
+ case GL.GL_PACK_ALIGNMENT: return GL_PACK_ALIGNMENT;
+ case GL2GL3.GL_PACK_IMAGE_HEIGHT: return GL_PACK_IMAGE_HEIGHT;
+ case GL2GL3.GL_PACK_SKIP_IMAGES: return GL_PACK_SKIP_IMAGES;
+
+ case GL2GL3.GL_UNPACK_SWAP_BYTES: return GL_UNPACK_SWAP_BYTES;
+ case GL2GL3.GL_UNPACK_LSB_FIRST: return GL_UNPACK_LSB_FIRST;
+ case GL2GL3.GL_UNPACK_ROW_LENGTH: return GL_UNPACK_ROW_LENGTH;
+ case GL2GL3.GL_UNPACK_SKIP_ROWS: return GL_UNPACK_SKIP_ROWS;
+ case GL2GL3.GL_UNPACK_SKIP_PIXELS: return GL_UNPACK_SKIP_PIXELS;
+ case GL.GL_UNPACK_ALIGNMENT: return GL_UNPACK_ALIGNMENT;
+ case GL2GL3.GL_UNPACK_IMAGE_HEIGHT: return GL_UNPACK_IMAGE_HEIGHT;
+ case GL2GL3.GL_UNPACK_SKIP_IMAGES: return GL_UNPACK_SKIP_IMAGES;
default: return null;
}
}
+ public void resetStates() {
+ pixelStateMap.clear();
+
+ pixelStateMap.put(GL_PACK_SWAP_BYTES, zero /* GL_FALSE */);
+ pixelStateMap.put(GL_PACK_LSB_FIRST, zero /* GL_FALSE */);
+ pixelStateMap.put(GL_PACK_ROW_LENGTH, zero);
+ pixelStateMap.put(GL_PACK_SKIP_ROWS, zero);
+ pixelStateMap.put(GL_PACK_SKIP_PIXELS, zero);
+ pixelStateMap.put(GL_PACK_ALIGNMENT, new Integer(4));
+ pixelStateMap.put(GL_PACK_IMAGE_HEIGHT, zero);
+ pixelStateMap.put(GL_PACK_SKIP_IMAGES, zero);
+
+ pixelStateMap.put(GL_UNPACK_SWAP_BYTES, zero /* GL_FALSE */);
+ pixelStateMap.put(GL_UNPACK_LSB_FIRST, zero /* GL_FALSE */);
+ pixelStateMap.put(GL_UNPACK_ROW_LENGTH, zero);
+ pixelStateMap.put(GL_UNPACK_SKIP_ROWS, zero);
+ pixelStateMap.put(GL_UNPACK_SKIP_PIXELS, zero);
+ pixelStateMap.put(GL_UNPACK_ALIGNMENT, new Integer(4));
+ pixelStateMap.put(GL_UNPACK_IMAGE_HEIGHT, zero);
+ pixelStateMap.put(GL_UNPACK_SKIP_IMAGES, zero);
+ }
+
private static Integer boxInt(int value) {
switch (value) {
- case 0: return zero;
+ case 0: return zero;
+ case 1: return one;
default: return new Integer(value);
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLExternalContext.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLExternalContext.java
index 1635e8d63..86c82396e 100755
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLExternalContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLExternalContext.java
@@ -48,6 +48,7 @@ public class EGLExternalContext extends EGLContext {
super(null, null);
GLContextShareSet.contextCreated(this);
setGLFunctionAvailability(false);
+ getGLStateTracker().setEnabled(false); // external context usage can't track state in Java
}
public int makeCurrent() throws GLException {
diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXExternalCGLContext.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXExternalCGLContext.java
index 03116f6bd..0e468e5c5 100644
--- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXExternalCGLContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXExternalCGLContext.java
@@ -57,6 +57,7 @@ public class MacOSXExternalCGLContext extends MacOSXCGLContext {
this.nsContext = nsContext;
GLContextShareSet.contextCreated(this);
setGLFunctionAvailability(false);
+ getGLStateTracker().setEnabled(false); // external context usage can't track state in Java
}
protected static MacOSXExternalCGLContext create(GLDrawableFactory factory, GLProfile glp) {
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLContext.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLContext.java
index 31e65fc8c..b433b6b38 100755
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLContext.java
@@ -60,6 +60,7 @@ public class WindowsExternalWGLContext extends WindowsWGLContext {
GLContextShareSet.contextCreated(this);
setGLFunctionAvailability(false);
cfg.updateCapabilitiesByWGL(this);
+ getGLStateTracker().setEnabled(false); // external context usage can't track state in Java
}
protected static WindowsExternalWGLContext create(GLDrawableFactory factory, GLProfile glp) {
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11ExternalGLXContext.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11ExternalGLXContext.java
index b509447f7..7e3755870 100755
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11ExternalGLXContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11ExternalGLXContext.java
@@ -56,6 +56,7 @@ public class X11ExternalGLXContext extends X11GLXContext {
this.context = context;
GLContextShareSet.contextCreated(this);
setGLFunctionAvailability(false);
+ getGLStateTracker().setEnabled(false); // external context usage can't track state in Java
}
protected static X11ExternalGLXContext create(GLDrawableFactory factory, GLProfile glp) {