diff options
author | bohu <bohu@google.com> | 2014-10-21 14:02:45 -0700 |
---|---|---|
committer | bohu <bohu@google.com> | 2014-10-21 16:07:36 -0700 |
commit | 758ef0bc56397ba50f96b7b9109cb6c50a7cdf29 (patch) | |
tree | 129170798d4012b8906613ae35a7af9f6c159c49 /opengl | |
parent | 6dc9b1b64a3a01ddcce9e664dc0153021a595130 (diff) | |
download | android_device_generic_goldfish-758ef0bc56397ba50f96b7b9109cb6c50a7cdf29.tar.gz android_device_generic_goldfish-758ef0bc56397ba50f96b7b9109cb6c50a7cdf29.tar.bz2 android_device_generic_goldfish-758ef0bc56397ba50f96b7b9109cb6c50a7cdf29.zip |
Merge aosp/master fixes into lmp-dev
This patch updates the goldfish device to match the following
patches:
3f62b50d Make the size of "cb_handle_t" same for 32/64-bit
7a2929cd Remove display initialization from eglGetProcAddress API
d0fead3c ranchu: Add ARM64-specific root/ramdisk config files.
58ab34d9 Upgrade goldfish sensor HAL module to 1_0
e3e68659 ranchu: Fix goldfish_pipe definitions.
fe2c5beb Use more appropriate type in cb_handle_t::validate.
40a674e0 Fix emulator crashes on glDrawElements command
972291ae Handle empty buffer in QemuPipeStream::writeFully
4aad46d9 Allow glGetProgramInfoLog_enc to have empty length
691e021d Guard against negative width and height
f2f04f45 Guard against negative buffer size
ebe80e44 Handle empty data parameter in glTexSubImage2D_enc
Change-Id: Ib272952af902dc57fa6c76f966eb508a5fda838e
Diffstat (limited to 'opengl')
-rw-r--r-- | opengl/shared/OpenglCodecCommon/GLClientState.cpp | 2 | ||||
-rw-r--r-- | opengl/system/GLESv2_enc/GL2Encoder.cpp | 41 | ||||
-rw-r--r-- | opengl/system/GLESv2_enc/GL2Encoder.h | 16 | ||||
-rw-r--r-- | opengl/system/GLESv2_enc/gl2_enc.cpp | 8 | ||||
-rw-r--r-- | opengl/system/OpenglSystemCommon/QemuPipeStream.cpp | 4 | ||||
-rw-r--r-- | opengl/system/OpenglSystemCommon/gralloc_cb.h | 4 |
6 files changed, 67 insertions, 8 deletions
diff --git a/opengl/shared/OpenglCodecCommon/GLClientState.cpp b/opengl/shared/OpenglCodecCommon/GLClientState.cpp index 9795490..a84e856 100644 --- a/opengl/shared/OpenglCodecCommon/GLClientState.cpp +++ b/opengl/shared/OpenglCodecCommon/GLClientState.cpp @@ -224,6 +224,8 @@ int GLClientState::setPixelStore(GLenum param, GLint value) size_t GLClientState::pixelDataSize(GLsizei width, GLsizei height, GLenum format, GLenum type, int pack) const { + if (width <= 0 || height <= 0) return 0; + int pixelsize = glUtilsPixelBitSize(format, type) >> 3; int alignment = pack ? m_pixelStore.pack_alignment : m_pixelStore.unpack_alignment; diff --git a/opengl/system/GLESv2_enc/GL2Encoder.cpp b/opengl/system/GLESv2_enc/GL2Encoder.cpp index 0f5abdd..f6f61e6 100644 --- a/opengl/system/GLESv2_enc/GL2Encoder.cpp +++ b/opengl/system/GLESv2_enc/GL2Encoder.cpp @@ -79,6 +79,11 @@ GL2Encoder::GL2Encoder(IOStream *stream) : gl2_encoder_context_t(stream) m_glDeleteShader_enc = set_glDeleteShader(s_glDeleteShader); m_glAttachShader_enc = set_glAttachShader(s_glAttachShader); m_glDetachShader_enc = set_glDetachShader(s_glDetachShader); + m_glGetAttachedShaders_enc = set_glGetAttachedShaders(s_glGetAttachedShaders); + m_glGetShaderSource_enc = set_glGetShaderSource(s_glGetShaderSource); + m_glGetShaderInfoLog_enc = set_glGetShaderInfoLog(s_glGetShaderInfoLog); + m_glGetProgramInfoLog_enc = set_glGetProgramInfoLog(s_glGetProgramInfoLog); + m_glGetUniformLocation_enc = set_glGetUniformLocation(s_glGetUniformLocation); m_glUseProgram_enc = set_glUseProgram(s_glUseProgram); @@ -424,15 +429,15 @@ void GL2Encoder::sendVertexAttributes(GLint first, GLsizei count) int stride = state->stride == 0 ? state->elementSize : state->stride; int firstIndex = stride * first; + this->m_glBindBuffer_enc(this, GL_ARRAY_BUFFER, state->bufferObject); if (state->bufferObject == 0) { this->glVertexAttribPointerData(this, i, state->size, state->type, state->normalized, state->stride, (unsigned char *)state->data + firstIndex, datalen); } else { - this->m_glBindBuffer_enc(this, GL_ARRAY_BUFFER, state->bufferObject); this->glVertexAttribPointerOffset(this, i, state->size, state->type, state->normalized, state->stride, (uintptr_t) state->data + firstIndex); - this->m_glBindBuffer_enc(this, GL_ARRAY_BUFFER, m_state->currentArrayVbo()); } + this->m_glBindBuffer_enc(this, GL_ARRAY_BUFFER, m_state->currentArrayVbo()); } else { this->m_glDisableVertexAttribArray_enc(this, i); } @@ -746,6 +751,38 @@ GLuint GL2Encoder::s_glCreateShader(void *self, GLenum shaderType) return shader; } +void GL2Encoder::s_glGetAttachedShaders(void *self, GLuint program, GLsizei maxCount, + GLsizei* count, GLuint* shaders) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + SET_ERROR_IF(maxCount < 0, GL_INVALID_VALUE); + ctx->m_glGetAttachedShaders_enc(self, program, maxCount, count, shaders); +} + +void GL2Encoder::s_glGetShaderSource(void *self, GLuint shader, GLsizei bufsize, + GLsizei* length, GLchar* source) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + SET_ERROR_IF(bufsize < 0, GL_INVALID_VALUE); + ctx->m_glGetShaderSource_enc(self, shader, bufsize, length, source); +} + +void GL2Encoder::s_glGetShaderInfoLog(void *self, GLuint shader, GLsizei bufsize, + GLsizei* length, GLchar* infolog) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + SET_ERROR_IF(bufsize < 0, GL_INVALID_VALUE); + ctx->m_glGetShaderInfoLog_enc(self, shader, bufsize, length, infolog); +} + +void GL2Encoder::s_glGetProgramInfoLog(void *self, GLuint program, GLsizei bufsize, + GLsizei* length, GLchar* infolog) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + SET_ERROR_IF(bufsize < 0, GL_INVALID_VALUE); + ctx->m_glGetProgramInfoLog_enc(self, program, bufsize, length, infolog); +} + void GL2Encoder::s_glDeleteShader(void *self, GLenum shader) { GL2Encoder *ctx = (GL2Encoder*)self; diff --git a/opengl/system/GLESv2_enc/GL2Encoder.h b/opengl/system/GLESv2_enc/GL2Encoder.h index c6506a9..8f6204c 100644 --- a/opengl/system/GLESv2_enc/GL2Encoder.h +++ b/opengl/system/GLESv2_enc/GL2Encoder.h @@ -148,6 +148,22 @@ private: glDetachShader_client_proc_t m_glDetachShader_enc; static void s_glDetachShader(void *self, GLuint program, GLuint shader); + glGetAttachedShaders_client_proc_t m_glGetAttachedShaders_enc; + static void s_glGetAttachedShaders(void *self, GLuint program, GLsizei maxCount, + GLsizei* count, GLuint* shaders); + + glGetShaderSource_client_proc_t m_glGetShaderSource_enc; + static void s_glGetShaderSource(void *self, GLuint shader, GLsizei bufsize, + GLsizei* length, GLchar* source); + + glGetShaderInfoLog_client_proc_t m_glGetShaderInfoLog_enc; + static void s_glGetShaderInfoLog(void *self,GLuint shader, + GLsizei bufsize, GLsizei* length, GLchar* infolog); + + glGetProgramInfoLog_client_proc_t m_glGetProgramInfoLog_enc; + static void s_glGetProgramInfoLog(void *self,GLuint program, + GLsizei bufsize, GLsizei* length, GLchar* infolog); + glGetUniformLocation_client_proc_t m_glGetUniformLocation_enc; static int s_glGetUniformLocation(void *self, GLuint program, const GLchar *name); glUseProgram_client_proc_t m_glUseProgram_enc; diff --git a/opengl/system/GLESv2_enc/gl2_enc.cpp b/opengl/system/GLESv2_enc/gl2_enc.cpp index 46684e9..5929697 100644 --- a/opengl/system/GLESv2_enc/gl2_enc.cpp +++ b/opengl/system/GLESv2_enc/gl2_enc.cpp @@ -1162,7 +1162,7 @@ void glGetProgramInfoLog_enc(void *self , GLuint program, GLsizei bufsize, GLsiz gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; IOStream *stream = ctx->m_stream; - const unsigned int __size_length = sizeof(GLsizei); + const unsigned int __size_length = ((length != NULL) ? (sizeof(GLsizei)) : 0); const unsigned int __size_infolog = bufsize; unsigned char *ptr; const size_t packetSize = 8 + 4 + 4 + __size_length + __size_infolog + 2*4; @@ -1174,7 +1174,7 @@ void glGetProgramInfoLog_enc(void *self , GLuint program, GLsizei bufsize, GLsiz memcpy(ptr, &bufsize, 4); ptr += 4; *(unsigned int *)(ptr) = __size_length; ptr += 4; *(unsigned int *)(ptr) = __size_infolog; ptr += 4; - stream->readback(length, __size_length); + if (length != NULL) stream->readback(length, __size_length); stream->readback(infolog, __size_infolog); } @@ -1923,7 +1923,7 @@ void glTexSubImage2D_enc(void *self , GLenum target, GLint level, GLint xoffset, gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; IOStream *stream = ctx->m_stream; - const unsigned int __size_pixels = pixelDataSize(self, width, height, format, type, 0); + const unsigned int __size_pixels = ((pixels != NULL) ? pixelDataSize(self, width, height, format, type, 0) : 0); unsigned char *ptr; const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_pixels + 1*4; ptr = stream->alloc(8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4); @@ -1940,7 +1940,7 @@ void glTexSubImage2D_enc(void *self , GLenum target, GLint level, GLint xoffset, memcpy(ptr, &type, 4); ptr += 4; stream->flush(); stream->writeFully(&__size_pixels,4); - stream->writeFully(pixels, __size_pixels); + if (pixels != NULL) stream->writeFully(pixels, __size_pixels); } void glUniform1f_enc(void *self , GLint location, GLfloat x) diff --git a/opengl/system/OpenglSystemCommon/QemuPipeStream.cpp b/opengl/system/OpenglSystemCommon/QemuPipeStream.cpp index a55dca0..5798370 100644 --- a/opengl/system/OpenglSystemCommon/QemuPipeStream.cpp +++ b/opengl/system/OpenglSystemCommon/QemuPipeStream.cpp @@ -87,6 +87,10 @@ int QemuPipeStream::writeFully(const void *buf, size_t len) { //DBG(">> QemuPipeStream::writeFully %d\n", len); if (!valid()) return -1; + if (!buf) { + if (len>0) ERR("QemuPipeStream::writeFully failed, buf=NULL, len %d", len); + return 0; + } size_t res = len; int retval = 0; diff --git a/opengl/system/OpenglSystemCommon/gralloc_cb.h b/opengl/system/OpenglSystemCommon/gralloc_cb.h index a0f6ed8..d2d6f35 100644 --- a/opengl/system/OpenglSystemCommon/gralloc_cb.h +++ b/opengl/system/OpenglSystemCommon/gralloc_cb.h @@ -71,8 +71,8 @@ struct cb_handle_t : public native_handle { numInts = CB_HANDLE_NUM_INTS(numFds); } - static bool validate(cb_handle_t * hnd) { - return (hnd && + static bool validate(const cb_handle_t* hnd) { + return (hnd && hnd->version == sizeof(native_handle) && hnd->magic == BUFFER_HANDLE_MAGIC && hnd->numInts == CB_HANDLE_NUM_INTS(hnd->numFds)); |