diff options
author | bohu <bohu@google.com> | 2015-02-13 20:55:12 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-02-13 20:55:12 +0000 |
commit | 6e3ed47ab0b06e09d4b8531e05805c4b3ea0e924 (patch) | |
tree | 4df7041d463ea87f28ff5d670a104dcbc0235c3c | |
parent | 8f9288eaf10b50d19038f5c7024616e147c64735 (diff) | |
parent | aa028a3c593319d085b43f3fcc78b571524d6de2 (diff) | |
download | device_generic_goldfish-6e3ed47ab0b06e09d4b8531e05805c4b3ea0e924.tar.gz device_generic_goldfish-6e3ed47ab0b06e09d4b8531e05805c4b3ea0e924.tar.bz2 device_generic_goldfish-6e3ed47ab0b06e09d4b8531e05805c4b3ea0e924.zip |
am aa028a3c: back port gles fix to api 18
* commit 'aa028a3c593319d085b43f3fcc78b571524d6de2':
back port gles fix to api 18
24 files changed, 276 insertions, 74 deletions
diff --git a/opengl/shared/OpenglCodecCommon/GLClientState.cpp b/opengl/shared/OpenglCodecCommon/GLClientState.cpp index 97954902..0826a14a 100644 --- a/opengl/shared/OpenglCodecCommon/GLClientState.cpp +++ b/opengl/shared/OpenglCodecCommon/GLClientState.cpp @@ -35,6 +35,7 @@ GLClientState::GLClientState(int nLocations) for (int i = 0; i < m_nLocations; i++) { m_states[i].enabled = 0; m_states[i].enableDirty = false; + m_states[i].data = 0; } m_currentArrayVbo = 0; m_currentIndexVbo = 0; @@ -224,6 +225,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/shared/OpenglCodecCommon/GLClientState.h b/opengl/shared/OpenglCodecCommon/GLClientState.h index c86329b4..09ee5717 100644 --- a/opengl/shared/OpenglCodecCommon/GLClientState.h +++ b/opengl/shared/OpenglCodecCommon/GLClientState.h @@ -91,6 +91,12 @@ public: void setActiveTexture(int texUnit) {m_activeTexture = texUnit; }; int getActiveTexture() const { return m_activeTexture; } + void unBindBuffer(GLuint id) + { + if (m_currentArrayVbo == id) m_currentArrayVbo = 0; + else if (m_currentIndexVbo == id) m_currentIndexVbo = 0; + } + int bindBuffer(GLenum target, GLuint id) { int err = 0; diff --git a/opengl/shared/OpenglCodecCommon/GLSharedGroup.cpp b/opengl/shared/OpenglCodecCommon/GLSharedGroup.cpp index 8504f7f7..b079b6da 100644..100755 --- a/opengl/shared/OpenglCodecCommon/GLSharedGroup.cpp +++ b/opengl/shared/OpenglCodecCommon/GLSharedGroup.cpp @@ -16,10 +16,19 @@ #include "GLSharedGroup.h" +/**** KeyedVector utilities ****/ + +template <typename T> +static void clearObjectMap(android::DefaultKeyedVector<GLuint, T>& v) { + for (size_t i = 0; i < v.size(); i++) + delete v.valueAt(i); + v.clear(); +} + /**** BufferData ****/ BufferData::BufferData() : m_size(0) {}; -BufferData::BufferData(GLsizeiptr size, void * data) : m_size(size) +BufferData::BufferData(GLsizeiptr size, void * data) : m_size(size) { void * buffer = NULL; if (size>0) buffer = m_fixedBuffer.alloc(size); @@ -55,7 +64,7 @@ ProgramData::~ProgramData() } void ProgramData::setIndexInfo(GLuint index, GLint base, GLint size, GLenum type) -{ +{ if (index>=m_numIndexes) return; m_Indexes[index].base = base; @@ -87,7 +96,7 @@ GLuint ProgramData::getIndexForLocation(GLint location) for (GLuint i=0;i<m_numIndexes;++i) { GLint dist = location - m_Indexes[i].base; - if (dist >= 0 && + if (dist >= 0 && (minDist < 0 || dist < minDist)) { index = i; minDist = dist; @@ -126,7 +135,7 @@ GLint ProgramData::locationWARHostToApp(GLint hostLoc, GLint arrIndex) GLuint index = getIndexForLocation(hostLoc); if (index<m_numIndexes) { if (arrIndex > 0) { - m_Indexes[index].hostLocsPerElement = + m_Indexes[index].hostLocsPerElement = (hostLoc - m_Indexes[index].base) / arrIndex; } return m_Indexes[index].appBase + arrIndex; @@ -226,12 +235,21 @@ GLSharedGroup::~GLSharedGroup() { m_buffers.clear(); m_programs.clear(); + clearObjectMap(m_buffers); + clearObjectMap(m_programs); + clearObjectMap(m_shaders); +} + +bool GLSharedGroup::isObject(GLuint obj) +{ + android::AutoMutex _lock(m_lock); + return ((m_shaders.valueFor(obj)!=NULL) || (m_programs.valueFor(obj)!=NULL)); } BufferData * GLSharedGroup::getBufferData(GLuint bufferId) { android::AutoMutex _lock(m_lock); - return m_buffers.valueFor(bufferId); + return m_buffers.valueFor(bufferId); } void GLSharedGroup::addBufferData(GLuint bufferId, GLsizeiptr size, void * data) @@ -243,32 +261,42 @@ void GLSharedGroup::addBufferData(GLuint bufferId, GLsizeiptr size, void * data) void GLSharedGroup::updateBufferData(GLuint bufferId, GLsizeiptr size, void * data) { android::AutoMutex _lock(m_lock); - m_buffers.replaceValueFor(bufferId, new BufferData(size, data)); + ssize_t idx = m_buffers.indexOfKey(bufferId); + if (idx >= 0) { + delete m_buffers.valueAt(idx); + m_buffers.editValueAt(idx) = new BufferData(size, data); + } else { + m_buffers.add(bufferId, new BufferData(size, data)); + } } GLenum GLSharedGroup::subUpdateBufferData(GLuint bufferId, GLintptr offset, GLsizeiptr size, void * data) { android::AutoMutex _lock(m_lock); BufferData * buf = m_buffers.valueFor(bufferId); - if ((!buf) || (buf->m_size < offset+size) || (offset < 0) || (size<0)) return GL_INVALID_VALUE; + if ((!buf) || (buf->m_size < offset+size) || (offset < 0) || (size<0)) return GL_INVALID_VALUE; //it's safe to update now memcpy((char*)buf->m_fixedBuffer.ptr() + offset, data, size); - return GL_NO_ERROR; + return GL_NO_ERROR; } void GLSharedGroup::deleteBufferData(GLuint bufferId) { android::AutoMutex _lock(m_lock); - m_buffers.removeItem(bufferId); + ssize_t idx = m_buffers.indexOfKey(bufferId); + if (idx >= 0) { + delete m_buffers.valueAt(idx); + m_buffers.removeItemsAt(idx); + } } void GLSharedGroup::addProgramData(GLuint program) { android::AutoMutex _lock(m_lock); ProgramData *pData = m_programs.valueFor(program); - if (pData) - { + if (pData) + { m_programs.removeItem(program); delete pData; } @@ -290,7 +318,7 @@ bool GLSharedGroup::isProgramInitialized(GLuint program) { android::AutoMutex _lock(m_lock); ProgramData* pData = m_programs.valueFor(program); - if (pData) + if (pData) { return pData->isInitialized(); } @@ -303,7 +331,7 @@ void GLSharedGroup::deleteProgramData(GLuint program) ProgramData *pData = m_programs.valueFor(program); if (pData) delete pData; - m_programs.removeItem(program); + m_programs.removeItem(program); } void GLSharedGroup::attachShader(GLuint program, GLuint shader) @@ -363,7 +391,7 @@ GLenum GLSharedGroup::getProgramUniformType(GLuint program, GLint location) android::AutoMutex _lock(m_lock); ProgramData* pData = m_programs.valueFor(program); GLenum type=0; - if (pData) + if (pData) { type = pData->getTypeForLocation(location); } diff --git a/opengl/shared/OpenglCodecCommon/GLSharedGroup.h b/opengl/shared/OpenglCodecCommon/GLSharedGroup.h index 61b8f005..6dfcd8f5 100644..100755 --- a/opengl/shared/OpenglCodecCommon/GLSharedGroup.h +++ b/opengl/shared/OpenglCodecCommon/GLSharedGroup.h @@ -110,6 +110,7 @@ private: public: GLSharedGroup(); ~GLSharedGroup(); + bool isObject(GLuint obj); BufferData * getBufferData(GLuint bufferId); void addBufferData(GLuint bufferId, GLsizeiptr size, void * data); void updateBufferData(GLuint bufferId, GLsizeiptr size, void * data); diff --git a/opengl/system/GLESv1_enc/GLEncoder.cpp b/opengl/system/GLESv1_enc/GLEncoder.cpp index 4414f246..989c26fc 100644 --- a/opengl/system/GLESv1_enc/GLEncoder.cpp +++ b/opengl/system/GLESv1_enc/GLEncoder.cpp @@ -464,19 +464,19 @@ void GLEncoder::sendVertexData(unsigned int first, unsigned int count) switch(i) { case GLClientState::VERTEX_LOCATION: this->glVertexPointerOffset(this, state->size, state->type, state->stride, - (GLuint)state->data + firstIndex); + (uintptr_t)state->data + firstIndex); break; case GLClientState::NORMAL_LOCATION: this->glNormalPointerOffset(this, state->type, state->stride, - (GLuint) state->data + firstIndex); + (uintptr_t)state->data + firstIndex); break; case GLClientState::POINTSIZE_LOCATION: this->glPointSizePointerOffset(this, state->type, state->stride, - (GLuint) state->data + firstIndex); + (uintptr_t)state->data + firstIndex); break; case GLClientState::COLOR_LOCATION: this->glColorPointerOffset(this, state->size, state->type, state->stride, - (GLuint) state->data + firstIndex); + (uintptr_t)state->data + firstIndex); break; case GLClientState::TEXCOORD0_LOCATION: case GLClientState::TEXCOORD1_LOCATION: @@ -487,17 +487,17 @@ void GLEncoder::sendVertexData(unsigned int first, unsigned int count) case GLClientState::TEXCOORD6_LOCATION: case GLClientState::TEXCOORD7_LOCATION: this->glTexCoordPointerOffset(this, state->size, state->type, state->stride, - (GLuint) state->data + firstIndex); + (uintptr_t)state->data + firstIndex); break; case GLClientState::WEIGHT_LOCATION: this->glWeightPointerOffset(this,state->size,state->type,state->stride, - (GLuint)state->data+firstIndex); + (uintptr_t)state->data+firstIndex); break; case GLClientState::MATRIXINDEX_LOCATION: this->glMatrixIndexPointerOffset(this,state->size,state->type,state->stride, - (GLuint)state->data+firstIndex); + (uintptr_t)state->data+firstIndex); break; - } + } this->m_glBindBuffer_enc(this, GL_ARRAY_BUFFER, m_state->currentArrayVbo()); } } else { @@ -545,14 +545,14 @@ void GLEncoder::s_glDrawElements(void *self, GLenum mode, GLsizei count, GLenum if (!has_immediate_arrays) { ctx->sendVertexData(0, count); ctx->m_glBindBuffer_enc(self, GL_ELEMENT_ARRAY_BUFFER, ctx->m_state->currentIndexVbo()); - ctx->glDrawElementsOffset(ctx, mode, count, type, (GLuint)indices); + ctx->glDrawElementsOffset(ctx, mode, count, type, (uintptr_t)indices); adjustIndices = false; } else { BufferData * buf = ctx->m_shared->getBufferData(ctx->m_state->currentIndexVbo()); ctx->m_glBindBuffer_enc(self, GL_ELEMENT_ARRAY_BUFFER, 0); indices = (void*)((GLintptr)buf->m_fixedBuffer.ptr() + (GLintptr)indices); } - } + } if (adjustIndices) { void *adjustedIndices = (void*)indices; int minIndex = 0, maxIndex = 0; diff --git a/opengl/system/GLESv2_enc/GL2Encoder.cpp b/opengl/system/GLESv2_enc/GL2Encoder.cpp index 7fc32b5b..db0e2708 100644..100755 --- 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); @@ -111,6 +116,7 @@ GL2Encoder::GL2Encoder(IOStream *stream) : gl2_encoder_context_t(stream) m_glTexParameterfv_enc = set_glTexParameterfv(s_glTexParameterfv); m_glTexParameteri_enc = set_glTexParameteri(s_glTexParameteri); m_glTexParameteriv_enc = set_glTexParameteriv(s_glTexParameteriv); + m_glTexImage2D_enc = set_glTexImage2D(s_glTexImage2D); } GL2Encoder::~GL2Encoder() @@ -179,6 +185,7 @@ void GL2Encoder::s_glBindBuffer(void *self, GLenum target, GLuint id) void GL2Encoder::s_glBufferData(void * self, GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage) { GL2Encoder *ctx = (GL2Encoder *) self; + SET_ERROR_IF(!(target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER), GL_INVALID_ENUM); GLuint bufferId = ctx->m_state->getBuffer(target); SET_ERROR_IF(bufferId==0, GL_INVALID_OPERATION); SET_ERROR_IF(size<0, GL_INVALID_VALUE); @@ -190,6 +197,7 @@ void GL2Encoder::s_glBufferData(void * self, GLenum target, GLsizeiptr size, con void GL2Encoder::s_glBufferSubData(void * self, GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data) { GL2Encoder *ctx = (GL2Encoder *) self; + SET_ERROR_IF(!(target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER), GL_INVALID_ENUM); GLuint bufferId = ctx->m_state->getBuffer(target); SET_ERROR_IF(bufferId==0, GL_INVALID_OPERATION); @@ -205,6 +213,7 @@ void GL2Encoder::s_glDeleteBuffers(void * self, GLsizei n, const GLuint * buffer SET_ERROR_IF(n<0, GL_INVALID_VALUE); for (int i=0; i<n; i++) { ctx->m_shared->deleteBufferData(buffers[i]); + ctx->m_state->unBindBuffer(buffers[i]); ctx->m_glDeleteBuffers_enc(self,1,&buffers[i]); } } @@ -348,6 +357,7 @@ void GL2Encoder::s_glGetBooleanv(void *self, GLenum param, GLboolean *ptr) if (!ctx->m_state->getClientStateParameter<GLboolean>(param, ptr)) { ctx->m_glGetBooleanv_enc(self, param, ptr); } + *ptr = (*ptr != 0) ? GL_TRUE : GL_FALSE; break; } } @@ -424,15 +434,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, - (GLuint) state->data + firstIndex); - this->m_glBindBuffer_enc(this, GL_ARRAY_BUFFER, m_state->currentArrayVbo()); + (uintptr_t) state->data + firstIndex); } + this->m_glBindBuffer_enc(this, GL_ARRAY_BUFFER, m_state->currentArrayVbo()); } else { this->m_glDisableVertexAttribArray_enc(this, i); } @@ -479,7 +489,7 @@ void GL2Encoder::s_glDrawElements(void *self, GLenum mode, GLsizei count, GLenum if (!has_immediate_arrays) { ctx->sendVertexAttributes(0, count); ctx->m_glBindBuffer_enc(self, GL_ELEMENT_ARRAY_BUFFER, ctx->m_state->currentIndexVbo()); - ctx->glDrawElementsOffset(ctx, mode, count, type, (GLuint)indices); + ctx->glDrawElementsOffset(ctx, mode, count, type, (uintptr_t)indices); adjustIndices = false; } else { BufferData * buf = ctx->m_shared->getBufferData(ctx->m_state->currentIndexVbo()); @@ -637,7 +647,9 @@ void GL2Encoder::s_glShaderSource(void *self, GLuint shader, GLsizei count, cons { GL2Encoder* ctx = (GL2Encoder*)self; ShaderData* shaderData = ctx->m_shared->getShaderData(shader); - SET_ERROR_IF(!shaderData, GL_INVALID_VALUE); + SET_ERROR_IF(!ctx->m_shared->isObject(shader), GL_INVALID_VALUE); + SET_ERROR_IF(!shaderData, GL_INVALID_OPERATION); + SET_ERROR_IF((count<0), GL_INVALID_VALUE); int len = glUtilsCalcShaderSourceLen((char**)string, (GLint*)length, count); char *str = new char[len + 1]; @@ -746,6 +758,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; @@ -1161,6 +1205,23 @@ void GL2Encoder::s_glTexParameteri(void* self, } } +void GL2Encoder::s_glTexImage2D(void* self, GLenum target, GLint level, + GLint internalformat, GLsizei width, GLsizei height, GLint border, + GLenum format, GLenum type, const GLvoid* pixels) +{ + GL2Encoder* ctx = (GL2Encoder*)self; + if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) { + ctx->override2DTextureTarget(target); + ctx->m_glTexImage2D_enc(ctx, target, level, internalformat, width, + height, border, format, type, pixels); + ctx->restore2DTextureTarget(); + } else { + ctx->m_glTexImage2D_enc(ctx, target, level, internalformat, width, + height, border, format, type, pixels); + } +} + + void GL2Encoder::s_glTexParameteriv(void* self, GLenum target, GLenum pname, const GLint* params) { diff --git a/opengl/system/GLESv2_enc/GL2Encoder.h b/opengl/system/GLESv2_enc/GL2Encoder.h index c6506a9a..927bd66c 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; @@ -202,6 +218,7 @@ private: glTexParameterfv_client_proc_t m_glTexParameterfv_enc; glTexParameteri_client_proc_t m_glTexParameteri_enc; glTexParameteriv_client_proc_t m_glTexParameteriv_enc; + glTexImage2D_client_proc_t m_glTexImage2D_enc; static void s_glActiveTexture(void* self, GLenum texture); static void s_glBindTexture(void* self, GLenum target, GLuint texture); @@ -212,5 +229,9 @@ private: static void s_glTexParameterfv(void* self, GLenum target, GLenum pname, const GLfloat* params); static void s_glTexParameteri(void* self, GLenum target, GLenum pname, GLint param); static void s_glTexParameteriv(void* self, GLenum target, GLenum pname, const GLint* params); + static void s_glTexImage2D(void* self, GLenum target, GLint level, GLint internalformat, + GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, + const GLvoid* pixels); + }; #endif diff --git a/opengl/system/GLESv2_enc/gl2_enc.cpp b/opengl/system/GLESv2_enc/gl2_enc.cpp index 46684e9f..59296979 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 a55dca0b..57983704 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/ThreadInfo.cpp b/opengl/system/OpenglSystemCommon/ThreadInfo.cpp index 75da8f29..f9c8521d 100644 --- a/opengl/system/OpenglSystemCommon/ThreadInfo.cpp +++ b/opengl/system/OpenglSystemCommon/ThreadInfo.cpp @@ -24,6 +24,7 @@ static void tlsDestruct(void *ptr) EGLThreadInfo *ti = (EGLThreadInfo *)ptr; delete ti->hostConn; delete ti; + ((intptr_t *)__get_tls())[TLS_SLOT_OPENGL] = NULL; } } diff --git a/opengl/system/OpenglSystemCommon/ThreadInfo.h b/opengl/system/OpenglSystemCommon/ThreadInfo.h index 03287334..f59ce2ae 100644 --- a/opengl/system/OpenglSystemCommon/ThreadInfo.h +++ b/opengl/system/OpenglSystemCommon/ThreadInfo.h @@ -40,10 +40,10 @@ EGLThreadInfo *slow_getEGLThreadInfo(); // We have a dedicated TLS slot in bionic inline EGLThreadInfo* getEGLThreadInfo() { EGLThreadInfo *tInfo = - (EGLThreadInfo *)(((unsigned *)__get_tls())[TLS_SLOT_OPENGL]); + (EGLThreadInfo *)(((uintptr_t *)__get_tls())[TLS_SLOT_OPENGL]); if (!tInfo) { tInfo = slow_getEGLThreadInfo(); - ((uint32_t *)__get_tls())[TLS_SLOT_OPENGL] = (uint32_t)tInfo; + ((uintptr_t *)__get_tls())[TLS_SLOT_OPENGL] = (uintptr_t)tInfo; } return tInfo; } diff --git a/opengl/system/OpenglSystemCommon/gralloc_cb.h b/opengl/system/OpenglSystemCommon/gralloc_cb.h index fd35473d..d2d6f352 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)); @@ -96,7 +96,11 @@ struct cb_handle_t : public native_handle { int glType; // OpenGL type enum used when uploading to host int ashmemSize; // ashmem region size for the buffer (0 unless is HW_FB buffer or // s/w access is needed) - int ashmemBase; // CPU address of the mapped ashmem region + union { + intptr_t ashmemBase; // CPU address of the mapped ashmem region + uint64_t padding; // enforce same size on 32-bit/64-bit + } __attribute__((aligned(8))); + int ashmemBasePid; // process id which mapped the ashmem region int mappedPid; // process id which succeeded gralloc_register call int lockedLeft; // region of buffer locked for s/w write diff --git a/opengl/system/egl/egl.cpp b/opengl/system/egl/egl.cpp index da89c4de..65ff39e5 100644 --- a/opengl/system/egl/egl.cpp +++ b/opengl/system/egl/egl.cpp @@ -86,7 +86,7 @@ const char * eglStrError(EGLint err) #endif //LOG_EGL_ERRORS #define VALIDATE_CONFIG(cfg,ret) \ - if(((int)cfg<0)||((int)cfg>s_display.getNumConfigs())) { \ + if(((intptr_t)cfg<0)||((intptr_t)cfg>s_display.getNumConfigs())) { \ RETURN_ERROR(ret,EGL_BAD_CONFIG); \ } @@ -140,7 +140,9 @@ EGLContext_t::EGLContext_t(EGLDisplay dpy, EGLConfig config, EGLContext_t* share versionString(NULL), vendorString(NULL), rendererString(NULL), - extensionString(NULL) + shaderVersionString(NULL), + extensionString(NULL), + deletePending(0) { flags = 0; version = 1; @@ -157,6 +159,7 @@ EGLContext_t::~EGLContext_t() delete [] versionString; delete [] vendorString; delete [] rendererString; + delete [] shaderVersionString; delete [] extensionString; } @@ -268,7 +271,7 @@ EGLBoolean egl_window_surface_t::init() } DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE); - rcSurface = rcEnc->rcCreateWindowSurface(rcEnc, (uint32_t)config, + rcSurface = rcEnc->rcCreateWindowSurface(rcEnc, (uintptr_t)config, getWidth(), getHeight()); if (!rcSurface) { ALOGE("rcCreateWindowSurface returned 0"); @@ -371,7 +374,7 @@ EGLBoolean egl_pbuffer_surface_t::init(GLenum pixelFormat) { DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE); - rcSurface = rcEnc->rcCreateWindowSurface(rcEnc, (uint32_t)config, + rcSurface = rcEnc->rcCreateWindowSurface(rcEnc, (uintptr_t)config, getWidth(), getHeight()); if (!rcSurface) { ALOGE("rcCreateWindowSurface returned 0"); @@ -415,6 +418,7 @@ static const char *getGLString(int glEnum) #define GL_VENDOR 0x1F00 #define GL_RENDERER 0x1F01 #define GL_VERSION 0x1F02 +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C #define GL_EXTENSIONS 0x1F03 switch(glEnum) { @@ -427,6 +431,9 @@ static const char *getGLString(int glEnum) case GL_RENDERER: strPtr = &tInfo->currentContext->rendererString; break; + case GL_SHADING_LANGUAGE_VERSION: + strPtr = &tInfo->currentContext->shaderVersionString; + break; case GL_EXTENSIONS: strPtr = &tInfo->currentContext->extensionString; break; @@ -526,15 +533,6 @@ __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname) } } - // - // Make sure display is initialized before searching in client APIs - // - if (!s_display.initialized()) { - if (!s_display.initialize(&s_eglIface)) { - return NULL; - } - } - // look in gles client api's extensions table return (__eglMustCastToProperFunctionPointerType)ClientAPIExts::getProcAddress(procname); @@ -563,7 +561,7 @@ EGLBoolean eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, return EGL_TRUE; } - int i=0; + uintptr_t i=0; for (i=0 ; i<numConfigs && i<config_size ; i++) { *configs++ = (EGLConfig)i; } @@ -585,9 +583,18 @@ EGLBoolean eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig attribs_size++; //for the terminating EGL_NONE } + uint32_t* tempConfigs[config_size]; DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE); - *num_config = rcEnc->rcChooseConfig(rcEnc, (EGLint*)attrib_list, attribs_size * sizeof(EGLint), (uint32_t*)configs, config_size); + *num_config = rcEnc->rcChooseConfig(rcEnc, (EGLint*)attrib_list, attribs_size * sizeof(EGLint), (uint32_t*)tempConfigs, config_size); + if (configs!=NULL) { + EGLint i=0; + for (i=0;i<(*num_config);i++) { + *((uintptr_t*)configs+i) = *((uint32_t*)tempConfigs+i); + } + } + if (*num_config <= 0) + return EGL_FALSE; return EGL_TRUE; } @@ -873,7 +880,7 @@ EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_c } DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_NO_CONTEXT); - uint32_t rcContext = rcEnc->rcCreateContext(rcEnc, (uint32_t)config, rcShareCtx, version); + uint32_t rcContext = rcEnc->rcCreateContext(rcEnc, (uintptr_t)config, rcShareCtx, version); if (!rcContext) { ALOGE("rcCreateContext returned 0"); setErrorReturn(EGL_BAD_ALLOC, EGL_NO_CONTEXT); @@ -897,9 +904,11 @@ EGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx) EGLContext_t * context = static_cast<EGLContext_t*>(ctx); - if (getEGLThreadInfo()->currentContext == context) - { - eglMakeCurrent(dpy, EGL_NO_CONTEXT, EGL_NO_SURFACE, EGL_NO_SURFACE); + if (!context) return EGL_TRUE; + + if (getEGLThreadInfo()->currentContext == context) { + getEGLThreadInfo()->currentContext->deletePending = 1; + return EGL_TRUE; } if (context->rcContext) { @@ -934,12 +943,21 @@ EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLC // Nothing to do if no binding change has made // EGLThreadInfo *tInfo = getEGLThreadInfo(); + if (tInfo->currentContext == context && (context == NULL || (context && context->draw == draw && context->read == read))) { return EGL_TRUE; } + if (tInfo->currentContext && tInfo->currentContext->deletePending) { + if (tInfo->currentContext != context) { + EGLContext_t * contextToDelete = tInfo->currentContext; + tInfo->currentContext = 0; + eglDestroyContext(dpy, contextToDelete); + } + } + if (context && (context->flags & EGLContext_t::IS_CURRENT) && (context != tInfo->currentContext)) { //context is current to another thread setErrorReturn(EGL_BAD_ACCESS, EGL_FALSE); @@ -966,7 +984,7 @@ EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLC hostCon->glEncoder()->setSharedGroup(context->getSharedGroup()); } } - else { + else if (tInfo->currentContext) { //release ClientState & SharedGroup if (tInfo->currentContext->version == 2) { hostCon->gl2Encoder()->setClientState(NULL); diff --git a/opengl/system/egl/eglContext.h b/opengl/system/egl/eglContext.h index 2ca6d0c2..5b6a428e 100644 --- a/opengl/system/egl/eglContext.h +++ b/opengl/system/egl/eglContext.h @@ -39,8 +39,9 @@ struct EGLContext_t { const char* versionString; const char* vendorString; const char* rendererString; + const char* shaderVersionString; const char* extensionString; - + EGLint deletePending; GLClientState * getClientState(){ return clientState; } GLSharedGroupPtr getSharedGroup(){ return sharedGroup; } private: diff --git a/opengl/system/egl/eglDisplay.cpp b/opengl/system/egl/eglDisplay.cpp index bcb0d4bb..96540aa1 100644 --- a/opengl/system/egl/eglDisplay.cpp +++ b/opengl/system/egl/eglDisplay.cpp @@ -84,9 +84,15 @@ bool eglDisplay::initialize(EGLClient_eglInterface *eglIface) // // load GLES client API // +#if __LP64__ + m_gles_iface = loadGLESClientAPI("/system/lib64/egl/libGLESv1_CM_emulation.so", + eglIface, + &s_gles_lib); +#else m_gles_iface = loadGLESClientAPI("/system/lib/egl/libGLESv1_CM_emulation.so", eglIface, &s_gles_lib); +#endif if (!m_gles_iface) { pthread_mutex_unlock(&m_lock); ALOGE("Failed to load gles1 iface"); @@ -94,9 +100,15 @@ bool eglDisplay::initialize(EGLClient_eglInterface *eglIface) } #ifdef WITH_GLES2 +#if __LP64__ + m_gles2_iface = loadGLESClientAPI("/system/lib64/egl/libGLESv2_emulation.so", + eglIface, + &s_gles2_lib); +#else m_gles2_iface = loadGLESClientAPI("/system/lib/egl/libGLESv2_emulation.so", eglIface, &s_gles2_lib); +#endif // Note that if loading gles2 failed, we can still run with no // GLES2 support, having GLES2 is not mandatory. #endif @@ -189,7 +201,7 @@ bool eglDisplay::initialize(EGLClient_eglInterface *eglIface) void eglDisplay::processConfigs() { - for (int i=0; i<m_numConfigs; i++) { + for (intptr_t i=0; i<m_numConfigs; i++) { EGLConfig config = (EGLConfig)i; //Setup the EGL_NATIVE_VISUAL_ID attribute PixelFormat format; @@ -401,7 +413,7 @@ EGLBoolean eglDisplay::getAttribValue(EGLConfig config, EGLint attribIdx, EGLint ALOGE("[%s] Bad attribute idx\n", __FUNCTION__); return EGL_FALSE; } - *value = *(m_configs + (int)config*m_numConfigAttribs + attribIdx); + *value = *(m_configs + (intptr_t)config*m_numConfigAttribs + attribIdx); return EGL_TRUE; } @@ -434,7 +446,7 @@ EGLBoolean eglDisplay::setAttribValue(EGLConfig config, EGLint attribIdx, EGLint ALOGE("[%s] Bad attribute idx\n", __FUNCTION__); return EGL_FALSE; } - *(m_configs + (int)config*m_numConfigAttribs + attribIdx) = value; + *(m_configs + (intptr_t)config*m_numConfigAttribs + attribIdx) = value; return EGL_TRUE; } diff --git a/opengl/system/gralloc/gralloc.cpp b/opengl/system/gralloc/gralloc.cpp index ed5d05f4..8fd15849 100644 --- a/opengl/system/gralloc/gralloc.cpp +++ b/opengl/system/gralloc/gralloc.cpp @@ -15,11 +15,7 @@ */ #include <string.h> #include <pthread.h> -#ifdef HAVE_ANDROID_OS // just want PAGE_SIZE define -# include <asm/page.h> -#else -# include <sys/user.h> -#endif +#include <limits.h> #include <cutils/ashmem.h> #include <unistd.h> #include <errno.h> @@ -332,6 +328,7 @@ static int gralloc_alloc(alloc_device_t* dev, // if (usage & (GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_2D | GRALLOC_USAGE_HW_COMPOSER | + GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_HW_FB) ) { DEFINE_HOST_CONNECTION; if (hostCon && rcEnc) { @@ -460,7 +457,7 @@ static int fb_post(struct framebuffer_device_t* dev, buffer_handle_t buffer) DEFINE_AND_VALIDATE_HOST_CONNECTION; // increment the post count of the buffer - uint32_t *postCountPtr = (uint32_t *)cb->ashmemBase; + intptr_t *postCountPtr = (intptr_t *)cb->ashmemBase; if (!postCountPtr) { // This should not happen return -EINVAL; @@ -545,7 +542,7 @@ static int gralloc_register_buffer(gralloc_module_t const* module, if (cb->hostHandle != 0) { DEFINE_AND_VALIDATE_HOST_CONNECTION; D("Opening host ColorBuffer 0x%x\n", cb->hostHandle); - rcEnc->rcOpenColorBuffer(rcEnc, cb->hostHandle); + rcEnc->rcOpenColorBuffer2(rcEnc, cb->hostHandle); } // @@ -652,7 +649,7 @@ static int gralloc_lock(gralloc_module_t const* module, return -EINVAL; } - EGLint postCount = 0; + intptr_t postCount = 0; void *cpu_addr = NULL; // @@ -666,8 +663,8 @@ static int gralloc_lock(gralloc_module_t const* module, } if (cb->canBePosted()) { - postCount = *((int *)cb->ashmemBase); - cpu_addr = (void *)(cb->ashmemBase + sizeof(int)); + postCount = *((intptr_t *)cb->ashmemBase); + cpu_addr = (void *)(cb->ashmemBase + sizeof(intptr_t)); } else { cpu_addr = (void *)(cb->ashmemBase); @@ -692,6 +689,14 @@ static int gralloc_lock(gralloc_module_t const* module, return -EBUSY; } + const bool sw_read = (cb->usage & GRALLOC_USAGE_SW_READ_OFTEN); + const bool screen_capture_mode = (sw_read); + if (screen_capture_mode) { + D("gralloc_lock read back color buffer %d %d\n", cb->width, cb->height); + DEFINE_AND_VALIDATE_HOST_CONNECTION; + rcEnc->rcReadColorBuffer(rcEnc, cb->hostHandle, + 0, 0, cb->width, cb->height, GL_RGBA, GL_UNSIGNED_BYTE, cpu_addr); + } } // @@ -1021,7 +1026,6 @@ struct private_module_t HAL_MODULE_INFO_SYM = { unlock: gralloc_unlock, perform: NULL, lock_ycbcr: gralloc_lock_ycbcr, - reserved_proc: {0, } } }; @@ -1042,7 +1046,11 @@ fallback_init(void) return; } ALOGD("Emulator without GPU emulation detected."); +#if __LP64__ + module = dlopen("/system/lib64/hw/gralloc.default.so", RTLD_LAZY|RTLD_LOCAL); +#else module = dlopen("/system/lib/hw/gralloc.default.so", RTLD_LAZY|RTLD_LOCAL); +#endif if (module != NULL) { sFallback = reinterpret_cast<gralloc_module_t*>(dlsym(module, HAL_MODULE_INFO_SYM_AS_STR)); if (sFallback == NULL) { diff --git a/opengl/system/renderControl_enc/renderControl_client_context.cpp b/opengl/system/renderControl_enc/renderControl_client_context.cpp index 94882484..a4bdb251 100644 --- a/opengl/system/renderControl_enc/renderControl_client_context.cpp +++ b/opengl/system/renderControl_enc/renderControl_client_context.cpp @@ -37,6 +37,7 @@ int renderControl_client_context_t::initDispatchByName(void *(*getProc)(const ch ptr = getProc("rcColorBufferCacheFlush", userData); set_rcColorBufferCacheFlush((rcColorBufferCacheFlush_client_proc_t)ptr); ptr = getProc("rcReadColorBuffer", userData); set_rcReadColorBuffer((rcReadColorBuffer_client_proc_t)ptr); ptr = getProc("rcUpdateColorBuffer", userData); set_rcUpdateColorBuffer((rcUpdateColorBuffer_client_proc_t)ptr); + ptr = getProc("rcOpenColorBuffer2", userData); set_rcOpenColorBuffer2((rcOpenColorBuffer2_client_proc_t)ptr); return 0; } diff --git a/opengl/system/renderControl_enc/renderControl_client_context.h b/opengl/system/renderControl_enc/renderControl_client_context.h index ed2b1fbf..46a007f6 100644 --- a/opengl/system/renderControl_enc/renderControl_client_context.h +++ b/opengl/system/renderControl_enc/renderControl_client_context.h @@ -33,6 +33,7 @@ struct renderControl_client_context_t { rcColorBufferCacheFlush_client_proc_t rcColorBufferCacheFlush; rcReadColorBuffer_client_proc_t rcReadColorBuffer; rcUpdateColorBuffer_client_proc_t rcUpdateColorBuffer; + rcOpenColorBuffer2_client_proc_t rcOpenColorBuffer2; //Accessors virtual rcGetRendererVersion_client_proc_t set_rcGetRendererVersion(rcGetRendererVersion_client_proc_t f) { rcGetRendererVersion_client_proc_t retval = rcGetRendererVersion; rcGetRendererVersion = f; return retval;} virtual rcGetEGLVersion_client_proc_t set_rcGetEGLVersion(rcGetEGLVersion_client_proc_t f) { rcGetEGLVersion_client_proc_t retval = rcGetEGLVersion; rcGetEGLVersion = f; return retval;} @@ -59,6 +60,7 @@ struct renderControl_client_context_t { virtual rcColorBufferCacheFlush_client_proc_t set_rcColorBufferCacheFlush(rcColorBufferCacheFlush_client_proc_t f) { rcColorBufferCacheFlush_client_proc_t retval = rcColorBufferCacheFlush; rcColorBufferCacheFlush = f; return retval;} virtual rcReadColorBuffer_client_proc_t set_rcReadColorBuffer(rcReadColorBuffer_client_proc_t f) { rcReadColorBuffer_client_proc_t retval = rcReadColorBuffer; rcReadColorBuffer = f; return retval;} virtual rcUpdateColorBuffer_client_proc_t set_rcUpdateColorBuffer(rcUpdateColorBuffer_client_proc_t f) { rcUpdateColorBuffer_client_proc_t retval = rcUpdateColorBuffer; rcUpdateColorBuffer = f; return retval;} + virtual rcOpenColorBuffer2_client_proc_t set_rcOpenColorBuffer2(rcOpenColorBuffer2_client_proc_t f) { rcOpenColorBuffer2_client_proc_t retval = rcOpenColorBuffer2; rcOpenColorBuffer2 = f; return retval;} virtual ~renderControl_client_context_t() {} typedef renderControl_client_context_t *CONTEXT_ACCESSOR_TYPE(void); diff --git a/opengl/system/renderControl_enc/renderControl_client_proc.h b/opengl/system/renderControl_enc/renderControl_client_proc.h index 3e00290b..85200cf1 100644 --- a/opengl/system/renderControl_enc/renderControl_client_proc.h +++ b/opengl/system/renderControl_enc/renderControl_client_proc.h @@ -34,6 +34,7 @@ typedef void (renderControl_APIENTRY *rcBindRenderbuffer_client_proc_t) (void * typedef EGLint (renderControl_APIENTRY *rcColorBufferCacheFlush_client_proc_t) (void * ctx, uint32_t, EGLint, int); typedef void (renderControl_APIENTRY *rcReadColorBuffer_client_proc_t) (void * ctx, uint32_t, GLint, GLint, GLint, GLint, GLenum, GLenum, void*); typedef int (renderControl_APIENTRY *rcUpdateColorBuffer_client_proc_t) (void * ctx, uint32_t, GLint, GLint, GLint, GLint, GLenum, GLenum, void*); +typedef int (renderControl_APIENTRY *rcOpenColorBuffer2_client_proc_t) (void * ctx, uint32_t); #endif diff --git a/opengl/system/renderControl_enc/renderControl_enc.cpp b/opengl/system/renderControl_enc/renderControl_enc.cpp index 41f59d0c..a40a501a 100644 --- a/opengl/system/renderControl_enc/renderControl_enc.cpp +++ b/opengl/system/renderControl_enc/renderControl_enc.cpp @@ -505,6 +505,25 @@ int rcUpdateColorBuffer_enc(void *self , uint32_t colorbuffer, GLint x, GLint y, return retval; } +int rcOpenColorBuffer2_enc(void *self , uint32_t colorbuffer) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + + unsigned char *ptr; + const size_t packetSize = 8 + 4; + ptr = stream->alloc(packetSize); + int tmp = OP_rcOpenColorBuffer2;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &packetSize, 4); ptr += 4; + + memcpy(ptr, &colorbuffer, 4); ptr += 4; + + int retval; + stream->readback(&retval, 4); + return retval; +} + renderControl_encoder_context_t::renderControl_encoder_context_t(IOStream *stream) { m_stream = stream; @@ -534,5 +553,6 @@ renderControl_encoder_context_t::renderControl_encoder_context_t(IOStream *strea set_rcColorBufferCacheFlush(rcColorBufferCacheFlush_enc); set_rcReadColorBuffer(rcReadColorBuffer_enc); set_rcUpdateColorBuffer(rcUpdateColorBuffer_enc); + set_rcOpenColorBuffer2(rcOpenColorBuffer2_enc); } diff --git a/opengl/system/renderControl_enc/renderControl_enc.h b/opengl/system/renderControl_enc/renderControl_enc.h index 712eeb9d..92ef76e5 100644 --- a/opengl/system/renderControl_enc/renderControl_enc.h +++ b/opengl/system/renderControl_enc/renderControl_enc.h @@ -47,5 +47,6 @@ extern "C" { EGLint rcColorBufferCacheFlush_enc(void *self , uint32_t colorbuffer, EGLint postCount, int forRead); void rcReadColorBuffer_enc(void *self , uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void* pixels); int rcUpdateColorBuffer_enc(void *self , uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void* pixels); + int rcOpenColorBuffer2_enc(void *self , uint32_t colorbuffer); }; #endif
\ No newline at end of file diff --git a/opengl/system/renderControl_enc/renderControl_entry.cpp b/opengl/system/renderControl_enc/renderControl_entry.cpp index 9a0bba99..a15fd144 100644 --- a/opengl/system/renderControl_enc/renderControl_entry.cpp +++ b/opengl/system/renderControl_enc/renderControl_entry.cpp @@ -31,6 +31,7 @@ extern "C" { EGLint rcColorBufferCacheFlush(uint32_t colorbuffer, EGLint postCount, int forRead); void rcReadColorBuffer(uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void* pixels); int rcUpdateColorBuffer(uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void* pixels); + int rcOpenColorBuffer2(uint32_t colorbuffer); }; #endif @@ -190,3 +191,9 @@ int rcUpdateColorBuffer(uint32_t colorbuffer, GLint x, GLint y, GLint width, GLi return ctx->rcUpdateColorBuffer(ctx, colorbuffer, x, y, width, height, format, type, pixels); } +int rcOpenColorBuffer2(uint32_t colorbuffer) +{ + GET_CONTEXT; + return ctx->rcOpenColorBuffer2(ctx, colorbuffer); +} + diff --git a/opengl/system/renderControl_enc/renderControl_ftable.h b/opengl/system/renderControl_enc/renderControl_ftable.h index 1e9e2f93..a43fe5bc 100644 --- a/opengl/system/renderControl_enc/renderControl_ftable.h +++ b/opengl/system/renderControl_enc/renderControl_ftable.h @@ -33,6 +33,7 @@ static struct _renderControl_funcs_by_name { {"rcColorBufferCacheFlush", (void*)rcColorBufferCacheFlush}, {"rcReadColorBuffer", (void*)rcReadColorBuffer}, {"rcUpdateColorBuffer", (void*)rcUpdateColorBuffer}, + {"rcOpenColorBuffer2", (void*)rcOpenColorBuffer2}, }; static int renderControl_num_funcs = sizeof(renderControl_funcs_by_name) / sizeof(struct _renderControl_funcs_by_name); diff --git a/opengl/system/renderControl_enc/renderControl_opcodes.h b/opengl/system/renderControl_enc/renderControl_opcodes.h index b44f5d06..a00dc777 100644 --- a/opengl/system/renderControl_enc/renderControl_opcodes.h +++ b/opengl/system/renderControl_enc/renderControl_opcodes.h @@ -28,7 +28,8 @@ #define OP_rcColorBufferCacheFlush 10022 #define OP_rcReadColorBuffer 10023 #define OP_rcUpdateColorBuffer 10024 -#define OP_last 10025 +#define OP_rcOpenColorBuffer2 10025 +#define OP_last 10026 #endif |