opengl translator: conformance fixes
- fix destructor of eglcontext to delete its share group if needed
- fix available eglconfigs not to choose configs with BUFFER_SIZE=0
or configs which do not support RGBA
- fix conformant bit on eglconfig
- fix typo in glBindBuffer
- fix glVertexAttribPointer to send correct offset to GL with vbo
Change-Id: I69d980407a40cb371ec62c5c883e4190bdcfce72
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglConfig.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/EglConfig.cpp
index 9fcdf64..d9357c2 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/EglConfig.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglConfig.cpp
@@ -67,7 +67,10 @@
m_trans_red_val(trans_red_val),
m_trans_green_val(trans_green_val),
m_trans_blue_val(trans_blue_val),
- m_nativeFormat(frmt){};
+ m_conformant(((red_size + green_size + blue_size + alpha_size > 0) &&
+ (caveat!=EGL_NON_CONFORMANT_CONFIG)) ?
+ m_renderable_type : 0),
+ m_nativeFormat(frmt) {};
EglConfig::EglConfig(const EglConfig& conf):m_buffer_size(conf.m_buffer_size),
@@ -98,7 +101,8 @@
m_trans_red_val(conf.m_trans_red_val),
m_trans_green_val(conf.m_trans_green_val),
m_trans_blue_val(conf.m_trans_blue_val),
- m_nativeFormat(conf.m_nativeFormat){};
+ m_conformant(conf.m_conformant),
+ m_nativeFormat(conf.m_nativeFormat) {};
@@ -187,6 +191,9 @@
case EGL_TRANSPARENT_BLUE_VALUE:
*val = m_trans_blue_val;
break;
+ case EGL_CONFORMANT:
+ *val = m_conformant;
+ break;
default:
return false;
}
@@ -283,6 +290,9 @@
//mask
if(dummy.m_surface_type != EGL_DONT_CARE &&
((dummy.m_surface_type & m_surface_type) != dummy.m_surface_type)) return false;
+
+ if(dummy.m_conformant != EGL_DONT_CARE &&
+ ((dummy.m_conformant & m_conformant) != dummy.m_conformant)) return false;
if(dummy.m_renderable_type != EGL_DONT_CARE &&
((dummy.m_renderable_type & m_renderable_type) != dummy.m_renderable_type)) return false;
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglConfig.h b/tools/emulator/opengl/host/libs/Translator/EGL/EglConfig.h
index 3336f0e..ad4e37d 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/EglConfig.h
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglConfig.h
@@ -91,6 +91,7 @@
const EGLint m_trans_red_val;
const EGLint m_trans_green_val;
const EGLint m_trans_blue_val;
+ const EGLenum m_conformant;
const EGLNativePixelFormatType m_nativeFormat;
};
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglContext.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/EglContext.cpp
index 6710baa..1223168 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/EglContext.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglContext.cpp
@@ -29,7 +29,8 @@
m_read(NULL),
m_draw(NULL),
m_destroy(false),
-m_version(ver)
+m_version(ver),
+m_mngr(mngr)
{
m_shareGroup = shared_context.Ptr()?
mngr->attachShareGroup(context,shared_context.Ptr()->getShareGroup().Ptr()):
@@ -37,6 +38,14 @@
m_hndl = ++s_nextContextHndl;
}
+EglContext::~EglContext()
+{
+ if (m_mngr)
+ {
+ m_mngr->deleteShareGroup(m_native);
+ }
+}
+
void EglContext::setSurfaces(SurfacePtr read,SurfacePtr draw)
{
m_read = read;
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglContext.h b/tools/emulator/opengl/host/libs/Translator/EGL/EglContext.h
index 5b528ab..1f54631 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/EglContext.h
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglContext.h
@@ -53,7 +53,8 @@
bool attachImage(unsigned int imageId,ImagePtr img);
void detachImage(unsigned int imageId);
- ~EglContext(){}
+ ~EglContext();
+
private:
static unsigned int s_nextContextHndl;
EGLNativeContextType m_native;
@@ -64,6 +65,7 @@
SurfacePtr m_draw;
bool m_destroy;
GLESVersion m_version;
+ ObjectNameManager *m_mngr;
unsigned int m_hndl;
ImagesHndlMap m_attachedImages;
};
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglValidate.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/EglValidate.cpp
index a4b2cc6..d87f9b9 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/EglValidate.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglValidate.cpp
@@ -46,6 +46,7 @@
case EGL_TRANSPARENT_RED_VALUE:
case EGL_TRANSPARENT_GREEN_VALUE:
case EGL_TRANSPARENT_BLUE_VALUE:
+ case EGL_CONFORMANT:
return true;
}
return false;
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglX11Api.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/EglX11Api.cpp
index a695d37..3aee4b4 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/EglX11Api.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglX11Api.cpp
@@ -39,16 +39,16 @@
android::Mutex ErrorHandler::s_lock;
ErrorHandler::ErrorHandler(EGLNativeDisplayType dpy){
- s_lock.lock();
+ android::Mutex::Autolock mutex(s_lock);
XSync(dpy,False);
s_lastErrorCode = 0;
m_oldErrorHandler = XSetErrorHandler(errorHandlerProc);
}
ErrorHandler::~ErrorHandler(){
+ android::Mutex::Autolock mutex(s_lock);
XSetErrorHandler(m_oldErrorHandler);
s_lastErrorCode = 0;
- s_lock.unlock();
}
int ErrorHandler::errorHandlerProc(EGLNativeDisplayType dpy,XErrorEvent* event){
@@ -130,7 +130,11 @@
IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_LEVEL,&level));
IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_FBCONFIG_ID,&configId));
IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_SAMPLES,&samples));
-
+ //Filter out configs that does not support RGBA
+ IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_RENDER_TYPE,&tmp));
+ if (!(tmp & GLX_RGBA_BIT)) {
+ return NULL;
+ }
return new EglConfig(red,green,blue,alpha,caveat,configId,depth,level,pMaxWidth,pMaxHeight,
pMaxPixels,renderable,renderableType,visualId,visualType,samples,stencil,
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 d708a25..7e2141c 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
@@ -141,7 +141,7 @@
}
ctx->bindBuffer(target,buffer);
GLESbuffer* vbo = (GLESbuffer*)thrd->shareGroup->getObjectData(VERTEXBUFFER,buffer).Ptr();
- vbo->wasBinded();
+ vbo->setBinded();
}
GL_APICALL void GL_APIENTRY glBindFramebuffer(GLenum target, GLuint framebuffer){
@@ -1251,7 +1251,7 @@
if (type==GL_HALF_FLOAT_OES)
type = GL_HALF_FLOAT;
const GLvoid* data = ctx->setPointer(indx,size,type,stride,ptr);
- if(type != GL_FIXED) ctx->dispatcher().glVertexAttribPointer(indx,size,type,normalized,stride,ptr);
+ if(type != GL_FIXED) ctx->dispatcher().glVertexAttribPointer(indx,size,type,normalized,stride,data);
}
GL_APICALL void GL_APIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height){