Android Patch
Kenneth Hurley
klhurley at graffitientertainment.com
Sun Apr 15 22:06:31 PDT 2012
This is a patch to embed a wrapper in Ice Cream Sandwich by replacing
the egl.cfg with pointer to the wrapper .so file
I did this while on contract with Sony Ericsson and wanted to contribute
this back
to the project so others may find it useful.
Regards,
Kenneth Hurley
-------------- next part --------------
commit 93d914422bd9fc1258603e806dd77a9089c38f6f
Author: Kenneth Hurley <klhurley at graffitientertainment.com>
Date: Thu Mar 29 16:52:09 2012 -0700
Wrappers to allow egl.cfg override on Android Devices
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 10ccc3a..a2db615 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -483,6 +483,9 @@ if (EGL_FOUND)
target_link_libraries (egltrace dl)
install (TARGETS egltrace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
+
+ add_subdirectory(gles-wrappers)
+
endif ()
##############################################################################
diff --git a/README.android b/README.android
index e5d401c..74483eb 100644
--- a/README.android
+++ b/README.android
@@ -2,7 +2,7 @@ Get standalone NDK
==================
$ANDROID_NDK/build/tools/make-standalone-toolchain.sh \
- --platform=android-9 \
+ --platform=android-14 \
--install-dir=/tmp/ndk
Get Android CMake
=================
@@ -28,8 +28,42 @@ cmake -DCMAKE_TOOLCHAIN_FILE=$ANDTOOLCHAIN \
-DEGL_FOUND=true \
-DOPENGL_INCLUDE_PATH=$ANDROID_NDK_TOOLCHAIN_ROOT/sysroot/usr/include ..
-Example
-=======
+Using the wrappers
+==================
+
+** You might have to
+ 1. adb root #root access
+ 2. adb remount #mount read/write file system.
+
+in egl_config/ there are two files.
+
+1. Modify to match the default files under /system/lib/egl
+2. Edit egl.cfg or adb push sample egl.cfg
+2. Edit the apitrace.cfg to tell wrappers which .so files were the original ones under /system/lib/egl
+3. Push libGLESv1_CM_apitrace.so, libGLESv2_apitrace.so, libEGL_apitrace, egl.cfg, apitrace.cfg, egltrace.so to /system/lib/egl
+
+Directory /system/lib/egl on device should look similar to this:
+
+-rw-rw-rw- root root 185 2012-03-05 20:25 apitrace.cfg
+-rw-rw-rw- root root 25 2012-03-05 20:26 egl.cfg
+-rw-rw-rw- root root 22160 2012-02-28 17:56 eglsubAndroid.so
+-rwxrwxrwx root root 3377328 2012-03-29 21:59 egltrace.so
+-rw-rw-rw- root root 109528 2012-02-28 17:54 libEGL_adreno200.so
+-rwxrwxrwx root root 11080 2012-03-29 21:59 libEGL_apitrace.so
+-rw-r--r-- root root 52264 2012-03-23 21:52 libEGL_emulation.so
+-rw-r--r-- root root 81512 2012-03-23 21:52 libGLES_android.so
+-rw-rw-rw- root root 192752 2012-02-28 17:57 libGLESv1_CM_adreno200.so
+-rwxrwxrwx root root 50012 2012-03-29 21:59 libGLESv1_CM_apitrace.so
+-rw-r--r-- root root 40564 2012-03-23 21:52 libGLESv1_CM_emulation.so
+-rw-rw-rw- root root 558864 2012-02-28 17:55 libGLESv2_adreno200.so
+-rwxrwxrwx root root 39699 2012-03-29 21:59 libGLESv2_apitrace.so
+-rw-r--r-- root root 31784 2012-03-23 21:52 libGLESv2_emulation.so
+-rw-r--r-- root root 362944 2012-03-23 21:52 libq3dtools_adreno200.so
+
+When you execute an OpenGL program, it should apitrace it now.
+
+LD Preload Example
+==================
adb push ../libs/armeabi-v7a/egltrace.so /data/local/tmp
adb shell
diff --git a/egl_config/apitrace.cfg b/egl_config/apitrace.cfg
new file mode 100644
index 0000000..2e99ac0
--- /dev/null
+++ b/egl_config/apitrace.cfg
@@ -0,0 +1,5 @@
+egltrace /system/lib/egl/egltrace.so
+libEGL /system/lib/egl/libEGL_adreno200.so
+libGLESv1_CM /system/lib/egl/libGLESv1_CM_adreno200.so
+libGLESv2 /system/lib/egl/libGLESv2_adreno200.so
+
diff --git a/egl_config/egl.cfg b/egl_config/egl.cfg
new file mode 100644
index 0000000..1bf431f
--- /dev/null
+++ b/egl_config/egl.cfg
@@ -0,0 +1,2 @@
+0 0 android
+0 1 apitrace
diff --git a/gles-wrappers/CMakeLists.txt b/gles-wrappers/CMakeLists.txt
new file mode 100644
index 0000000..b407216
--- /dev/null
+++ b/gles-wrappers/CMakeLists.txt
@@ -0,0 +1,72 @@
+ add_library (GLESv2_apitrace SHARED
+ wrapper.c
+ gl2_entries.in
+ gl2ext_entries.in
+ )
+
+ set_property (
+ TARGET GLESv2_apitrace
+ APPEND
+ PROPERTY COMPILE_DEFINITIONS GL2_WRAPPER
+ )
+
+ set_target_properties (GLESv2_apitrace PROPERTIES
+ LINK_FLAGS "-Wl,-Bsymbolic -Wl,-Bsymbolic-functions"
+ # Prevent symbol relocations internal to our wrapper library to be
+ # overwritten by the application.
+ RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
+ LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
+ )
+
+ target_link_libraries (GLESv2_apitrace)
+
+ install (TARGETS GLESv2_apitrace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
+
+ add_library (EGL_apitrace SHARED
+ wrapper.c
+ egl_entries.in
+ )
+
+ set_property (
+ TARGET EGL_apitrace
+ APPEND
+ PROPERTY COMPILE_DEFINITIONS EGL_WRAPPER
+ )
+
+ set_target_properties (EGL_apitrace PROPERTIES
+ LINK_FLAGS "-Wl,-Bsymbolic -Wl,-Bsymbolic-functions"
+ # Prevent symbol relocations internal to our wrapper library to be
+ # overwritten by the application.
+ RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
+ LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
+ )
+
+ target_link_libraries (EGL_apitrace)
+
+ install (TARGETS EGL_apitrace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
+
+ add_library (GLESv1_CM_apitrace SHARED
+ wrapper.c
+ gl_entries.in
+ glext_entries.in
+ )
+
+ set_property (
+ TARGET GLESv1_CM_apitrace
+ APPEND
+ PROPERTY COMPILE_DEFINITIONS GL_WRAPPER
+ )
+
+ set_target_properties (GLESv1_CM_apitrace PROPERTIES
+ LINK_FLAGS "-Wl,-Bsymbolic -Wl,-Bsymbolic-functions"
+ # Prevent symbol relocations internal to our wrapper library to be
+ # overwritten by the application.
+ RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
+ LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
+ )
+
+ target_link_libraries (GLESv1_CM_apitrace)
+
+ install (TARGETS GLESv1_CM_apitrace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
+
+
diff --git a/gles-wrappers/egl_entries.in b/gles-wrappers/egl_entries.in
new file mode 100644
index 0000000..0cb3e6b
--- /dev/null
+++ b/gles-wrappers/egl_entries.in
@@ -0,0 +1,57 @@
+API_ENTRY(eglGetDisplay)
+API_ENTRY(eglInitialize)
+API_ENTRY(eglTerminate)
+API_ENTRY(eglGetConfigs)
+API_ENTRY(eglChooseConfig)
+
+API_ENTRY(eglGetConfigAttrib)
+API_ENTRY(eglCreateWindowSurface)
+API_ENTRY(eglCreatePixmapSurface)
+API_ENTRY(eglCreatePbufferSurface)
+API_ENTRY(eglDestroySurface)
+API_ENTRY(eglQuerySurface)
+API_ENTRY(eglCreateContext)
+API_ENTRY(eglDestroyContext)
+API_ENTRY(eglMakeCurrent)
+API_ENTRY(eglGetCurrentContext)
+API_ENTRY(eglGetCurrentSurface)
+API_ENTRY(eglGetCurrentDisplay)
+API_ENTRY(eglQueryContext)
+API_ENTRY(eglWaitGL)
+API_ENTRY(eglWaitNative)
+API_ENTRY(eglSwapBuffers)
+API_ENTRY(eglCopyBuffers)
+API_ENTRY(eglGetError)
+API_ENTRY(eglQueryString)
+API_ENTRY(eglGetProcAddress)
+
+/* EGL 1.1 */
+
+API_ENTRY(eglSurfaceAttrib)
+API_ENTRY(eglBindTexImage)
+API_ENTRY(eglReleaseTexImage)
+API_ENTRY(eglSwapInterval)
+
+/* EGL 1.2 */
+
+API_ENTRY(eglBindAPI)
+API_ENTRY(eglQueryAPI)
+API_ENTRY(eglWaitClient)
+API_ENTRY(eglReleaseThread)
+API_ENTRY(eglCreatePbufferFromClientBuffer)
+
+/* EGL 1.3 */
+
+/* EGL 1.4 */
+
+/* EGL_EGLEXT_VERSION 3 */
+
+API_ENTRY( eglLockSurfaceKHR)
+API_ENTRY( eglUnlockSurfaceKHR)
+API_ENTRY(eglCreateImageKHR)
+API_ENTRY( eglDestroyImageKHR)
+
+/* ANDROID extensions */
+
+API_ENTRY(eglSetSwapRectangleANDROID)
+API_ENTRY(eglGetRenderBufferANDROID)
diff --git a/gles-wrappers/gl2_entries.in b/gles-wrappers/gl2_entries.in
new file mode 100644
index 0000000..aac65c4
--- /dev/null
+++ b/gles-wrappers/gl2_entries.in
@@ -0,0 +1,143 @@
+API_ENTRY(glActiveTexture)
+API_ENTRY(glAttachShader)
+API_ENTRY(glBindAttribLocation)
+API_ENTRY(glBindBuffer)
+API_ENTRY(glBindFramebuffer)
+API_ENTRY(glBindRenderbuffer)
+API_ENTRY(glBindTexture)
+API_ENTRY(glBlendColor)
+API_ENTRY(glBlendEquation)
+API_ENTRY(glBlendEquationSeparate)
+API_ENTRY(glBlendFunc)
+API_ENTRY(glBlendFuncSeparate)
+API_ENTRY(glBufferData)
+API_ENTRY(glBufferSubData)
+API_ENTRY(glCheckFramebufferStatus)
+API_ENTRY(glClear)
+API_ENTRY(glClearColor)
+API_ENTRY(glClearDepthf)
+API_ENTRY(glClearStencil)
+API_ENTRY(glColorMask)
+API_ENTRY(glCompileShader)
+API_ENTRY(glCompressedTexImage2D)
+API_ENTRY(glCompressedTexSubImage2D)
+API_ENTRY(glCopyTexImage2D)
+API_ENTRY(glCopyTexSubImage2D)
+API_ENTRY(glCreateProgram)
+API_ENTRY(glCreateShader)
+API_ENTRY(glCullFace)
+API_ENTRY(glDeleteBuffers)
+API_ENTRY(glDeleteFramebuffers)
+API_ENTRY(glDeleteProgram)
+API_ENTRY(glDeleteRenderbuffers)
+API_ENTRY(glDeleteShader)
+API_ENTRY(glDeleteTextures)
+API_ENTRY(glDepthFunc)
+API_ENTRY(glDepthMask)
+API_ENTRY(glDepthRangef)
+API_ENTRY(glDetachShader)
+API_ENTRY(glDisable)
+API_ENTRY(glDisableVertexAttribArray)
+API_ENTRY(glDrawArrays)
+API_ENTRY(glDrawElements)
+API_ENTRY(glEnable)
+API_ENTRY(glEnableVertexAttribArray)
+API_ENTRY(glFinish)
+API_ENTRY(glFlush)
+API_ENTRY(glFramebufferRenderbuffer)
+API_ENTRY(glFramebufferTexture2D)
+API_ENTRY(glFrontFace)
+API_ENTRY(glGenBuffers)
+API_ENTRY(glGenerateMipmap)
+API_ENTRY(glGenFramebuffers)
+API_ENTRY(glGenRenderbuffers)
+API_ENTRY(glGenTextures)
+API_ENTRY(glGetActiveAttrib)
+API_ENTRY(glGetActiveUniform)
+API_ENTRY(glGetAttachedShaders)
+API_ENTRY(glGetAttribLocation)
+API_ENTRY(glGetBooleanv)
+API_ENTRY(glGetBufferParameteriv)
+API_ENTRY(glGetError)
+API_ENTRY(glGetFloatv)
+API_ENTRY(glGetFramebufferAttachmentParameteriv)
+API_ENTRY(glGetIntegerv)
+API_ENTRY(glGetProgramiv)
+API_ENTRY(glGetProgramInfoLog)
+API_ENTRY(glGetRenderbufferParameteriv)
+API_ENTRY(glGetShaderiv)
+API_ENTRY(glGetShaderInfoLog)
+API_ENTRY(glGetShaderPrecisionFormat)
+API_ENTRY(glGetShaderSource)
+API_ENTRY(glGetString)
+API_ENTRY(glGetTexParameterfv)
+API_ENTRY(glGetTexParameteriv)
+API_ENTRY(glGetUniformfv)
+API_ENTRY(glGetUniformiv)
+API_ENTRY(glGetUniformLocation)
+API_ENTRY(glGetVertexAttribfv)
+API_ENTRY(glGetVertexAttribiv)
+API_ENTRY(glGetVertexAttribPointerv)
+API_ENTRY(glHint)
+API_ENTRY(glIsBuffer)
+API_ENTRY(glIsEnabled)
+API_ENTRY(glIsFramebuffer)
+API_ENTRY(glIsProgram)
+API_ENTRY(glIsRenderbuffer)
+API_ENTRY(glIsShader)
+API_ENTRY(glIsTexture)
+API_ENTRY(glLineWidth)
+API_ENTRY(glLinkProgram)
+API_ENTRY(glPixelStorei)
+API_ENTRY(glPolygonOffset)
+API_ENTRY(glReadPixels)
+API_ENTRY(glReleaseShaderCompiler)
+API_ENTRY(glRenderbufferStorage)
+API_ENTRY(glSampleCoverage)
+API_ENTRY(glScissor)
+API_ENTRY(glShaderBinary)
+API_ENTRY(glShaderSource)
+API_ENTRY(glStencilFunc)
+API_ENTRY(glStencilFuncSeparate)
+API_ENTRY(glStencilMask)
+API_ENTRY(glStencilMaskSeparate)
+API_ENTRY(glStencilOp)
+API_ENTRY(glStencilOpSeparate)
+API_ENTRY(glTexImage2D)
+API_ENTRY(glTexParameterf)
+API_ENTRY(glTexParameterfv)
+API_ENTRY(glTexParameteri)
+API_ENTRY(glTexParameteriv)
+API_ENTRY(glTexSubImage2D)
+API_ENTRY(glUniform1f)
+API_ENTRY(glUniform1fv)
+API_ENTRY(glUniform1i)
+API_ENTRY(glUniform1iv)
+API_ENTRY(glUniform2f)
+API_ENTRY(glUniform2fv)
+API_ENTRY(glUniform2i)
+API_ENTRY(glUniform2iv)
+API_ENTRY(glUniform3f)
+API_ENTRY(glUniform3fv)
+API_ENTRY(glUniform3i)
+API_ENTRY(glUniform3iv)
+API_ENTRY(glUniform4f)
+API_ENTRY(glUniform4fv)
+API_ENTRY(glUniform4i)
+API_ENTRY(glUniform4iv)
+API_ENTRY(glUniformMatrix2fv)
+API_ENTRY(glUniformMatrix3fv)
+API_ENTRY(glUniformMatrix4fv)
+API_ENTRY(glUseProgram)
+API_ENTRY(glValidateProgram)
+API_ENTRY(glVertexAttrib1f)
+API_ENTRY(glVertexAttrib1fv)
+API_ENTRY(glVertexAttrib2f)
+API_ENTRY(glVertexAttrib2fv)
+API_ENTRY(glVertexAttrib3f)
+API_ENTRY(glVertexAttrib3fv)
+API_ENTRY(glVertexAttrib4f)
+API_ENTRY(glVertexAttrib4fv)
+API_ENTRY(glVertexAttribPointer)
+API_ENTRY(glViewport)
+
diff --git a/gles-wrappers/gl2ext_entries.in b/gles-wrappers/gl2ext_entries.in
new file mode 100644
index 0000000..5563ecb
--- /dev/null
+++ b/gles-wrappers/gl2ext_entries.in
@@ -0,0 +1,60 @@
+API_ENTRY(__glEGLImageTargetTexture2DOES)
+API_ENTRY(__glEGLImageTargetRenderbufferStorageOES)
+API_ENTRY(glGetProgramBinaryOES)
+API_ENTRY(glProgramBinaryOES)
+API_ENTRY(glMapBufferOES)
+API_ENTRY(glUnmapBufferOES)
+API_ENTRY(glGetBufferPointervOES)
+API_ENTRY(glTexImage3DOES)
+API_ENTRY(glTexSubImage3DOES)
+API_ENTRY(glCopyTexSubImage3DOES)
+API_ENTRY(glCompressedTexImage3DOES)
+API_ENTRY(glCompressedTexSubImage3DOES)
+API_ENTRY(glFramebufferTexture3DOES)
+API_ENTRY(glBindVertexArrayOES)
+API_ENTRY(glDeleteVertexArraysOES)
+API_ENTRY(glGenVertexArraysOES)
+API_ENTRY(glIsVertexArrayOES)
+API_ENTRY(glGetPerfMonitorGroupsAMD)
+API_ENTRY(glGetPerfMonitorCountersAMD)
+API_ENTRY(glGetPerfMonitorGroupStringAMD)
+API_ENTRY(glGetPerfMonitorCounterStringAMD)
+API_ENTRY(glGetPerfMonitorCounterInfoAMD)
+API_ENTRY(glGenPerfMonitorsAMD)
+API_ENTRY(glDeletePerfMonitorsAMD)
+API_ENTRY(glSelectPerfMonitorCountersAMD)
+API_ENTRY(glBeginPerfMonitorAMD)
+API_ENTRY(glEndPerfMonitorAMD)
+API_ENTRY(glGetPerfMonitorCounterDataAMD)
+API_ENTRY(glDiscardFramebufferEXT)
+API_ENTRY(glMultiDrawArraysEXT)
+API_ENTRY(glMultiDrawElementsEXT)
+API_ENTRY(glRenderbufferStorageMultisampleIMG)
+API_ENTRY(glFramebufferTexture2DMultisampleIMG)
+API_ENTRY(glDeleteFencesNV)
+API_ENTRY(glGenFencesNV)
+API_ENTRY(glIsFenceNV)
+API_ENTRY(glTestFenceNV)
+API_ENTRY(glGetFenceivNV)
+API_ENTRY(glFinishFenceNV)
+API_ENTRY(glSetFenceNV)
+API_ENTRY(glCoverageMaskNV)
+API_ENTRY(glCoverageOperationNV)
+API_ENTRY(glGetDriverControlsQCOM)
+API_ENTRY(glGetDriverControlStringQCOM)
+API_ENTRY(glEnableDriverControlQCOM)
+API_ENTRY(glDisableDriverControlQCOM)
+API_ENTRY(glExtGetTexturesQCOM)
+API_ENTRY(glExtGetBuffersQCOM)
+API_ENTRY(glExtGetRenderbuffersQCOM)
+API_ENTRY(glExtGetFramebuffersQCOM)
+API_ENTRY(glExtGetTexLevelParameterivQCOM)
+API_ENTRY(glExtTexObjectStateOverrideiQCOM)
+API_ENTRY(glExtGetTexSubImageQCOM)
+API_ENTRY(glExtGetBufferPointervQCOM)
+API_ENTRY(glExtGetShadersQCOM)
+API_ENTRY(glExtGetProgramsQCOM)
+API_ENTRY(glExtIsProgramBinaryQCOM)
+API_ENTRY(glExtGetProgramBinarySourceQCOM)
+API_ENTRY(glStartTilingQCOM)
+API_ENTRY(glEndTilingQCOM)
diff --git a/gles-wrappers/gl_entries.in b/gles-wrappers/gl_entries.in
new file mode 100644
index 0000000..b6444ad
--- /dev/null
+++ b/gles-wrappers/gl_entries.in
@@ -0,0 +1,145 @@
+API_ENTRY(glAlphaFunc)
+API_ENTRY(glClearColor)
+API_ENTRY(glClearDepthf)
+API_ENTRY(glClipPlanef)
+API_ENTRY(glColor4f)
+API_ENTRY(glDepthRangef)
+API_ENTRY(glFogf)
+API_ENTRY(glFogfv)
+API_ENTRY(glFrustumf)
+API_ENTRY(glGetClipPlanef)
+API_ENTRY(glGetFloatv)
+API_ENTRY(glGetLightfv)
+API_ENTRY(glGetMaterialfv)
+API_ENTRY(glGetTexEnvfv)
+API_ENTRY(glGetTexParameterfv)
+API_ENTRY(glLightModelf)
+API_ENTRY(glLightModelfv)
+API_ENTRY(glLightf)
+API_ENTRY(glLightfv)
+API_ENTRY(glLineWidth)
+API_ENTRY(glLoadMatrixf)
+API_ENTRY(glMaterialf)
+API_ENTRY(glMaterialfv)
+API_ENTRY(glMultMatrixf)
+API_ENTRY(glMultiTexCoord4f)
+API_ENTRY(glNormal3f)
+API_ENTRY(glOrthof)
+API_ENTRY(glPointParameterf)
+API_ENTRY(glPointParameterfv)
+API_ENTRY(glPointSize)
+API_ENTRY(glPolygonOffset)
+API_ENTRY(glRotatef)
+API_ENTRY(glScalef)
+API_ENTRY(glTexEnvf)
+API_ENTRY(glTexEnvfv)
+API_ENTRY(glTexParameterf)
+API_ENTRY(glTexParameterfv)
+API_ENTRY(glTranslatef)
+API_ENTRY(glActiveTexture)
+API_ENTRY(glAlphaFuncx)
+API_ENTRY(glBindBuffer)
+API_ENTRY(glBindTexture)
+API_ENTRY(glBlendFunc)
+API_ENTRY(glBufferData)
+API_ENTRY(glBufferSubData)
+API_ENTRY(glClear)
+API_ENTRY(glClearColorx)
+API_ENTRY(glClearDepthx)
+API_ENTRY(glClearStencil)
+API_ENTRY(glClientActiveTexture)
+API_ENTRY(glClipPlanex)
+API_ENTRY(glColor4ub)
+API_ENTRY(glColor4x)
+API_ENTRY(glColorMask)
+API_ENTRY(glColorPointer)
+API_ENTRY(glCompressedTexImage2D)
+API_ENTRY(glCompressedTexSubImage2D)
+API_ENTRY(glCopyTexImage2D)
+API_ENTRY(glCopyTexSubImage2D)
+API_ENTRY(glCullFace)
+API_ENTRY(glDeleteBuffers)
+API_ENTRY(glDeleteTextures)
+API_ENTRY(glDepthFunc)
+API_ENTRY(glDepthMask)
+API_ENTRY(glDepthRangex)
+API_ENTRY(glDisable)
+API_ENTRY(glDisableClientState)
+API_ENTRY(glDrawArrays)
+API_ENTRY(glDrawElements)
+API_ENTRY(glEnable)
+API_ENTRY(glEnableClientState)
+API_ENTRY(glFinish)
+API_ENTRY(glFlush)
+API_ENTRY(glFogx)
+API_ENTRY(glFogxv)
+API_ENTRY(glFrontFace)
+API_ENTRY(glFrustumx)
+API_ENTRY(glGetBooleanv)
+API_ENTRY(glGetBufferParameteriv)
+API_ENTRY(glGetClipPlanex)
+API_ENTRY(glGenBuffers)
+API_ENTRY(glGenTextures)
+API_ENTRY(glGetError)
+API_ENTRY(glGetFixedv)
+API_ENTRY(glGetIntegerv)
+API_ENTRY(glGetLightxv)
+API_ENTRY(glGetMaterialxv)
+API_ENTRY(glGetPointerv)
+API_ENTRY(glGetString)
+API_ENTRY(glGetTexEnviv)
+API_ENTRY(glGetTexEnvxv)
+API_ENTRY(glGetTexParameteriv)
+API_ENTRY(glGetTexParameterxv)
+API_ENTRY(glHint)
+API_ENTRY(glIsBuffer)
+API_ENTRY(glIsEnabled)
+API_ENTRY(glIsTexture)
+API_ENTRY(glLightModelx)
+API_ENTRY(glLightModelxv)
+API_ENTRY(glLightx)
+API_ENTRY(glLightxv)
+API_ENTRY(glLineWidthx)
+API_ENTRY(glLoadIdentity)
+API_ENTRY(glLoadMatrixx)
+API_ENTRY(glLogicOp)
+API_ENTRY(glMaterialx)
+API_ENTRY(glMaterialxv)
+API_ENTRY(glMatrixMode)
+API_ENTRY(glMultMatrixx)
+API_ENTRY(glMultiTexCoord4x)
+API_ENTRY(glNormal3x)
+API_ENTRY(glNormalPointer)
+API_ENTRY(glOrthox)
+API_ENTRY(glPixelStorei)
+API_ENTRY(glPointParameterx)
+API_ENTRY(glPointParameterxv)
+API_ENTRY(glPointSizex)
+API_ENTRY(glPolygonOffsetx)
+API_ENTRY(glPopMatrix)
+API_ENTRY(glPushMatrix)
+API_ENTRY(glReadPixels)
+API_ENTRY(glRotatex)
+API_ENTRY(glSampleCoverage)
+API_ENTRY(glSampleCoveragex)
+API_ENTRY(glScalex)
+API_ENTRY(glScissor)
+API_ENTRY(glShadeModel)
+API_ENTRY(glStencilFunc)
+API_ENTRY(glStencilMask)
+API_ENTRY(glStencilOp)
+API_ENTRY(glTexCoordPointer)
+API_ENTRY(glTexEnvi)
+API_ENTRY(glTexEnvx)
+API_ENTRY(glTexEnviv)
+API_ENTRY(glTexEnvxv)
+API_ENTRY(glTexImage2D)
+API_ENTRY(glTexParameteri)
+API_ENTRY(glTexParameterx)
+API_ENTRY(glTexParameteriv)
+API_ENTRY(glTexParameterxv)
+API_ENTRY(glTexSubImage2D)
+API_ENTRY(glTranslatex)
+API_ENTRY(glVertexPointer)
+API_ENTRY(glViewport)
+
diff --git a/gles-wrappers/glext_entries.in b/gles-wrappers/glext_entries.in
new file mode 100644
index 0000000..f2acda2
--- /dev/null
+++ b/gles-wrappers/glext_entries.in
@@ -0,0 +1,126 @@
+API_ENTRY(glBlendEquationSeparateOES)
+API_ENTRY(glBlendFuncSeparateOES)
+API_ENTRY(glBlendEquationOES)
+API_ENTRY(glDrawTexsOES)
+API_ENTRY(glDrawTexiOES)
+API_ENTRY(glDrawTexxOES)
+API_ENTRY(glDrawTexsvOES)
+API_ENTRY(glDrawTexivOES)
+API_ENTRY(glDrawTexxvOES)
+API_ENTRY(glDrawTexfOES)
+API_ENTRY(glDrawTexfvOES)
+API_ENTRY(__glEGLImageTargetTexture2DOES)
+API_ENTRY(__glEGLImageTargetRenderbufferStorageOES)
+API_ENTRY(glAlphaFuncxOES)
+API_ENTRY(glClearColorxOES)
+API_ENTRY(glClearDepthxOES)
+API_ENTRY(glClipPlanexOES)
+API_ENTRY(glColor4xOES)
+API_ENTRY(glDepthRangexOES)
+API_ENTRY(glFogxOES)
+API_ENTRY(glFogxvOES)
+API_ENTRY(glFrustumxOES)
+API_ENTRY(glGetClipPlanexOES)
+API_ENTRY(glGetFixedvOES)
+API_ENTRY(glGetLightxvOES)
+API_ENTRY(glGetMaterialxvOES)
+API_ENTRY(glGetTexEnvxvOES)
+API_ENTRY(glGetTexParameterxvOES)
+API_ENTRY(glLightModelxOES)
+API_ENTRY(glLightModelxvOES)
+API_ENTRY(glLightxOES)
+API_ENTRY(glLightxvOES)
+API_ENTRY(glLineWidthxOES)
+API_ENTRY(glLoadMatrixxOES)
+API_ENTRY(glMaterialxOES)
+API_ENTRY(glMaterialxvOES)
+API_ENTRY(glMultMatrixxOES)
+API_ENTRY(glMultiTexCoord4xOES)
+API_ENTRY(glNormal3xOES)
+API_ENTRY(glOrthoxOES)
+API_ENTRY(glPointParameterxOES)
+API_ENTRY(glPointParameterxvOES)
+API_ENTRY(glPointSizexOES)
+API_ENTRY(glPolygonOffsetxOES)
+API_ENTRY(glRotatexOES)
+API_ENTRY(glSampleCoveragexOES)
+API_ENTRY(glScalexOES)
+API_ENTRY(glTexEnvxOES)
+API_ENTRY(glTexEnvxvOES)
+API_ENTRY(glTexParameterxOES)
+API_ENTRY(glTexParameterxvOES)
+API_ENTRY(glTranslatexOES)
+API_ENTRY(glIsRenderbufferOES)
+API_ENTRY(glBindRenderbufferOES)
+API_ENTRY(glDeleteRenderbuffersOES)
+API_ENTRY(glGenRenderbuffersOES)
+API_ENTRY(glRenderbufferStorageOES)
+API_ENTRY(glGetRenderbufferParameterivOES)
+API_ENTRY(glIsFramebufferOES)
+API_ENTRY(glBindFramebufferOES)
+API_ENTRY(glDeleteFramebuffersOES)
+API_ENTRY(glGenFramebuffersOES)
+API_ENTRY(glCheckFramebufferStatusOES)
+API_ENTRY(glFramebufferRenderbufferOES)
+API_ENTRY(glFramebufferTexture2DOES)
+API_ENTRY(glGetFramebufferAttachmentParameterivOES)
+API_ENTRY(glGenerateMipmapOES)
+API_ENTRY(glMapBufferOES)
+API_ENTRY(glUnmapBufferOES)
+API_ENTRY(glGetBufferPointervOES)
+API_ENTRY(glCurrentPaletteMatrixOES)
+API_ENTRY(glLoadPaletteFromModelViewMatrixOES)
+API_ENTRY(glMatrixIndexPointerOES)
+API_ENTRY(glWeightPointerOES)
+API_ENTRY(glQueryMatrixxOES)
+API_ENTRY(glDepthRangefOES)
+API_ENTRY(glFrustumfOES)
+API_ENTRY(glOrthofOES)
+API_ENTRY(glClipPlanefOES)
+API_ENTRY(glGetClipPlanefOES)
+API_ENTRY(glClearDepthfOES)
+API_ENTRY(glTexGenfOES)
+API_ENTRY(glTexGenfvOES)
+API_ENTRY(glTexGeniOES)
+API_ENTRY(glTexGenivOES)
+API_ENTRY(glTexGenxOES)
+API_ENTRY(glTexGenxvOES)
+API_ENTRY(glGetTexGenfvOES)
+API_ENTRY(glGetTexGenivOES)
+API_ENTRY(glGetTexGenxvOES)
+API_ENTRY(glBindVertexArrayOES)
+API_ENTRY(glDeleteVertexArraysOES)
+API_ENTRY(glGenVertexArraysOES)
+API_ENTRY(glIsVertexArrayOES)
+API_ENTRY(glDiscardFramebufferEXT)
+API_ENTRY(glMultiDrawArraysEXT)
+API_ENTRY(glMultiDrawElementsEXT)
+API_ENTRY(glClipPlanefIMG)
+API_ENTRY(glClipPlanexIMG)
+API_ENTRY(glRenderbufferStorageMultisampleIMG)
+API_ENTRY(glFramebufferTexture2DMultisampleIMG)
+API_ENTRY(glDeleteFencesNV)
+API_ENTRY(glGenFencesNV)
+API_ENTRY(glIsFenceNV)
+API_ENTRY(glTestFenceNV)
+API_ENTRY(glGetFenceivNV)
+API_ENTRY(glFinishFenceNV)
+API_ENTRY(glSetFenceNV)
+API_ENTRY(glGetDriverControlsQCOM)
+API_ENTRY(glGetDriverControlStringQCOM)
+API_ENTRY(glEnableDriverControlQCOM)
+API_ENTRY(glDisableDriverControlQCOM)
+API_ENTRY(glExtGetTexturesQCOM)
+API_ENTRY(glExtGetBuffersQCOM)
+API_ENTRY(glExtGetRenderbuffersQCOM)
+API_ENTRY(glExtGetFramebuffersQCOM)
+API_ENTRY(glExtGetTexLevelParameterivQCOM)
+API_ENTRY(glExtTexObjectStateOverrideiQCOM)
+API_ENTRY(glExtGetTexSubImageQCOM)
+API_ENTRY(glExtGetBufferPointervQCOM)
+API_ENTRY(glExtGetShadersQCOM)
+API_ENTRY(glExtGetProgramsQCOM)
+API_ENTRY(glExtIsProgramBinaryQCOM)
+API_ENTRY(glExtGetProgramBinarySourceQCOM)
+API_ENTRY(glStartTilingQCOM)
+API_ENTRY(glEndTilingQCOM)
diff --git a/gles-wrappers/wrapper.c b/gles-wrappers/wrapper.c
new file mode 100644
index 0000000..0d110a8
--- /dev/null
+++ b/gles-wrappers/wrapper.c
@@ -0,0 +1,126 @@
+
+#include <stdio.h>
+#include <dlfcn.h>
+#include <stdbool.h>
+#include <string.h>
+
+#include <signal.h>
+
+static void *lib_handles[2] = { NULL, NULL };
+
+#if defined(EGL_WRAPPER)
+#define API_ENTRIES "egl_entries.in"
+ const char *sourceTags[2] = { "egltrace", "libEGL" };
+#elif defined(GL_WRAPPER)
+#define API_ENTRIES "gl_entries.in"
+#define API_ENTRIES_EXT "glext_entries.in"
+ const char *sourceTags[2] = { "egltrace", "libGLESv1_CM" };
+#elif defined(GL2_WRAPPER)
+#define API_ENTRIES "gl2_entries.in"
+#define API_ENTRIES_EXT "gl2ext_entries.in"
+ const char *sourceTags[2] = { "egltrace", "libGLESv2" };
+#endif
+
+
+#undef API_ENTRY
+#define API_ENTRY(_api) FUNC##_api,
+
+enum API_OFFSET {
+#include API_ENTRIES
+#ifdef API_ENTRIES_EXT
+ #include API_ENTRIES_EXT
+#endif
+ API_NUM
+};
+
+void LoadLibraries()
+{
+ char line[256];
+ char tag[256];
+ char wrappedLib[256];
+ int i;
+ FILE *cfg;
+
+ /* apitrace.cfg */
+ cfg = fopen("/system/lib/egl/apitrace.cfg", "r");
+ if (cfg != NULL) {
+ while (fgets(line, 256, cfg)) {
+ if (sscanf(line, "%s %s", tag, wrappedLib) == 2) {
+ for (i=0; i<2; i++) {
+ if (!strcasecmp(tag, sourceTags[i])) {
+ lib_handles[i] = dlopen(wrappedLib, RTLD_LOCAL|RTLD_NOW);
+ }
+ }
+ }
+ }
+ fclose(cfg);
+
+ }
+}
+
+static void *func_ptr[API_NUM];
+
+#undef API_ENTRY
+#define API_ENTRY(_api) \
+ func_ptr[FUNC##_api] = dlsym(lib_handles[0], #_api);
+
+
+void *find_symbol(int offset) {
+ if (lib_handles[0] == NULL ) {
+ LoadLibraries();
+ }
+
+ if (lib_handles[0] == NULL) {
+ printf("Unable to open %s to load and wrap.\n", sourceTags[0]);
+ }
+
+ if (lib_handles[1] == NULL) {
+ printf("Unable to open %s to load and wrap.\n", sourceTags[1]);
+ }
+
+
+ if ((lib_handles[0] != NULL) && (lib_handles[1] != NULL)) {
+
+#include API_ENTRIES
+#ifdef API_ENTRIES_EXT
+#include API_ENTRIES_EXT
+#endif
+ return func_ptr[offset];
+ }
+ else
+ {
+ raise(SIGINT);
+ }
+
+ return NULL;
+}
+
+
+#undef API_ENTRY
+#define API_ENTRY(_api) \
+ __attribute__((naked)) __attribute__((visibility("default"))) \
+ void _api() { \
+ asm volatile( \
+ "push {r0-r3,lr}\n" \
+ ); \
+ asm volatile( \
+ "movw r0, %[offset]\n" \
+ "bl find_symbol \n" \
+ "mov r12, r0 \n" \
+ "pop {r0-r3,lr} \n" \
+ "cmp r12, #0 \n" \
+ "IT NE \n" \
+ "bxne r12 \n" \
+ "mov r0, #0 \n" \
+ "bx lr \n" \
+ : \
+ : [offset] "i"(FUNC##_api) \
+ : "r0", "r1", "r2", "r3", "r12" \
+ ); \
+ }
+#include API_ENTRIES
+#ifdef API_ENTRIES_EXT
+#include API_ENTRIES_EXT
+#endif
+
+#undef API_ENTRY
More information about the apitrace
mailing list