add gles2 extensions
implement extensions for gles2
add missing entry point for gles1 EGLImage extension
Change-Id: I7cf0118fdf69f3fb2a7023cf97134efd6aabbf59
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 81be5de..e4afd54 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp
@@ -95,13 +95,14 @@
else
s_glesExtensions->clear();
(*s_glesExtensions)["glEGLImageTargetTexture2DOES"] = (__translatorMustCastToProperFunctionPointerType)glEGLImageTargetTexture2DOES;
+ (*s_glesExtensions)["glEGLImageTargetRenderbufferStorageOES"]=(__translatorMustCastToProperFunctionPointerType)glEGLImageTargetRenderbufferStorageOES;
(*s_glesExtensions)["glBlendEquationSeparateOES"] = (__translatorMustCastToProperFunctionPointerType)glBlendEquationSeparateOES;
(*s_glesExtensions)["glBlendFuncSeparateOES"] = (__translatorMustCastToProperFunctionPointerType)glBlendFuncSeparateOES;
(*s_glesExtensions)["glBlendEquationOES"] = (__translatorMustCastToProperFunctionPointerType)glBlendEquationOES;
if (ctx->getCaps()->GL_ARB_MATRIX_PALETTE && ctx->getCaps()->GL_ARB_VERTEX_BLEND) {
(*s_glesExtensions)["glCurrentPaletteMatrixOES"] = (__translatorMustCastToProperFunctionPointerType)glCurrentPaletteMatrixOES;
- (*s_glesExtensions)["glLoadPaletteFromModelViewMatrixOES"] = (__translatorMustCastToProperFunctionPointerType)glLoadPaletteFromModelViewMatrixOES;
+ (*s_glesExtensions)["glLoadPaletteFromModelViewMatrixOES"]=(__translatorMustCastToProperFunctionPointerType)glLoadPaletteFromModelViewMatrixOES;
(*s_glesExtensions)["glMatrixIndexPointerOES"] = (__translatorMustCastToProperFunctionPointerType)glMatrixIndexPointerOES;
(*s_glesExtensions)["glWeightPointerOES"] = (__translatorMustCastToProperFunctionPointerType)glWeightPointerOES;
}
@@ -1452,6 +1453,13 @@
}
}
+GL_API void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image)
+{
+ GET_CTX()
+ //not supported by EGL
+ SET_ERROR_IF(false,GL_INVALID_OPERATION);
+}
+
/* GL_OES_blend_subtract*/
GL_API void GL_APIENTRY glBlendEquationOES(GLenum mode) {
GET_CTX()
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.cpp b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.cpp
index ac87717..5ec9f5c 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.cpp
@@ -21,6 +21,7 @@
if(!m_initialized) {
s_glDispatch.dispatchFuncs(GLES_2_0);
initCapsLocked(s_glDispatch.glGetString(GL_EXTENSIONS));
+ initExtensionString();
for(int i=0; i < s_glSupport.maxVertexAttribs;i++){
m_map[i] = new GLESpointer();
@@ -48,3 +49,14 @@
void GLESv2Context::sendArr(GLvoid* arr,GLenum arrayType,GLint size,GLsizei stride,int index) {
s_glDispatch.glVertexAttribPointer(arrayType,size,GL_FLOAT,GL_FALSE,stride,arr);
}
+
+void GLESv2Context::initExtensionString() {
+ *s_glExtensions = "GL_OES_EGL_image GL_OES_depth24 GL_OES_depth32 GL_OES_element_index_uint "
+ "GL_OES_standard_derivatives GL_OES_texture_float GL_OES_texture_float_linear ";
+ if (s_glSupport.GL_ARB_HALF_FLOAT_PIXEL || s_glSupport.GL_NV_HALF_FLOAT)
+ *s_glExtensions+="GL_OES_texture_half_float GL_OES_texture_half_float_linear ";
+ if (s_glSupport.GL_NV_PACKED_DEPTH_STENCIL)
+ *s_glExtensions+="GL_OES_packed_depth_stencil ";
+ if (s_glSupport.GL_ARB_HALF_FLOAT_VERTEX)
+ *s_glExtensions+="GL_OES_vertex_half_float ";
+}
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.h b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.h
index 36929ef..e0f9ba6 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.h
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.h
@@ -30,6 +30,7 @@
void convertArrs(GLESFloatArrays& fArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices,bool direct);
private:
void sendArr(GLvoid* arr,GLenum arrayType,GLint size,GLsizei stride,int pointsIndex = -1);
+ void initExtensionString();
};
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 37c71af..09c7aa6 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
@@ -19,6 +19,7 @@
#define GL_APICALL __declspec(dllexport)
#endif
+#define GL_GLEXT_PROTOTYPES
#include <stdio.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
@@ -38,6 +39,12 @@
}
+/************************************** GLES EXTENSIONS *********************************************************/
+//extentions descriptor
+typedef std::map<std::string, __translatorMustCastToProperFunctionPointerType> ProcTableMap;
+ProcTableMap *s_glesExtensions = NULL;
+/****************************************************************************************************************/
+
static EGLiface* s_eglIface = NULL;
static GLESiface s_glesIface = {
createGLESContext:createGLESContext,
@@ -71,7 +78,25 @@
}
static __translatorMustCastToProperFunctionPointerType getProcAddress(const char* procName) {
- return NULL;
+ GET_CTX_RET(NULL)
+ ctx->getGlobalLock();
+ static bool proc_table_initialized = false;
+ if (!proc_table_initialized) {
+ proc_table_initialized = true;
+ if (!s_glesExtensions)
+ s_glesExtensions = new ProcTableMap();
+ else
+ s_glesExtensions->clear();
+ (*s_glesExtensions)["glEGLImageTargetTexture2DOES"] = (__translatorMustCastToProperFunctionPointerType)glEGLImageTargetTexture2DOES;
+ (*s_glesExtensions)["glEGLImageTargetRenderbufferStorageOES"]=(__translatorMustCastToProperFunctionPointerType)glEGLImageTargetRenderbufferStorageOES;
+ }
+ __translatorMustCastToProperFunctionPointerType ret=NULL;
+ ProcTableMap::iterator val = s_glesExtensions->find(procName);
+ if (val!=s_glesExtensions->end())
+ ret = val->second;
+ ctx->releaseGlobalLock();
+
+ return ret;
}
GL_APICALL GLESiface* __translator_getIfaces(EGLiface* eglIface){
@@ -808,7 +833,7 @@
GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer){
GET_CTX();
SET_ERROR_IF(pname != GL_VERTEX_ATTRIB_ARRAY_POINTER,GL_INVALID_ENUM);
-
+
const GLESpointer* p = ctx->getPointer(pname);
if(p) {
*pointer = const_cast<void *>( p->getBufferData());
@@ -1011,6 +1036,8 @@
texData->internalFormat = internalformat;
}
}
+ if (type==GL_HALF_FLOAT_OES)
+ type = GL_HALF_FLOAT_NV;
ctx->dispatcher().glTexImage2D(target,level,internalformat,width,height,border,format,type,pixels);
}
@@ -1042,6 +1069,8 @@
GLESv2Validate::pixelFrmt(ctx,format)&&
GLESv2Validate::pixelType(ctx,type)),GL_INVALID_ENUM);
SET_ERROR_IF(!GLESv2Validate::pixelOp(format,type),GL_INVALID_OPERATION);
+ if (type==GL_HALF_FLOAT_OES)
+ type = GL_HALF_FLOAT_NV;
ctx->dispatcher().glTexSubImage2D(target,level,xoffset,yoffset,width,height,format,type,pixels);
@@ -1194,6 +1223,8 @@
GL_APICALL void GL_APIENTRY glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr){
GET_CTX();
+ 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);
}
@@ -1202,3 +1233,37 @@
GET_CTX();
ctx->dispatcher().glViewport(x,y,width,height);
}
+
+GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image)
+{
+ GET_CTX();
+ SET_ERROR_IF(!GLESv2Validate::textureTargetLimited(target),GL_INVALID_ENUM);
+ EglImage *img = s_eglIface->eglAttachEGLImage((unsigned int)image);
+ if (img) {
+ // Create the texture object in the underlying EGL implementation,
+ // 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();
+ unsigned int oldGlobal = thrd->shareGroup->getGlobalName(TEXTURE, tex);
+ // Delete old texture object
+ if (oldGlobal) {
+ ctx->dispatcher().glDeleteTextures(1, &oldGlobal);
+ }
+ // 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();
+ SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION);
+ texData->sourceEGLImage = (unsigned int)image;
+ texData->eglImageDetach = s_eglIface->eglDetachEGLImage;
+ }
+ }
+}
+
+GL_APICALL void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image)
+{
+ GET_CTX()
+ //not supported by EGL
+ SET_ERROR_IF(false,GL_INVALID_OPERATION);
+}
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.cpp b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.cpp
index 6721d08..99ac331 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.cpp
@@ -86,7 +86,7 @@
break;
default: return false;
}
- return target == GL_GENERATE_MIPMAP_HINT;
+ return target == GL_GENERATE_MIPMAP_HINT || target == GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES;
}
bool GLESv2Validate::capability(GLenum cap){
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.h b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.h
index 0a27f79..353fc67 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.h
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.h
@@ -18,6 +18,7 @@
*/
#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
#include <GLcommon/GLESvalidate.h>
struct GLESv2Validate:public GLESvalidate{
diff --git a/tools/emulator/opengl/host/libs/Translator/GLcommon/GLEScontext.cpp b/tools/emulator/opengl/host/libs/Translator/GLcommon/GLEScontext.cpp
index 5b78294..0f1e7b8 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLcommon/GLEScontext.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/GLcommon/GLEScontext.cpp
@@ -397,6 +397,15 @@
if (strstr(cstring,"GL_OES_read_format ")!=NULL)
s_glSupport.GL_OES_READ_FORMAT = true;
+ if (strstr(cstring,"GL_ARB_half_float_pixel ")!=NULL)
+ s_glSupport.GL_ARB_HALF_FLOAT_PIXEL = true;
+
+ if (strstr(cstring,"GL_NV_half_float ")!=NULL)
+ s_glSupport.GL_NV_HALF_FLOAT = true;
+
+ if (strstr(cstring,"GL_ARB_half_float_vertex ")!=NULL)
+ s_glSupport.GL_ARB_HALF_FLOAT_VERTEX = true;
+
//init extension string
s_glExtensions = new std::string("");
}
diff --git a/tools/emulator/opengl/host/libs/Translator/GLcommon/GLESvalidate.cpp b/tools/emulator/opengl/host/libs/Translator/GLcommon/GLESvalidate.cpp
index 9d27910..2b487e9 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLcommon/GLESvalidate.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/GLcommon/GLESvalidate.cpp
@@ -1,6 +1,8 @@
#include<GLcommon/GLESvalidate.h>
#include<GLES/gl.h>
#include<GLES/glext.h>
+#include<GLES2/gl2.h>
+#include<GLES2/gl2ext.h>
bool GLESvalidate::textureEnum(GLenum e,unsigned int maxTex) {
@@ -8,15 +10,21 @@
}
bool GLESvalidate::pixelType(GLEScontext * ctx, GLenum type) {
- if (ctx && ctx->getCaps()->GL_NV_PACKED_DEPTH_STENCIL) {
- if (type == GL_UNSIGNED_INT_24_8_OES)
- return true;
- }
+ if ((ctx && ctx->getCaps()->GL_NV_PACKED_DEPTH_STENCIL) &&
+ (type == GL_UNSIGNED_INT_24_8_OES) )
+ return true;
+
+ if (ctx &&
+ (ctx->getCaps()->GL_ARB_HALF_FLOAT_PIXEL || ctx->getCaps()->GL_NV_HALF_FLOAT) &&
+ (type == GL_HALF_FLOAT_OES))
+ return true;
+
switch(type) {
case GL_UNSIGNED_BYTE:
case GL_UNSIGNED_SHORT_5_6_5:
case GL_UNSIGNED_SHORT_4_4_4_4:
case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_FLOAT:
return true;
}
return false;
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 aad88ad..10dd8c0 100644
--- a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h
+++ b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h
@@ -26,7 +26,9 @@
GLSupport():maxLights(0),maxVertexAttribs(0),maxClipPlane(0),maxTexUnits(0),maxTexSize(0) , \
GL_EXT_TEXTURE_FORMAT_BGRA8888(false), GL_EXT_FRAMEBUFFER_OBJECT(false), \
GL_ARB_VERTEX_BLEND(false), GL_ARB_MATRIX_PALETTE(false), \
- GL_NV_PACKED_DEPTH_STENCIL(false) , GL_OES_READ_FORMAT(false) {} ;
+ GL_NV_PACKED_DEPTH_STENCIL(false) , GL_OES_READ_FORMAT(false), \
+ GL_ARB_HALF_FLOAT_PIXEL(false), GL_NV_HALF_FLOAT(false), \
+ GL_ARB_HALF_FLOAT_VERTEX(false) {} ;
int maxLights;
int maxVertexAttribs;
int maxClipPlane;
@@ -38,6 +40,10 @@
bool GL_ARB_MATRIX_PALETTE;
bool GL_NV_PACKED_DEPTH_STENCIL;
bool GL_OES_READ_FORMAT;
+ bool GL_ARB_HALF_FLOAT_PIXEL;
+ bool GL_NV_HALF_FLOAT;
+ bool GL_ARB_HALF_FLOAT_VERTEX;
+
};
struct GLESFloatArrays
diff --git a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/gldefs.h b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/gldefs.h
index ea8578d..1cba3bf 100644
--- a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/gldefs.h
+++ b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/gldefs.h
@@ -23,3 +23,5 @@
#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002
#define GL_TRANSFORM_BIT 0x00001000
#define GL_INT 0x1404
+#define GL_HALF_FLOAT_NV 0x140B
+#define GL_HALF_FLOAT 0x140B
diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/glUtils.cpp b/tools/emulator/opengl/shared/OpenglCodecCommon/glUtils.cpp
index 4623bf8..f07e9ae 100644
--- a/tools/emulator/opengl/shared/OpenglCodecCommon/glUtils.cpp
+++ b/tools/emulator/opengl/shared/OpenglCodecCommon/glUtils.cpp
@@ -169,6 +169,7 @@
case GL_TEXTURE_2D:
case GL_TEXTURE_BINDING_2D:
case GL_TEXTURE_BINDING_CUBE_MAP:
+ case GL_TEXTURE_BINDING_EXTERNAL_OES:
case GL_TEXTURE_COORD_ARRAY:
case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING:
case GL_TEXTURE_COORD_ARRAY_SIZE:
@@ -244,6 +245,8 @@
case GL_MAX_FRAGMENT_UNIFORM_VECTORS:
case GL_MAX_RENDERBUFFER_SIZE:
case GL_MAX_TEXTURE_IMAGE_UNITS:
+ case GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES:
+ case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
s = 1;
break;
case GL_ALIASED_LINE_WIDTH_RANGE: