it probably makes no sense to cycle ByteBuffers for upload to GL
This commit is contained in:
parent
6f98e1542b
commit
5f03a33492
@ -69,8 +69,7 @@ public class GLRenderer implements GLSurfaceView.Renderer {
|
|||||||
private static MapViewPosition mMapViewPosition;
|
private static MapViewPosition mMapViewPosition;
|
||||||
private static MapPosition mMapPosition;
|
private static MapPosition mMapPosition;
|
||||||
|
|
||||||
private static int rotateBuffers = 2;
|
private static ShortBuffer shortBuffer;
|
||||||
private static ShortBuffer shortBuffer[];
|
|
||||||
private static short[] mFillCoords;
|
private static short[] mFillCoords;
|
||||||
|
|
||||||
// bytes currently loaded in VBOs
|
// bytes currently loaded in VBOs
|
||||||
@ -190,15 +189,11 @@ public class GLRenderer implements GLSurfaceView.Renderer {
|
|||||||
mFillCoords[6] = max;
|
mFillCoords[6] = max;
|
||||||
mFillCoords[7] = min;
|
mFillCoords[7] = min;
|
||||||
|
|
||||||
shortBuffer = new ShortBuffer[rotateBuffers];
|
|
||||||
|
|
||||||
for (int i = 0; i < rotateBuffers; i++) {
|
|
||||||
ByteBuffer bbuf = ByteBuffer.allocateDirect(MB >> 2)
|
ByteBuffer bbuf = ByteBuffer.allocateDirect(MB >> 2)
|
||||||
.order(ByteOrder.nativeOrder());
|
.order(ByteOrder.nativeOrder());
|
||||||
|
|
||||||
shortBuffer[i] = bbuf.asShortBuffer();
|
shortBuffer = bbuf.asShortBuffer();
|
||||||
shortBuffer[i].put(mFillCoords, 0, 8);
|
shortBuffer.put(mFillCoords, 0, 8);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setRenderTheme(RenderTheme t) {
|
public static void setRenderTheme(RenderTheme t) {
|
||||||
@ -213,25 +208,17 @@ public class GLRenderer implements GLSurfaceView.Renderer {
|
|||||||
|
|
||||||
GLES20.glBindBuffer(GL_ARRAY_BUFFER, vbo.id);
|
GLES20.glBindBuffer(GL_ARRAY_BUFFER, vbo.id);
|
||||||
|
|
||||||
// use multiple buffers to avoid overwriting buffer while current
|
|
||||||
// data is uploaded (or rather the blocking which is probably done to
|
|
||||||
// avoid overwriting)
|
|
||||||
int curBuffer = uploadCnt++ % rotateBuffers;
|
|
||||||
//uploadCnt++;
|
|
||||||
|
|
||||||
ShortBuffer sbuf = shortBuffer[curBuffer];
|
|
||||||
|
|
||||||
// add fill coordinates
|
// add fill coordinates
|
||||||
if (addFill)
|
if (addFill)
|
||||||
newSize += 8;
|
newSize += 8;
|
||||||
|
|
||||||
|
ShortBuffer sbuf = shortBuffer;
|
||||||
|
|
||||||
if (sbuf.capacity() < newSize) {
|
if (sbuf.capacity() < newSize) {
|
||||||
sbuf = ByteBuffer
|
shortBuffer = sbuf = ByteBuffer
|
||||||
.allocateDirect(newSize * SHORT_BYTES)
|
.allocateDirect(newSize * SHORT_BYTES)
|
||||||
.order(ByteOrder.nativeOrder())
|
.order(ByteOrder.nativeOrder())
|
||||||
.asShortBuffer();
|
.asShortBuffer();
|
||||||
|
|
||||||
shortBuffer[curBuffer] = sbuf;
|
|
||||||
} else {
|
} else {
|
||||||
sbuf.clear();
|
sbuf.clear();
|
||||||
// if (addFill)
|
// if (addFill)
|
||||||
@ -263,7 +250,6 @@ public class GLRenderer implements GLSurfaceView.Renderer {
|
|||||||
mBufferMemoryUsage += newSize - vbo.size;
|
mBufferMemoryUsage += newSize - vbo.size;
|
||||||
vbo.size = newSize;
|
vbo.size = newSize;
|
||||||
GLES20.glBufferData(GL_ARRAY_BUFFER, vbo.size, sbuf, GL_DYNAMIC_DRAW);
|
GLES20.glBufferData(GL_ARRAY_BUFFER, vbo.size, sbuf, GL_DYNAMIC_DRAW);
|
||||||
//mBufferMemoryUsage += vbo.size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -610,8 +596,12 @@ public class GLRenderer implements GLSurfaceView.Renderer {
|
|||||||
TextureRenderer.init();
|
TextureRenderer.init();
|
||||||
TextureObject.init(10);
|
TextureObject.init(10);
|
||||||
|
|
||||||
GLES20.glEnable(GLES20.GL_SCISSOR_TEST);
|
//GLES20.glEnable(GLES20.GL_SCISSOR_TEST);
|
||||||
GLES20.glClearStencil(0);
|
|
||||||
|
// set all bits on clear
|
||||||
|
GLES20.glClearStencil(0xFF);
|
||||||
|
//GLES20.glClearStencil(0);
|
||||||
|
|
||||||
GLES20.glDisable(GLES20.GL_CULL_FACE);
|
GLES20.glDisable(GLES20.GL_CULL_FACE);
|
||||||
GLES20.glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
GLES20.glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
mNewSurface = true;
|
mNewSurface = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user