emulator: opengl: 'large' buffer optimization

This patch modifies the guest encoding libraries to avoid
un-necessary copies when sending large buffers (e.g. pixels)
to the host. Instead, the data is sent directly through a
new IOStream method (writeFully()).

On my machine, this improves the NenaMark2 benchmark
(from 50.8 to 57.1 fps). More importantly, this speeds up
the display of non-GL surfaces too, which are sent through
the special rcUpdateColorBuffer() function in gralloc_goldfish.

This is noticeable in many parts of the UI (e.g. when scrolling
through lists).

To tag a given parameter, use the new 'isLarge' variable flag
in the protocol .attrib file.

Implemented for the following encoding functions:

  rcUpdateColorBuffer
  glTexSubImage2D
  glTexImage2Di
  glBufferData
  glBufferSubData
  glCompressedTexImage2D
  glCompressedTexSubImage2D
  glTexImage3DOES
  glTexSubImage3DOES
  glCompressedTexImage3DOES
  glCompressedTexSubImage3DOES

+ Optimize the auto-generated encoder functions to avoid
  repeated function calls (for size computations).

Change-Id: I13a02607b606c40cd05984cd2051b1f3424bc2d0
This commit is contained in:
David 'Digit' Turner
2011-09-19 18:47:26 +02:00
parent e72ed049a8
commit 5d7f0875e9
11 changed files with 302 additions and 109 deletions

View File

@@ -240,7 +240,7 @@ glTexEnvxv
glTexImage2D
dir pixels in
len pixels pixelDataSize(self, width, height, format, type, 0)
var_flag pixels nullAllowed
var_flag pixels nullAllowed isLarge
#void glTexParameteriv(GLenum target, GLenum pname, GLint *params)
glTexParameteriv
@@ -253,6 +253,7 @@ glTexParameterxv
#void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels)
glTexSubImage2D
len pixels pixelDataSize(self, width, height, format, type, 0)
var_flag pixels isLarge
#void glVertexPointer(GLint size, GLenum type, GLsizei stride, GLvoid *pointer)
# we treat the pointer as an offset to a VBO

View File

@@ -9,20 +9,22 @@ glBindAttribLocation
#void glBufferData(GLenum target, GLsizeiptr size, GLvoid *data, GLenum usage)
glBufferData
len data size
var_flag data nullAllowed
var_flag data nullAllowed isLarge
#void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data)
glBufferSubData
len data size
var_flag data isLarge
#void glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, GLvoid *data)
glCompressedTexImage2D
len data imageSize
var_flag data nullAllowed
var_flag data nullAllowed isLarge
#void glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, GLvoid *data)
glCompressedTexSubImage2D
len data imageSize
var_flag data isLarge
#void glDeleteBuffers(GLsizei n, GLuint *buffers)
glDeleteBuffers
@@ -243,7 +245,7 @@ glShaderBinary
glTexImage2D
dir pixels in
len pixels pixelDataSize(self, width, height, format, type, 0)
var_flag pixels nullAllowed
var_flag pixels nullAllowed isLarge
#void glTexParameterfv(GLenum target, GLenum pname, GLfloat *params)
glTexParameterfv
@@ -255,6 +257,7 @@ glTexParameteriv
#void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels)
glTexSubImage2D
len pixels pixelDataSize(self, width, height, format, type, 0)
var_flag pixels isLarge
#void glUniform1fv(GLint location, GLsizei count, GLfloat *v)
glUniform1fv
@@ -333,20 +336,23 @@ glMapBufferOES
#void glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, GLvoid *pixels)
glTexImage3DOES
len pixels pixelDataSize3D(self, width, height, depth, format, type, 0)
var_flag pixels nullAllowed
len pixels pixelDataSize3D(self, width, height, depth, format, type, 0)
var_flag pixels nullAllowed isLarge
#void glTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *pixels)
glTexSubImage3DOES
len pixels pixelDataSize3D(self, width, height, depth, format, type, 0)
var_flag pixels isLarge
#void glCompressedTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, GLvoid *data)
glCompressedTexImage3DOES
len data imageSize
var_flag data isLarge
#void glCompressedTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, GLvoid *data)
glCompressedTexSubImage3DOES
len data imageSize
var_flag data isLarge
#void glDeleteVertexArraysOES(GLsizei n, GLuint *arrays)
glDeleteVertexArraysOES

View File

@@ -39,8 +39,7 @@ public:
bool valid() { return m_sock >= 0; }
int recv(void *buf, size_t len);
private:
int writeFully(const void *buf, size_t len);
virtual int writeFully(const void *buf, size_t len);
private:
int m_sock;

View File

@@ -26,10 +26,10 @@ rcGetConfigs
rcChooseConfig
dir attribs in
len attribs attribs_size
dir configs out
len attribs attribs_size
dir configs out
var_flag configs nullAllowed
len configs configs_size*sizeof(uint32_t)
len configs configs_size*sizeof(uint32_t)
rcReadColorBuffer
dir pixels out
@@ -38,3 +38,4 @@ rcReadColorBuffer
rcUpdateColorBuffer
dir pixels in
len pixels (((glUtilsPixelBitSize(format, type) * width) >> 3) * height)
var_flag pixels isLarge