Permalink
Browse files

Added remaining implementations for new IVertexBufferObject methods. …

…Added cummulative getters for memory usage of loaded VertexBufferObjects in the VertexBufferObjectManager. Minor javadoc update in IVertexBufferObject.
  • Loading branch information...
1 parent 06ef700 commit 0366ae3096cfa2ff9277fc856e6d184f6fb8f45e Nicolas Gramlich committed Feb 11, 2012
@@ -28,7 +28,10 @@
public int getHardwareBufferID();
public boolean isLoadedToHardware();
- /** Mark this {@link VertexBufferObject} as not not loaded to hardware, so it gets loaded to hardware before being used.. */
+ /**
+ * Mark this {@link VertexBufferObject} as not not loaded to hardware.
+ * It will reload itself to hardware when it gets used again.
+ */
public void setNotLoadedToHardware();
public void unloadFromHardware(final GLState pGLState);
@@ -32,13 +32,29 @@
// Getter & Setter
// ===========================================================
- // TODO public synchronized int getPermamentByteSize() {
+ public synchronized int getHeapMemoryByteSize() {
+ int byteSize = 0;
+ final ArrayList<IVertexBufferObject> vertexBufferObjectsLoaded = this.mVertexBufferObjectsLoaded;
+ for(int i = vertexBufferObjectsLoaded.size() - 1; i >= 0; i--) {
+ byteSize += vertexBufferObjectsLoaded.get(i).getHeapMemoryByteSize();
+ }
+ return byteSize;
+ }
+
+ public synchronized int getNativeHeapMemoryByteSize() {
+ int byteSize = 0;
+ final ArrayList<IVertexBufferObject> vertexBufferObjectsLoaded = this.mVertexBufferObjectsLoaded;
+ for(int i = vertexBufferObjectsLoaded.size() - 1; i >= 0; i--) {
+ byteSize += vertexBufferObjectsLoaded.get(i).getNativeHeapMemoryByteSize();
+ }
+ return byteSize;
+ }
- public synchronized int getByteSize() {
+ public synchronized int getGPUHeapMemoryByteSize() {
int byteSize = 0;
final ArrayList<IVertexBufferObject> vertexBufferObjectsLoaded = this.mVertexBufferObjectsLoaded;
for(int i = vertexBufferObjectsLoaded.size() - 1; i >= 0; i--) {
- byteSize += vertexBufferObjectsLoaded.get(i).getByteCapacity();
+ byteSize += vertexBufferObjectsLoaded.get(i).getGPUMemoryByteSize();
}
return byteSize;
}
@@ -129,6 +129,15 @@ public int getNativeHeapMemoryByteSize() {
return 0;
}
+ @Override
+ public int getGPUMemoryByteSize() {
+ if(this.isLoadedToHardware()) {
+ return this.getByteCapacity();
+ } else {
+ return 0;
+ }
+ }
+
// ===========================================================
// Methods for/from SuperClass/Interfaces
// ===========================================================

0 comments on commit 0366ae3

Please sign in to comment.