summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/GLBufferObjectTracker.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-04-02 19:25:16 +0200
committerSven Gothel <[email protected]>2014-04-02 19:25:16 +0200
commitabc833631e0ab30a06c7aff47a39a551544fd735 (patch)
tree1d6e5a94d2149d7b2635de5b5eccb330bc41cd2c /src/jogl/classes/jogamp/opengl/GLBufferObjectTracker.java
parente8a5a1cbb988670ca206ab1ac633e19a91bfa478 (diff)
Bug 801: Reduce temp. object creation, i.e. GC load
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/GLBufferObjectTracker.java')
-rw-r--r--src/jogl/classes/jogamp/opengl/GLBufferObjectTracker.java44
1 files changed, 27 insertions, 17 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLBufferObjectTracker.java b/src/jogl/classes/jogamp/opengl/GLBufferObjectTracker.java
index 2351826cb..483b9b526 100644
--- a/src/jogl/classes/jogamp/opengl/GLBufferObjectTracker.java
+++ b/src/jogl/classes/jogamp/opengl/GLBufferObjectTracker.java
@@ -109,11 +109,11 @@ public class GLBufferObjectTracker {
GLBufferStorageImpl(final int name, final long size, final int mutableUsage, final int immutableFlags) {
super(name, size, mutableUsage, immutableFlags);
}
- final void setMappedBuffer(final ByteBuffer bb) {
- if (DEBUG) {
- System.err.printf("%s.GLBufferStorage.setMappedBuffer: %s: %s -> %s%n", msgClazzName, toString(true), mappedBuffer, bb);
- }
- mappedBuffer = bb;
+ protected final void reset(final long size, final int mutableUsage, final int immutableFlags) {
+ super.reset(size, mutableUsage, immutableFlags);
+ }
+ protected final void setMappedBuffer(final ByteBuffer buffer) {
+ super.setMappedBuffer(buffer);
}
}
@@ -169,13 +169,18 @@ public class GLBufferObjectTracker {
throw new GLException(String.format("GL-Error 0x%X while creating %s storage for target 0x%X -> buffer %d of size %d with data %s",
glerrPost, mutableBuffer ? "mutable" : "immutable", target, bufferName, size, data));
}
- final GLBufferStorageImpl objNew = new GLBufferStorageImpl(bufferName, size, mutableUsage, immutableFlags);
- final GLBufferStorageImpl objOld = (GLBufferStorageImpl) bufferName2StorageMap.put(bufferName, objNew);
- if (DEBUG) {
- System.err.printf("%s.%s target: 0x%X -> %d: %s -> %s%n", msgClazzName, msgCreateBound, target, bufferName, objOld, objNew);
- }
+ final GLBufferStorageImpl objOld = (GLBufferStorageImpl) bufferName2StorageMap.get(bufferName);
if( null != objOld ) {
- objOld.setMappedBuffer(null);
+ objOld.reset(size, mutableUsage, immutableFlags);
+ if (DEBUG) {
+ System.err.printf("%s.%s target: 0x%X -> reset %d: %s%n", msgClazzName, msgCreateBound, target, bufferName, objOld);
+ }
+ } else {
+ final GLBufferStorageImpl objNew = new GLBufferStorageImpl(bufferName, size, mutableUsage, immutableFlags);
+ bufferName2StorageMap.put(bufferName, objNew);
+ if (DEBUG) {
+ System.err.printf("%s.%s target: 0x%X -> new %d: %s%n", msgClazzName, msgCreateBound, target, bufferName, objNew);
+ }
}
}
@@ -209,13 +214,18 @@ public class GLBufferObjectTracker {
throw new GLException(String.format("GL-Error 0x%X while creating %s storage for buffer %d of size %d with data %s",
glerrPost, "mutable", bufferName, size, data));
}
- final GLBufferStorageImpl objNew = new GLBufferStorageImpl(bufferName, size, mutableUsage, 0 /* immutableFlags */);
- final GLBufferStorageImpl objOld = (GLBufferStorageImpl) bufferName2StorageMap.put(bufferName, objNew);
- if (DEBUG) {
- System.err.printf("%s.%s direct: %d: %s -> %s%n", msgClazzName, msgCreateNamed, bufferName, objOld, objNew);
- }
+ final GLBufferStorageImpl objOld = (GLBufferStorageImpl) bufferName2StorageMap.get(bufferName);
if( null != objOld ) {
- objOld.setMappedBuffer(null);
+ objOld.reset(size, mutableUsage, immutableFlags);
+ if (DEBUG) {
+ System.err.printf("%s.%s direct: reset %d: %s%n", msgClazzName, msgCreateNamed, bufferName, objOld);
+ }
+ } else {
+ final GLBufferStorageImpl objNew = new GLBufferStorageImpl(bufferName, size, mutableUsage, immutableFlags);
+ bufferName2StorageMap.put(bufferName, objNew);
+ if (DEBUG) {
+ System.err.printf("%s.%s direct: new %d: %s%n", msgClazzName, msgCreateNamed, bufferName, objNew);
+ }
}
}