aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-08-01 15:14:39 +0200
committerSven Gothel <[email protected]>2011-08-01 15:14:39 +0200
commit2dbd16fc3edf29b39ba37a11b9fbf1b2aad75c45 (patch)
tree70367f094a969e9387b506cef79ee846b0bd6d3b /src
parent0f0f6162cfbce1ad7db86e7e627721c4c918933c (diff)
StateTracker: Map's KeyNotFound value -1 -> 0xffffffff... allowing unusual values. Impl -> final.
Map's KeyNotFound value -1 -> 0xffffffff Turns out some GL impl. use VBO names like 0xa2d67443, which is (int) < 0. This is now handled in GLBufferStateTracker as well as for the others. Make methods final to restrict 'em.
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/jogamp/opengl/GLBufferSizeTracker.java18
-rw-r--r--src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java44
-rw-r--r--src/jogl/classes/jogamp/opengl/GLStateTracker.java28
3 files changed, 55 insertions, 35 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLBufferSizeTracker.java b/src/jogl/classes/jogamp/opengl/GLBufferSizeTracker.java
index fc8be95e9..dc121323e 100644
--- a/src/jogl/classes/jogamp/opengl/GLBufferSizeTracker.java
+++ b/src/jogl/classes/jogamp/opengl/GLBufferSizeTracker.java
@@ -100,11 +100,11 @@ public class GLBufferSizeTracker {
public GLBufferSizeTracker() {
bufferSizeMap = new IntLongHashMap();
- bufferSizeMap.setKeyNotFoundValue(-1);
+ bufferSizeMap.setKeyNotFoundValue(0xFFFFFFFFFFFFFFFFL);
}
- public void setBufferSize(GLBufferStateTracker bufferStateTracker,
- int target, GL caller, long size) {
+ public final void setBufferSize(GLBufferStateTracker bufferStateTracker,
+ int target, GL caller, long size) {
// Need to do some similar queries to getBufferSize below
int buffer = bufferStateTracker.getBoundBufferObject(target, caller);
if (buffer != 0) {
@@ -116,11 +116,11 @@ public class GLBufferSizeTracker {
// left to do except drop this piece of information on the floor.
}
- public void setDirectStateBufferSize(int buffer, GL caller, long size) {
+ public final void setDirectStateBufferSize(int buffer, GL caller, long size) {
bufferSizeMap.put(buffer, size);
}
- public long getBufferSize(GLBufferStateTracker bufferStateTracker,
+ public final long getBufferSize(GLBufferStateTracker bufferStateTracker,
int target,
GL caller) {
// See whether we know what buffer is currently bound to the given
@@ -140,16 +140,16 @@ public class GLBufferSizeTracker {
return (long) tmp[0];
}
- public long getDirectStateBufferSize(int buffer, GL caller) {
+ public final long getDirectStateBufferSize(int buffer, GL caller) {
return getBufferSizeImpl(0, buffer, caller);
}
- private long getBufferSizeImpl(int target, int buffer, GL caller) {
+ private final long getBufferSizeImpl(int target, int buffer, GL caller) {
// See whether we know the size of this buffer object; at this
// point we almost certainly should if the application is
// written correctly
long sz = bufferSizeMap.get(buffer);
- if (0 > sz) {
+ if (0xFFFFFFFFFFFFFFFFL == sz) {
// For robustness, try to query this value from the GL as we used to
// FIXME: both functions return 'int' types, which is not suitable,
// since buffer lenght is 64bit ?
@@ -188,7 +188,7 @@ public class GLBufferSizeTracker {
// destruction if we don't know whether there are other currently-
// created contexts that might be keeping the buffer objects alive
// that we're dealing with
- public void clearCachedBufferSizes() {
+ public final void clearCachedBufferSizes() {
bufferSizeMap.clear();
}
}
diff --git a/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java b/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java
index 5a31431d8..c7e27da2a 100644
--- a/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java
+++ b/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java
@@ -40,6 +40,8 @@
package jogamp.opengl;
+import java.util.HashMap;
+
import javax.media.opengl.*;
import com.jogamp.common.util.IntIntHashMap;
@@ -89,26 +91,32 @@ public class GLBufferStateTracker {
public GLBufferStateTracker() {
bindingMap = new IntIntHashMap();
- bindingMap.setKeyNotFoundValue(-1);
+ bindingMap.setKeyNotFoundValue(0xFFFFFFFF);
// Start with known unbound targets for known keys
- bindingMap.put(GL.GL_ARRAY_BUFFER, 0);
- bindingMap.put(GL.GL_ELEMENT_ARRAY_BUFFER, 0);
- bindingMap.put(GL2.GL_PIXEL_PACK_BUFFER, 0);
- bindingMap.put(GL2.GL_PIXEL_UNPACK_BUFFER, 0);
+ setBoundBufferObject(GL.GL_ARRAY_BUFFER, 0);
+ setBoundBufferObject(GL.GL_ELEMENT_ARRAY_BUFFER, 0);
+ setBoundBufferObject(GL2.GL_PIXEL_PACK_BUFFER, 0);
+ setBoundBufferObject(GL2.GL_PIXEL_UNPACK_BUFFER, 0);
}
- public void setBoundBufferObject(int target, int buffer) {
+ public final void setBoundBufferObject(int target, int buffer) {
bindingMap.put(target, buffer);
+ if (DEBUG) {
+ System.err.println();
+ System.err.println("GLBufferStateTracker.setBoundBufferObject(): mapped bound buffer 0x" +
+ Integer.toHexString(buffer) + " for query target 0x" + Integer.toHexString(target));
+ Thread.dumpStack();
+ }
}
/** Note: returns an unspecified value if the binding for the
specified target (e.g. GL_ARRAY_BUFFER) is currently unknown.
You must use isBoundBufferObjectKnown() to see whether the
return value is valid. */
- public int getBoundBufferObject(int target, GL caller) {
+ public final int getBoundBufferObject(int target, GL caller) {
int value = bindingMap.get(target);
- if (0 > value) {
+ if (0xFFFFFFFF == value) {
// User probably either called glPushClientAttrib /
// glPopClientAttrib or is querying an unknown target. See
// whether we know how to fetch this state.
@@ -124,15 +132,22 @@ public class GLBufferStateTracker {
if (gotQueryTarget) {
caller.glGetIntegerv(queryTarget, bufTmp, 0);
if (DEBUG) {
- System.err.println("GLBufferStateTracker.getBoundBufferObject(): queried bound buffer " +
- bufTmp[0] +
- " for query target 0x" + Integer.toHexString(queryTarget));
+ System.err.println();
+ System.err.println("GLBufferStateTracker.getBoundBufferObject(): queried bound buffer 0x" +
+ Integer.toHexString(bufTmp[0]) +
+ " for target 0x" + Integer.toHexString(target)+" / query 0x"+Integer.toHexString(queryTarget));
}
setBoundBufferObject(target, bufTmp[0]);
return bufTmp[0];
}
return 0;
}
+ if (DEBUG) {
+ System.err.println();
+ System.err.println("GLBufferStateTracker.getBoundBufferObject(): mapped bound buffer 0x" +
+ Integer.toHexString(value) + " for query target 0x" + Integer.toHexString(target));
+ Thread.dumpStack();
+ }
return value;
}
@@ -143,7 +158,12 @@ public class GLBufferStateTracker {
from GLContext.makeCurrent() in the future to possibly increase
the robustness of these caches in the face of external native
code manipulating OpenGL state. */
- public void clearBufferObjectState() {
+ public final void clearBufferObjectState() {
bindingMap.clear();
+ if (DEBUG) {
+ System.err.println();
+ System.err.println("GLBufferStateTracker.clearBufferObjectState()");
+ Thread.dumpStack();
+ }
}
}
diff --git a/src/jogl/classes/jogamp/opengl/GLStateTracker.java b/src/jogl/classes/jogamp/opengl/GLStateTracker.java
index 3bf06ac7a..391f96aed 100644
--- a/src/jogl/classes/jogamp/opengl/GLStateTracker.java
+++ b/src/jogl/classes/jogamp/opengl/GLStateTracker.java
@@ -75,45 +75,45 @@ public class GLStateTracker {
/**
* set (client) pixel-store state, deep copy
*/
- private void setPixelStateMap(IntIntHashMap pixelStateMap) {
+ private final void setPixelStateMap(IntIntHashMap pixelStateMap) {
this.pixelStateMap = (IntIntHashMap) pixelStateMap.clone();
}
/**
* get (client) pixel-store state, return reference
*/
- private IntIntHashMap getPixelStateMap() { return pixelStateMap; }
+ private final IntIntHashMap getPixelStateMap() { return pixelStateMap; }
}
public GLStateTracker() {
pixelStateMap = new IntIntHashMap(PIXEL_STATE_MAP_CAPACITY, 0.75f);
- pixelStateMap.setKeyNotFoundValue(-1);
+ pixelStateMap.setKeyNotFoundValue(0xFFFFFFFF);
resetStates();
stack = new ArrayList<SavedState>(MIN_CLIENT_ATTRIB_STACK_DEPTH);
}
- public void clearStates(boolean enable) {
+ public final void clearStates(boolean enable) {
enabled = enable;
pixelStateMap.clear();
}
- public void setEnabled(boolean on) {
+ public final void setEnabled(boolean on) {
enabled = on;
}
- public boolean isEnabled() {
+ public final boolean isEnabled() {
return enabled;
}
/** @return true if found in our map, otherwise false,
* which forces the caller to query GL. */
- public boolean getInt(int pname, int[] params, int params_offset) {
+ public final boolean getInt(int pname, int[] params, int params_offset) {
if(enabled) {
int value = pixelStateMap.get(pname);
- if(0 <= value) {
+ if(0xFFFFFFFF != value) {
params[params_offset] = value;
return true;
}
@@ -123,10 +123,10 @@ public class GLStateTracker {
/** @return true if found in our map, otherwise false,
* which forces the caller to query GL. */
- public boolean getInt(int pname, IntBuffer params, int dummy) {
+ public final boolean getInt(int pname, IntBuffer params, int dummy) {
if(enabled) {
int value = pixelStateMap.get(pname);
- if(0 <= value) {
+ if(0xFFFFFFFF != value) {
params.put(params.position(), value);
return true;
}
@@ -134,13 +134,13 @@ public class GLStateTracker {
return false;
}
- public void setInt(int pname, int param) {
+ public final void setInt(int pname, int param) {
if(enabled) {
pixelStateMap.put(pname, param);
}
}
- public void pushAttrib(int flags) {
+ public final void pushAttrib(int flags) {
if(enabled) {
SavedState state = new SavedState(); // empty-slot
if( 0 != (flags&GL2.GL_CLIENT_PIXEL_STORE_BIT) ) {
@@ -151,7 +151,7 @@ public class GLStateTracker {
}
}
- public void popAttrib() {
+ public final void popAttrib() {
if(enabled) {
if(stack.isEmpty()) {
throw new GLException("stack contains no elements");
@@ -169,7 +169,7 @@ public class GLStateTracker {
}
}
- private void resetStates() {
+ private final void resetStates() {
pixelStateMap.clear();
// 16 values -> PIXEL_STATE_MAP_SIZE