diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp index 68aa2a839..f6cf31f51 100644 --- a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp +++ b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp @@ -73,6 +73,7 @@ static void initContext(GLEScontext* ctx,ShareGroupPtr grp) { ctx->setShareGroup(grp); ctx->init(); glBindTexture(GL_TEXTURE_2D,0); + glBindTexture(GL_TEXTURE_CUBE_MAP_OES,0); } } @@ -169,7 +170,12 @@ GL_API GLESiface* __translator_getIfaces(EGLiface* eglIface){ } -static TextureData* getTextureData(unsigned int tex){ +static ObjectLocalName TextureLocalName(GLenum target, unsigned int tex) { + GET_CTX_RET(0); + return (tex!=0? tex : ctx->getDefaultTextureName(target)); +} + +static TextureData* getTextureData(ObjectLocalName tex){ GET_CTX_RET(NULL); if(!thrd->shareGroup->isObject(TEXTURE,tex)) @@ -188,11 +194,10 @@ static TextureData* getTextureData(unsigned int tex){ return texData; } -static TextureData* getTextureData(){ +static TextureData* getTextureTargetData(GLenum target){ GET_CTX_RET(NULL); - unsigned int tex = ctx->getBindedTexture(); - - return getTextureData(tex); + unsigned int tex = ctx->getBindedTexture(target); + return getTextureData(TextureLocalName(target,tex)); } GL_API GLboolean GL_APIENTRY glIsBuffer(GLuint buffer) { @@ -303,19 +308,27 @@ GL_API void GL_APIENTRY glBindTexture( GLenum target, GLuint texture) { GET_CTX() SET_ERROR_IF(!GLEScmValidate::textureTarget(target),GL_INVALID_ENUM) - GLuint globalTextureName = texture; + //for handling default texture (0) + ObjectLocalName localTexName = TextureLocalName(target,texture); + + GLuint globalTextureName = localTexName; if(thrd->shareGroup.Ptr()){ - globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,texture); + globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,localTexName); //if texture wasn't generated before,generate one if(!globalTextureName){ - thrd->shareGroup->genName(TEXTURE,texture); - globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,texture); + thrd->shareGroup->genName(TEXTURE,localTexName); + globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,localTexName); } - } - ctx->setBindedTexture(texture); - TextureData* tex = getTextureData(texture); - tex->wasBound = true; + TextureData* texData = getTextureData(localTexName); + if (texData->target==0) + texData->target = target; + //if texture was already bound to another target + SET_ERROR_IF(texData->target!=target,GL_INVALID_OPERATION); + texData->wasBound = true; + } + + ctx->setBindedTexture(target,texture); ctx->dispatcher().glBindTexture(target,globalTextureName); } @@ -483,11 +496,11 @@ GL_API void GL_APIENTRY glDeleteTextures( GLsizei n, const GLuint *textures) { thrd->shareGroup->deleteName(TEXTURE,textures[i]); const GLuint globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,textures[i]); ctx->dispatcher().glDeleteTextures(1,&globalTextureName); - - if(ctx->getBindedTexture() == textures[i]) - { - ctx->setBindedTexture(0); - } + + if(ctx->getBindedTexture(GL_TEXTURE_2D) == textures[i]) + ctx->setBindedTexture(GL_TEXTURE_2D,0); + if (ctx->getBindedTexture(GL_TEXTURE_CUBE_MAP) == textures[i]) + ctx->setBindedTexture(GL_TEXTURE_CUBE_MAP,0); } } } @@ -521,10 +534,8 @@ GL_API void GL_APIENTRY glDisable( GLenum cap) { ctx->dispatcher().glDisable(GL_TEXTURE_GEN_R); } ctx->dispatcher().glDisable(cap); - if (cap==GL_TEXTURE_2D) - ctx->setTextureEnabled(TEXTURE_2D,false); - else if (cap==GL_TEXTURE_CUBE_MAP_OES) - ctx->setTextureEnabled(TEXTURE_CUBE_MAP,false); + if (cap==GL_TEXTURE_2D || cap==GL_TEXTURE_CUBE_MAP_OES) + ctx->setTextureEnabled(cap,false); } GL_API void GL_APIENTRY glDisableClientState( GLenum array) { @@ -585,10 +596,8 @@ GL_API void GL_APIENTRY glEnable( GLenum cap) { } else ctx->dispatcher().glEnable(cap); - if (cap==GL_TEXTURE_2D) - ctx->setTextureEnabled(TEXTURE_2D,true); - else if (cap==GL_TEXTURE_CUBE_MAP_OES) - ctx->setTextureEnabled(TEXTURE_CUBE_MAP,true); + if (cap==GL_TEXTURE_2D || cap==GL_TEXTURE_CUBE_MAP_OES) + ctx->setTextureEnabled(cap,true); } GL_API void GL_APIENTRY glEnableClientState( GLenum array) { @@ -986,7 +995,7 @@ GL_API void GL_APIENTRY glGetTexEnvxv( GLenum env, GLenum pname, GLfixed *param GL_API void GL_APIENTRY glGetTexParameterfv( GLenum target, GLenum pname, GLfloat *params) { GET_CTX() if (pname==GL_TEXTURE_CROP_RECT_OES) { - TextureData *texData = getTextureData(); + TextureData *texData = getTextureTargetData(target); SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION); for (int i=0;i<4;++i) params[i] = texData->crop_rect[i]; @@ -999,7 +1008,7 @@ GL_API void GL_APIENTRY glGetTexParameterfv( GLenum target, GLenum pname, GLflo GL_API void GL_APIENTRY glGetTexParameteriv( GLenum target, GLenum pname, GLint *params) { GET_CTX() if (pname==GL_TEXTURE_CROP_RECT_OES) { - TextureData *texData = getTextureData(); + TextureData *texData = getTextureTargetData(target); SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION); for (int i=0;i<4;++i) params[i] = texData->crop_rect[i]; @@ -1012,7 +1021,7 @@ GL_API void GL_APIENTRY glGetTexParameteriv( GLenum target, GLenum pname, GLint GL_API void GL_APIENTRY glGetTexParameterxv( GLenum target, GLenum pname, GLfixed *params) { GET_CTX() if (pname==GL_TEXTURE_CROP_RECT_OES) { - TextureData *texData = getTextureData(); + TextureData *texData = getTextureTargetData(target); SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION); for (int i=0;i<4;++i) params[i] = F2X(texData->crop_rect[i]); @@ -1419,13 +1428,14 @@ GL_API void GL_APIENTRY glTexImage2D( GLenum target, GLint level, GLint interna ctx->dispatcher().glTexImage2D(target,level,internalformat,width,height,border,format,type,pixels); if (thrd->shareGroup.Ptr()){ - TextureData *texData = getTextureData(); + TextureData *texData = getTextureTargetData(target); SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION); if(texData) { texData->width = width; texData->height = height; texData->border = border; texData->internalFormat = internalformat; + texData->target = target; if(texData->requiresAutoMipmap) { @@ -1435,13 +1445,13 @@ GL_API void GL_APIENTRY glTexImage2D( GLenum target, GLint level, GLint interna } } -static bool handleMipmapGeneration(GLenum pname, bool param) +static bool handleMipmapGeneration(GLenum target, GLenum pname, bool param) { GET_CTX_RET(false) if(pname == GL_GENERATE_MIPMAP && !ctx->isAutoMipmapSupported()) { - TextureData *texData = getTextureData(); + TextureData *texData = getTextureTargetData(target); if(texData) { texData->requiresAutoMipmap = param; @@ -1456,7 +1466,7 @@ GL_API void GL_APIENTRY glTexParameterf( GLenum target, GLenum pname, GLfloat p GET_CTX() SET_ERROR_IF(!GLEScmValidate::texParams(target,pname),GL_INVALID_ENUM); - if(handleMipmapGeneration(pname, (bool)param)) + if(handleMipmapGeneration(target, pname, (bool)param)) return; ctx->dispatcher().glTexParameterf(target,pname,param); @@ -1466,11 +1476,11 @@ GL_API void GL_APIENTRY glTexParameterfv( GLenum target, GLenum pname, const GL GET_CTX() SET_ERROR_IF(!GLEScmValidate::texParams(target,pname),GL_INVALID_ENUM); - if(handleMipmapGeneration(pname, (bool)(*params))) + if(handleMipmapGeneration(target, pname, (bool)(*params))) return; if (pname==GL_TEXTURE_CROP_RECT_OES) { - TextureData *texData = getTextureData(); + TextureData *texData = getTextureTargetData(target); SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION); for (int i=0;i<4;++i) texData->crop_rect[i] = params[i]; @@ -1484,7 +1494,7 @@ GL_API void GL_APIENTRY glTexParameteri( GLenum target, GLenum pname, GLint par GET_CTX() SET_ERROR_IF(!GLEScmValidate::texParams(target,pname),GL_INVALID_ENUM); - if(handleMipmapGeneration(pname, (bool)param)) + if(handleMipmapGeneration(target, pname, (bool)param)) return; ctx->dispatcher().glTexParameteri(target,pname,param); @@ -1494,11 +1504,11 @@ GL_API void GL_APIENTRY glTexParameteriv( GLenum target, GLenum pname, const GL GET_CTX() SET_ERROR_IF(!GLEScmValidate::texParams(target,pname),GL_INVALID_ENUM); - if(handleMipmapGeneration(pname, (bool)(*params))) + if(handleMipmapGeneration(target, pname, (bool)(*params))) return; if (pname==GL_TEXTURE_CROP_RECT_OES) { - TextureData *texData = getTextureData(); + TextureData *texData = getTextureTargetData(target); SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION); for (int i=0;i<4;++i) texData->crop_rect[i] = params[i]; @@ -1512,7 +1522,7 @@ GL_API void GL_APIENTRY glTexParameterx( GLenum target, GLenum pname, GLfixed p GET_CTX() SET_ERROR_IF(!GLEScmValidate::texParams(target,pname),GL_INVALID_ENUM); - if(handleMipmapGeneration(pname, (bool)param)) + if(handleMipmapGeneration(target, pname, (bool)param)) return; ctx->dispatcher().glTexParameterf(target,pname,static_cast(param)); @@ -1522,11 +1532,11 @@ GL_API void GL_APIENTRY glTexParameterxv( GLenum target, GLenum pname, const GL GET_CTX() SET_ERROR_IF(!GLEScmValidate::texParams(target,pname),GL_INVALID_ENUM); - if(handleMipmapGeneration(pname, (bool)(*params))) + if(handleMipmapGeneration(target, pname, (bool)(*params))) return; if (pname==GL_TEXTURE_CROP_RECT_OES) { - TextureData *texData = getTextureData(); + TextureData *texData = getTextureTargetData(target); SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION); for (int i=0;i<4;++i) texData->crop_rect[i] = X2F(params[i]); @@ -1547,7 +1557,7 @@ GL_API void GL_APIENTRY glTexSubImage2D( GLenum target, GLint level, GLint xoff ctx->dispatcher().glTexSubImage2D(target,level,xoffset,yoffset,width,height,format,type,pixels); if (thrd->shareGroup.Ptr()){ - TextureData *texData = getTextureData(); + TextureData *texData = getTextureTargetData(target); SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION); if(texData && texData->requiresAutoMipmap) { @@ -1588,7 +1598,7 @@ GL_API void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOE // flag to the OpenGL layer to skip the image creation and map the // current binded texture object to the existing global object. if (thrd->shareGroup.Ptr()) { - unsigned int tex = ctx->getBindedTexture(); + ObjectLocalName tex = TextureLocalName(target,ctx->getBindedTexture(target)); unsigned int oldGlobal = thrd->shareGroup->getGlobalName(TEXTURE, tex); // Delete old texture object if (oldGlobal) { @@ -1597,7 +1607,7 @@ GL_API void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOE // replace mapping and bind the new global object thrd->shareGroup->replaceGlobalName(TEXTURE, tex,img->globalTexName); ctx->dispatcher().glBindTexture(GL_TEXTURE_2D, img->globalTexName); - TextureData *texData = getTextureData(); + TextureData *texData = getTextureTargetData(target); SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION); texData->sourceEGLImage = (unsigned int)image; texData->eglImageDetach = s_eglIface->eglDetachEGLImage; @@ -1981,7 +1991,8 @@ void glDrawTexOES (T x, T y, T z, T width, T height) { for (int i=0;igetMaxTexUnits();++i) { if (ctx->isTextureUnitEnabled(GL_TEXTURE0+i)) { TextureData * texData = NULL; - int tex = ctx->getBindedTexture(GL_TEXTURE0+i); + unsigned int texname = ctx->getBindedTexture(GL_TEXTURE0+i,GL_TEXTURE_2D); + ObjectLocalName tex = TextureLocalName(GL_TEXTURE_2D,texname); ctx->dispatcher().glClientActiveTexture(GL_TEXTURE0+i); ObjectDataPtr objData = thrd->shareGroup->getObjectData(TEXTURE,tex); if (objData.Ptr()) { diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp index 76348efc2..8d2556f2c 100644 --- a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp +++ b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp @@ -70,6 +70,7 @@ static void initContext(GLEScontext* ctx,ShareGroupPtr grp) { ctx->setShareGroup(grp); ctx->init(); glBindTexture(GL_TEXTURE_2D,0); + glBindTexture(GL_TEXTURE_CUBE_MAP,0); } } static GLEScontext* createGLESContext() { @@ -115,6 +116,30 @@ GL_APICALL GLESiface* __translator_getIfaces(EGLiface* eglIface){ } +static ObjectLocalName TextureLocalName(GLenum target,unsigned int tex) { + GET_CTX_RET(0); + return (tex!=0? tex : ctx->getDefaultTextureName(target)); +} + +static TextureData* getTextureData(ObjectLocalName tex) { + GET_CTX_RET(NULL); + TextureData *texData = NULL; + ObjectDataPtr objData = thrd->shareGroup->getObjectData(TEXTURE,tex); + if(!objData.Ptr()){ + texData = new TextureData(); + thrd->shareGroup->setObjectData(TEXTURE, tex, ObjectDataPtr(texData)); + } else { + texData = (TextureData*)objData.Ptr(); + } + return texData; +} + +static TextureData* getTextureTargetData(GLenum target){ + GET_CTX_RET(NULL); + unsigned int tex = ctx->getBindedTexture(target); + return getTextureData(TextureLocalName(target,tex)); +} + GL_APICALL void GL_APIENTRY glActiveTexture(GLenum texture){ GET_CTX_V2(); SET_ERROR_IF (!GLESv2Validate::textureEnum(texture,ctx->getMaxTexUnits()),GL_INVALID_ENUM); @@ -204,16 +229,27 @@ GL_APICALL void GL_APIENTRY glBindTexture(GLenum target, GLuint texture){ GET_CTX(); SET_ERROR_IF(!GLESv2Validate::textureTarget(target),GL_INVALID_ENUM) - GLuint globalTextureName = texture; + //for handling default texture (0) + ObjectLocalName localTexName = TextureLocalName(target,texture); + + GLuint globalTextureName = localTexName; if(thrd->shareGroup.Ptr()){ - globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,texture); + globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,localTexName); //if texture wasn't generated before,generate one if(!globalTextureName){ - thrd->shareGroup->genName(TEXTURE,texture); - globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,texture); + thrd->shareGroup->genName(TEXTURE,localTexName); + globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,localTexName); } + + TextureData* texData = getTextureData(localTexName); + if (texData->target==0) + texData->target = target; + //if texture was already bound to another target + SET_ERROR_IF(texData->target !=target,GL_INVALID_OPERATION); + texData->wasBound = true; } - ctx->setBindedTexture(texture); + + ctx->setBindedTexture(target,texture); ctx->dispatcher().glBindTexture(target,globalTextureName); } @@ -403,9 +439,16 @@ GL_APICALL void GL_APIENTRY glDeleteTextures(GLsizei n, const GLuint* textures) SET_ERROR_IF(n<0,GL_INVALID_VALUE); if(thrd->shareGroup.Ptr()) { for(int i=0; i < n; i++){ - const GLuint globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,textures[i]); - thrd->shareGroup->deleteName(TEXTURE,textures[i]); - ctx->dispatcher().glDeleteTextures(1,&globalTextureName); + if (textures[i]!=0) { + const GLuint globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,textures[i]); + thrd->shareGroup->deleteName(TEXTURE,textures[i]); + ctx->dispatcher().glDeleteTextures(1,&globalTextureName); + + if (ctx->getBindedTexture(GL_TEXTURE_2D) == textures[i]) + ctx->setBindedTexture(GL_TEXTURE_2D,0); + if (ctx->getBindedTexture(GL_TEXTURE_CUBE_MAP) == textures[i]) + ctx->setBindedTexture(GL_TEXTURE_CUBE_MAP,0); + } } } } @@ -571,7 +614,8 @@ GL_APICALL void GL_APIENTRY glFramebufferTexture2D(GLenum target, GLenum attach SET_ERROR_IF(level != 0, GL_INVALID_VALUE); if(thrd->shareGroup.Ptr()) { - GLuint globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,texture); + ObjectLocalName texname = TextureLocalName(textarget,texture); + GLuint globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,texname); ctx->dispatcher().glFramebufferTexture2DEXT(target,attachment,textarget,globalTextureName,level); } } @@ -1158,10 +1202,10 @@ GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer(GLuint renderbuffer){ GL_APICALL GLboolean GL_APIENTRY glIsTexture(GLuint texture){ GET_CTX_RET(GL_FALSE) - if(texture && thrd->shareGroup.Ptr()){ - return thrd->shareGroup->isObject(TEXTURE,texture) ? GL_TRUE :GL_FALSE; - } - return GL_FALSE; + if (texture==0) + return GL_FALSE; + TextureData* tex = getTextureData(texture); + return tex ? tex->wasBound : GL_FALSE; } GL_APICALL GLboolean GL_APIENTRY glIsProgram(GLuint program){ @@ -1310,20 +1354,6 @@ GL_APICALL void GL_APIENTRY glStencilOpSeparate(GLenum face, GLenum fail, GLenu ctx->dispatcher().glStencilOp(fail,zfail,zpass); } -static TextureData* getTextureData(){ - GET_CTX_RET(NULL); - unsigned int tex = ctx->getBindedTexture(); - TextureData *texData = NULL; - ObjectDataPtr objData = thrd->shareGroup->getObjectData(TEXTURE,tex); - if(!objData.Ptr()){ - texData = new TextureData(); - thrd->shareGroup->setObjectData(TEXTURE, tex, ObjectDataPtr(texData)); - } else { - texData = (TextureData*)objData.Ptr(); - } - return texData; -} - GL_APICALL void GL_APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels){ GET_CTX(); SET_ERROR_IF(!(GLESv2Validate::textureTargetEx(target) && @@ -1335,13 +1365,13 @@ GL_APICALL void GL_APIENTRY glTexImage2D(GLenum target, GLint level, GLint inte SET_ERROR_IF(border != 0,GL_INVALID_VALUE); if (thrd->shareGroup.Ptr()){ - unsigned int tex = ctx->getBindedTexture(); - TextureData *texData = getTextureData(); + TextureData *texData = getTextureTargetData(target); if(texData) { texData->width = width; texData->height = height; texData->border = border; texData->internalFormat = internalformat; + texData->target = target; } } if (type==GL_HALF_FLOAT_OES) @@ -1553,7 +1583,7 @@ GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglIma // flag to the OpenGL layer to skip the image creation and map the // current binded texture object to the existing global object. if (thrd->shareGroup.Ptr()) { - unsigned int tex = ctx->getBindedTexture(); + ObjectLocalName tex = TextureLocalName(target,ctx->getBindedTexture(target)); unsigned int oldGlobal = thrd->shareGroup->getGlobalName(TEXTURE, tex); // Delete old texture object if (oldGlobal) { @@ -1562,7 +1592,7 @@ GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglIma // replace mapping and bind the new global object thrd->shareGroup->replaceGlobalName(TEXTURE, tex,img->globalTexName); ctx->dispatcher().glBindTexture(GL_TEXTURE_2D, img->globalTexName); - TextureData *texData = getTextureData(); + TextureData *texData = getTextureTargetData(target); SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION); texData->sourceEGLImage = (unsigned int)image; texData->eglImageDetach = s_eglIface->eglDetachEGLImage; diff --git a/tools/emulator/opengl/host/libs/Translator/GLcommon/GLEScontext.cpp b/tools/emulator/opengl/host/libs/Translator/GLcommon/GLEScontext.cpp index fadb27547..43bbf7bbe 100644 --- a/tools/emulator/opengl/host/libs/Translator/GLcommon/GLEScontext.cpp +++ b/tools/emulator/opengl/host/libs/Translator/GLcommon/GLEScontext.cpp @@ -121,11 +121,13 @@ void GLEScontext::init() { initExtensionString(); int maxTexUnits = getMaxTexUnits(); - m_tex2DBind = new textureUnitState[maxTexUnits]; + m_texState = new textureUnitState[maxTexUnits]; for (int i=0;i ObjectIDPair; +typedef std::pair ObjectIDPair; typedef std::map ObjectDataMap; ShareGroup::ShareGroup(GlobalNameSpace *globalNameSpace) @@ -133,20 +133,20 @@ ShareGroup::~ShareGroup() mutex_destroy(&m_lock); } -unsigned int -ShareGroup::genName(NamedObjectType p_type, unsigned int p_localName, bool genLocal) +ObjectLocalName +ShareGroup::genName(NamedObjectType p_type, ObjectLocalName p_localName, bool genLocal) { if (p_type >= NUM_OBJECT_TYPES) return 0; mutex_lock(&m_lock); - unsigned int localName = m_nameSpace[p_type]->genName(p_localName,true,genLocal); + ObjectLocalName localName = m_nameSpace[p_type]->genName(p_localName,true,genLocal); mutex_unlock(&m_lock); return localName; } unsigned int -ShareGroup::getGlobalName(NamedObjectType p_type, unsigned int p_localName) +ShareGroup::getGlobalName(NamedObjectType p_type, ObjectLocalName p_localName) { if (p_type >= NUM_OBJECT_TYPES) return 0; @@ -157,20 +157,20 @@ ShareGroup::getGlobalName(NamedObjectType p_type, unsigned int p_localName) return globalName; } -unsigned int +ObjectLocalName ShareGroup::getLocalName(NamedObjectType p_type, unsigned int p_globalName) { if (p_type >= NUM_OBJECT_TYPES) return 0; mutex_lock(&m_lock); - unsigned int localName = m_nameSpace[p_type]->getLocalName(p_globalName); + ObjectLocalName localName = m_nameSpace[p_type]->getLocalName(p_globalName); mutex_unlock(&m_lock); return localName; } void -ShareGroup::deleteName(NamedObjectType p_type, unsigned int p_localName) +ShareGroup::deleteName(NamedObjectType p_type, ObjectLocalName p_localName) { if (p_type >= NUM_OBJECT_TYPES) return; @@ -184,7 +184,7 @@ ShareGroup::deleteName(NamedObjectType p_type, unsigned int p_localName) } bool -ShareGroup::isObject(NamedObjectType p_type, unsigned int p_localName) +ShareGroup::isObject(NamedObjectType p_type, ObjectLocalName p_localName) { if (p_type >= NUM_OBJECT_TYPES) return 0; @@ -196,7 +196,7 @@ ShareGroup::isObject(NamedObjectType p_type, unsigned int p_localName) } void -ShareGroup::replaceGlobalName(NamedObjectType p_type, unsigned int p_localName, unsigned int p_globalName) +ShareGroup::replaceGlobalName(NamedObjectType p_type, ObjectLocalName p_localName, unsigned int p_globalName) { if (p_type >= NUM_OBJECT_TYPES) return; @@ -206,7 +206,7 @@ ShareGroup::replaceGlobalName(NamedObjectType p_type, unsigned int p_localName, } void -ShareGroup::setObjectData(NamedObjectType p_type, unsigned int p_localName, ObjectDataPtr data) +ShareGroup::setObjectData(NamedObjectType p_type, ObjectLocalName p_localName, ObjectDataPtr data) { if (p_type >= NUM_OBJECT_TYPES) return; @@ -225,7 +225,7 @@ ShareGroup::setObjectData(NamedObjectType p_type, unsigned int p_localName, Obje } ObjectDataPtr -ShareGroup::getObjectData(NamedObjectType p_type, unsigned int p_localName) +ShareGroup::getObjectData(NamedObjectType p_type, ObjectLocalName p_localName) { ObjectDataPtr ret; diff --git a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h index 746cca124..035f521c4 100644 --- a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h +++ b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h @@ -15,10 +15,12 @@ TEXTURE_CUBE_MAP, NUM_TEXTURE_TARGETS }; -typedef struct _textureUnitState { +typedef struct _textureTargetState { GLuint texture; - GLboolean enabled[NUM_TEXTURE_TARGETS]; -} textureUnitState; + GLboolean enabled; +} textureTargetState; + +typedef textureTargetState textureUnitState[NUM_TEXTURE_TARGETS]; class Version{ public: @@ -102,11 +104,12 @@ public: void setGLerror(GLenum err); void setShareGroup(ShareGroupPtr grp){m_shareGroup = grp;}; virtual void setActiveTexture(GLenum tex); - unsigned int getBindedTexture(){return m_tex2DBind[m_activeTexture].texture;}; - unsigned int getBindedTexture(GLenum unit) { return m_tex2DBind[unit - GL_TEXTURE0].texture;}; - void setBindedTexture(unsigned int tex){ m_tex2DBind[m_activeTexture].texture = tex;}; + unsigned int getBindedTexture(GLenum target); + unsigned int getBindedTexture(GLenum unit,GLenum target); + void setBindedTexture(GLenum target,unsigned int tex); bool isTextureUnitEnabled(GLenum unit); - void setTextureEnabled(TextureTarget target, GLenum enable) {m_tex2DBind[m_activeTexture].enabled[target] = enable; }; + void setTextureEnabled(GLenum target, GLenum enable); + ObjectLocalName getDefaultTextureName(GLenum target); bool isInitialized() { return m_initialized; }; void setUnpackAlignment(GLint param){ m_unpackAlignment = param; }; GLint getUnpackAlignment(){ return m_unpackAlignment; }; @@ -166,10 +169,11 @@ private: virtual void setupArr(const GLvoid* arr,GLenum arrayType,GLenum dataType,GLint size,GLsizei stride, GLboolean normalized, int pointsIndex = -1) = 0 ; GLuint getBuffer(GLenum target); + TextureTarget GLTextureTargetToLocal(GLenum target); ShareGroupPtr m_shareGroup; GLenum m_glError; - textureUnitState* m_tex2DBind; + textureUnitState* m_texState; unsigned int m_arrayBuffer; unsigned int m_elementBuffer; }; diff --git a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h index 1da457306..19f69e590 100644 --- a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h +++ b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h @@ -44,7 +44,8 @@ public: internalFormat(GL_RGBA), sourceEGLImage(0), wasBound(false), - requiresAutoMipmap(false){ + requiresAutoMipmap(false), + target(0) { memset(crop_rect,0,4*sizeof(int)); }; @@ -57,6 +58,7 @@ public: bool requiresAutoMipmap; int crop_rect[4]; void (*eglImageDetach)(unsigned int imageId); + GLenum target; }; struct EglImage diff --git a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/objectNameManager.h b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/objectNameManager.h index aeb01f60b..726f241d1 100644 --- a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/objectNameManager.h +++ b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/objectNameManager.h @@ -20,8 +20,6 @@ #include #include "SmartPtr.h" -typedef std::map NamesMap; - enum NamedObjectType { VERTEXBUFFER = 0, TEXTURE = 1, @@ -50,6 +48,8 @@ private: ObjectDataType m_dataType; }; typedef SmartPtr ObjectDataPtr; +typedef unsigned long long ObjectLocalName; +typedef std::map NamesMap; // // Class NameSpace - this class manages allocations and deletions of objects @@ -78,38 +78,38 @@ private: // the value of the global name can be retrieved using the // getGlobalName function. // - unsigned int genName(unsigned int p_localName, bool genGlobal, bool genLocal); + ObjectLocalName genName(ObjectLocalName p_localName, bool genGlobal, bool genLocal); // // getGlobalName - returns the global name of an object or 0 if the object // does not exist. // - unsigned int getGlobalName(unsigned int p_localName); + unsigned int getGlobalName(ObjectLocalName p_localName); // // getLocaalName - returns the local name of an object or 0 if the object // does not exist. // - unsigned int getLocalName(unsigned int p_globalName); + ObjectLocalName getLocalName(unsigned int p_globalName); // // deleteName - deletes and object from the namespace as well as its // global name from the global name space. // - void deleteName(unsigned int p_localName); + void deleteName(ObjectLocalName p_localName); // // isObject - returns true if the named object exist. // - bool isObject(unsigned int p_localName); + bool isObject(ObjectLocalName p_localName); // // replaces an object to map to an existing global object // - void replaceGlobalName(unsigned int p_localName, unsigned int p_globalName); + void replaceGlobalName(ObjectLocalName p_localName, unsigned int p_globalName); private: - unsigned int m_nextName; + ObjectLocalName m_nextName; NamesMap m_localToGlobalMap; const NamedObjectType m_type; GlobalNameSpace *m_globalNameSpace; @@ -183,46 +183,46 @@ public: // This function also generates a "global" name for the object // which can be queried using the getGlobalName function. // - unsigned int genName(NamedObjectType p_type, unsigned int p_localName = 0, bool genLocal= false); + ObjectLocalName genName(NamedObjectType p_type, ObjectLocalName p_localName = 0, bool genLocal= false); // // getGlobalName - retrieves the "global" name of an object or 0 if the // object does not exist. // - unsigned int getGlobalName(NamedObjectType p_type, unsigned int p_localName); + unsigned int getGlobalName(NamedObjectType p_type, ObjectLocalName p_localName); // // getLocalName - retrieves the "local" name of an object or 0 if the // object does not exist. // - unsigned int getLocalName(NamedObjectType p_type, unsigned int p_globalName); + ObjectLocalName getLocalName(NamedObjectType p_type, unsigned int p_globalName); // // deleteName - deletes and object from the namespace as well as its // global name from the global name space. // - void deleteName(NamedObjectType p_type, unsigned int p_localName); + void deleteName(NamedObjectType p_type, ObjectLocalName p_localName); // // replaceGlobalName - replaces an object to map to an existing global // named object. (used when creating EGLImage siblings) // - void replaceGlobalName(NamedObjectType p_type, unsigned int p_localName, unsigned int p_globalName); + void replaceGlobalName(NamedObjectType p_type, ObjectLocalName p_localName, unsigned int p_globalName); // // isObject - returns true if the named object exist. // - bool isObject(NamedObjectType p_type, unsigned int p_localName); + bool isObject(NamedObjectType p_type, ObjectLocalName p_localName); // // Assign object global data to a names object // - void setObjectData(NamedObjectType p_type, unsigned int p_localName, ObjectDataPtr data); + void setObjectData(NamedObjectType p_type, ObjectLocalName p_localName, ObjectDataPtr data); // // Retrieve object global data // - ObjectDataPtr getObjectData(NamedObjectType p_type, unsigned int p_localName); + ObjectDataPtr getObjectData(NamedObjectType p_type, ObjectLocalName p_localName); private: explicit ShareGroup(GlobalNameSpace *globalNameSpace);