reset static buffer-usage-count on init, formatting..
This commit is contained in:
parent
004ad338ae
commit
59533d823b
@ -26,11 +26,8 @@ public final class BufferObject {
|
|||||||
private static final int MB = 1024 * 1024;
|
private static final int MB = 1024 * 1024;
|
||||||
private static final int LIMIT_BUFFERS = 16 * MB;
|
private static final int LIMIT_BUFFERS = 16 * MB;
|
||||||
|
|
||||||
|
// GL identifier
|
||||||
// -------------------------------------------------------------
|
|
||||||
// GL id
|
|
||||||
public int id;
|
public int id;
|
||||||
|
|
||||||
// allocated bytes
|
// allocated bytes
|
||||||
public int size;
|
public int size;
|
||||||
|
|
||||||
@ -42,10 +39,10 @@ public final class BufferObject {
|
|||||||
|
|
||||||
int bufferType;
|
int bufferType;
|
||||||
|
|
||||||
public void loadBufferData(ShortBuffer buf, int newSize, int type){
|
public void loadBufferData(ShortBuffer buf, int newSize, int type) {
|
||||||
boolean clear = false;
|
boolean clear = false;
|
||||||
|
|
||||||
if (type != bufferType){
|
if (type != bufferType) {
|
||||||
if (bufferType != 0)
|
if (bufferType != 0)
|
||||||
clear = true;
|
clear = true;
|
||||||
bufferType = type;
|
bufferType = type;
|
||||||
@ -55,7 +52,7 @@ public final class BufferObject {
|
|||||||
|
|
||||||
// reuse memory allocated for vbo when possible and allocated
|
// reuse memory allocated for vbo when possible and allocated
|
||||||
// memory is less then four times the new data
|
// memory is less then four times the new data
|
||||||
if (!clear && (size > newSize) && (size < newSize * 4)){
|
if (!clear && (size > newSize) && (size < newSize * 4)) {
|
||||||
GLES20.glBufferSubData(type, 0, newSize, buf);
|
GLES20.glBufferSubData(type, 0, newSize, buf);
|
||||||
} else {
|
} else {
|
||||||
mBufferMemoryUsage += newSize - size;
|
mBufferMemoryUsage += newSize - size;
|
||||||
@ -66,11 +63,11 @@ public final class BufferObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bindArrayBuffer(){
|
public void bindArrayBuffer() {
|
||||||
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, id);
|
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bindIndexBuffer(){
|
public void bindIndexBuffer() {
|
||||||
GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, id);
|
GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,9 +80,11 @@ public final class BufferObject {
|
|||||||
if (mBufferMemoryUsage < LIMIT_BUFFERS)
|
if (mBufferMemoryUsage < LIMIT_BUFFERS)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Log.d(TAG, "buffer object usage: " + mBufferMemoryUsage / MB + "MB");
|
Log.d(TAG, "buffer object usage: "
|
||||||
|
+ mBufferMemoryUsage / MB
|
||||||
|
+ "MB, force: " + force);
|
||||||
|
|
||||||
mBufferMemoryUsage -= BufferObject.limitUsage(1024*1024);
|
mBufferMemoryUsage -= BufferObject.limitUsage(1024 * 1024);
|
||||||
|
|
||||||
Log.d(TAG, "now: " + mBufferMemoryUsage / MB + "MB");
|
Log.d(TAG, "now: " + mBufferMemoryUsage / MB + "MB");
|
||||||
}
|
}
|
||||||
@ -187,6 +186,7 @@ public final class BufferObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static synchronized void init(int num) {
|
static synchronized void init(int num) {
|
||||||
|
mBufferMemoryUsage = 0;
|
||||||
pool = null;
|
pool = null;
|
||||||
createBuffers(num);
|
createBuffers(num);
|
||||||
counter = num;
|
counter = num;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user