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. 56
      jme3-android/src/main/java/com/jme3/renderer/android/OGLESShaderRenderer.java

@ -1950,7 +1950,7 @@ 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();
@ -1977,33 +1977,33 @@ public class OGLESShaderRenderer implements Renderer {
default: default:
throw new RuntimeException("Unknown buffer format."); throw new RuntimeException("Unknown buffer format.");
} }
} else { // } else {
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.glBufferSubData(target, 0, size, (ByteBuffer) vb.getData()); // GLES20.glBufferSubData(target, 0, size, (ByteBuffer) vb.getData());
RendererUtil.checkGLError(); // RendererUtil.checkGLError();
break; // break;
case Short: // case Short:
case UnsignedShort: // case UnsignedShort:
GLES20.glBufferSubData(target, 0, size, (ShortBuffer) vb.getData()); // GLES20.glBufferSubData(target, 0, size, (ShortBuffer) vb.getData());
RendererUtil.checkGLError(); // RendererUtil.checkGLError();
break; // break;
case Int: // case Int:
case UnsignedInt: // case UnsignedInt:
GLES20.glBufferSubData(target, 0, size, (IntBuffer) vb.getData()); // GLES20.glBufferSubData(target, 0, size, (IntBuffer) vb.getData());
RendererUtil.checkGLError(); // RendererUtil.checkGLError();
break; // break;
case Float: // case Float:
GLES20.glBufferSubData(target, 0, size, (FloatBuffer) vb.getData()); // GLES20.glBufferSubData(target, 0, size, (FloatBuffer) vb.getData());
RendererUtil.checkGLError(); // RendererUtil.checkGLError();
break; // break;
default: // default:
throw new RuntimeException("Unknown buffer format."); // throw new RuntimeException("Unknown buffer format.");
} // }
} // }
vb.clearUpdateNeeded(); vb.clearUpdateNeeded();
} }

Loading…
Cancel
Save