Use of glBufferData instead of glBufferSubData in android renderer, because it seems to cause GL oom on some devices.

experimental
Nehon 10 years ago
parent 5a482e2b98
commit a709ba9a77
  1. 102
      jme3-android/src/main/java/com/jme3/renderer/android/OGLESShaderRenderer.java

@ -1950,60 +1950,60 @@ public class OGLESShaderRenderer implements Renderer {
int usage = convertUsage(vb.getUsage()); int usage = convertUsage(vb.getUsage());
vb.getData().rewind(); vb.getData().rewind();
if (created || vb.hasDataSizeChanged()) { // if (created || vb.hasDataSizeChanged()) {
// upload data based on format // upload data based on format
int size = vb.getData().limit() * vb.getFormat().getComponentSize(); int size = vb.getData().limit() * vb.getFormat().getComponentSize();
switch (vb.getFormat()) { switch (vb.getFormat()) {
case Byte: case Byte:
case UnsignedByte: case UnsignedByte:
GLES20.glBufferData(target, size, (ByteBuffer) vb.getData(), usage); GLES20.glBufferData(target, size, (ByteBuffer) vb.getData(), usage);
RendererUtil.checkGLError(); RendererUtil.checkGLError();
break; break;
case Short: case Short:
case UnsignedShort: case UnsignedShort:
GLES20.glBufferData(target, size, (ShortBuffer) vb.getData(), usage); GLES20.glBufferData(target, size, (ShortBuffer) vb.getData(), usage);
RendererUtil.checkGLError(); RendererUtil.checkGLError();
break; break;
case Int: case Int:
case UnsignedInt: case UnsignedInt:
GLES20.glBufferData(target, size, (IntBuffer) vb.getData(), usage); GLES20.glBufferData(target, size, (IntBuffer) vb.getData(), usage);
RendererUtil.checkGLError(); RendererUtil.checkGLError();
break; break;
case Float: case Float:
GLES20.glBufferData(target, size, (FloatBuffer) vb.getData(), usage); GLES20.glBufferData(target, size, (FloatBuffer) vb.getData(), usage);
RendererUtil.checkGLError(); RendererUtil.checkGLError();
break; break;
default: default:
throw new RuntimeException("Unknown buffer format."); throw new RuntimeException("Unknown buffer format.");
}
} else {
int size = vb.getData().limit() * vb.getFormat().getComponentSize();
switch (vb.getFormat()) {
case Byte:
case UnsignedByte:
GLES20.glBufferSubData(target, 0, size, (ByteBuffer) vb.getData());
RendererUtil.checkGLError();
break;
case Short:
case UnsignedShort:
GLES20.glBufferSubData(target, 0, size, (ShortBuffer) vb.getData());
RendererUtil.checkGLError();
break;
case Int:
case UnsignedInt:
GLES20.glBufferSubData(target, 0, size, (IntBuffer) vb.getData());
RendererUtil.checkGLError();
break;
case Float:
GLES20.glBufferSubData(target, 0, size, (FloatBuffer) vb.getData());
RendererUtil.checkGLError();
break;
default:
throw new RuntimeException("Unknown buffer format.");
}
} }
// } else {
// int size = vb.getData().limit() * vb.getFormat().getComponentSize();
//
// switch (vb.getFormat()) {
// case Byte:
// case UnsignedByte:
// GLES20.glBufferSubData(target, 0, size, (ByteBuffer) vb.getData());
// RendererUtil.checkGLError();
// break;
// case Short:
// case UnsignedShort:
// GLES20.glBufferSubData(target, 0, size, (ShortBuffer) vb.getData());
// RendererUtil.checkGLError();
// break;
// case Int:
// case UnsignedInt:
// GLES20.glBufferSubData(target, 0, size, (IntBuffer) vb.getData());
// RendererUtil.checkGLError();
// break;
// case Float:
// GLES20.glBufferSubData(target, 0, size, (FloatBuffer) vb.getData());
// RendererUtil.checkGLError();
// break;
// default:
// throw new RuntimeException("Unknown buffer format.");
// }
// }
vb.clearUpdateNeeded(); vb.clearUpdateNeeded();
} }

Loading…
Cancel
Save