gl2 encoder: async unmapbuffer
bug: 140112486
- No need to talk to the host if we glMapBufferRange with invalidation.
- No need to talk to the host if we glUnmapBuffer without wanting to
write.
Use the extension string to decide which to use, as it may or
may not be available on the host.
Change-Id: Ib50d24064d4c4d5517dc02b4d65f0f314f5d4ccf
diff --git a/system/GLESv2_enc/GL2Encoder.cpp b/system/GLESv2_enc/GL2Encoder.cpp
index 478b823..2f20516 100755
--- a/system/GLESv2_enc/GL2Encoder.cpp
+++ b/system/GLESv2_enc/GL2Encoder.cpp
@@ -72,6 +72,7 @@
{
m_currMajorVersion = 2;
m_currMinorVersion = 0;
+ m_hasAsyncUnmapBuffer = false;
m_initialized = false;
m_noHostError = false;
m_state = NULL;
@@ -2953,11 +2954,16 @@
GLbitfield access, BufferData* buf) {
char* bits = (char*)buf->m_fixedBuffer.ptr() + offset;
- ctx->glMapBufferRangeAEMU(
- ctx, target,
- offset, length,
- access,
- bits);
+ if ((access & GL_MAP_READ_BIT) ||
+ ((access & GL_MAP_WRITE_BIT) &&
+ (!(access & GL_MAP_INVALIDATE_RANGE_BIT) &&
+ !(access & GL_MAP_INVALIDATE_BUFFER_BIT)))) {
+ ctx->glMapBufferRangeAEMU(
+ ctx, target,
+ offset, length,
+ access,
+ bits);
+ }
return bits;
}
@@ -3069,13 +3075,25 @@
goldfish_dma_guest_paddr(&buf->dma_buffer.get()),
&host_res);
} else {
- ctx->glUnmapBufferAEMU(
- ctx, target,
- buf->m_mappedOffset,
- buf->m_mappedLength,
- buf->m_mappedAccess,
- (void*)((char*)buf->m_fixedBuffer.ptr() + buf->m_mappedOffset),
- &host_res);
+ if (ctx->m_hasAsyncUnmapBuffer) {
+ ctx->glUnmapBufferAsyncAEMU(
+ ctx, target,
+ buf->m_mappedOffset,
+ buf->m_mappedLength,
+ buf->m_mappedAccess,
+ (void*)((char*)buf->m_fixedBuffer.ptr() + buf->m_mappedOffset),
+ &host_res);
+ } else {
+ if (buf->m_mappedAccess & GL_MAP_WRITE_BIT) {
+ ctx->glUnmapBufferAEMU(
+ ctx, target,
+ buf->m_mappedOffset,
+ buf->m_mappedLength,
+ buf->m_mappedAccess,
+ (void*)((char*)buf->m_fixedBuffer.ptr() + buf->m_mappedOffset),
+ &host_res);
+ }
+ }
}
buf->m_mapped = false;
@@ -3107,12 +3125,21 @@
buf->m_indexRangeCache.invalidateRange(totalOffset, length);
- ctx->glFlushMappedBufferRangeAEMU(
- ctx, target,
- totalOffset,
- length,
- buf->m_mappedAccess,
- (void*)((char*)buf->m_fixedBuffer.ptr() + totalOffset));
+ if (ctx->m_hasAsyncUnmapBuffer) {
+ ctx->glFlushMappedBufferRangeAEMU2(
+ ctx, target,
+ totalOffset,
+ length,
+ buf->m_mappedAccess,
+ (void*)((char*)buf->m_fixedBuffer.ptr() + totalOffset));
+ } else {
+ ctx->glFlushMappedBufferRangeAEMU(
+ ctx, target,
+ totalOffset,
+ length,
+ buf->m_mappedAccess,
+ (void*)((char*)buf->m_fixedBuffer.ptr() + totalOffset));
+ }
}
void GL2Encoder::s_glCompressedTexImage2D(void* self, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data) {