Merge pull request #439 from morphis/f/emugl-generation

Add necessary infrastructure to easily regenerate EmuGL code
This commit is contained in:
Simon Fels 2017-08-31 16:48:17 +02:00 • committed by GitHub
commit 3cf7d60b81
27 changed files with 787 additions and 505 deletions

View file

@ -192,6 +192,7 @@ Interesting things to have a look at
* [Runtime Setup](docs/runtime-setup.md)
* [Build Android image](docs/build-android.md)
* [Generate Android emugl source](docs/generate-emugl-source.md)
## Reporting bugs

View file

@ -6,6 +6,8 @@
#include "gl_types.h"
#include "emugl/common/logging.h"
#ifndef gl_APIENTRY
#define gl_APIENTRY
#endif

View file

@ -6,6 +6,8 @@
#include "gl2_types.h"
#include "emugl/common/logging.h"
#ifndef gl2_APIENTRY
#define gl2_APIENTRY
#endif

View file

@ -7,6 +7,7 @@
#include "renderControl_types.h"
#include "emugl/common/logging.h"
#ifndef renderControl_APIENTRY
#define renderControl_APIENTRY
#endif

View file

@ -0,0 +1,16 @@
# Generate Android EmuGL source
Parts of the EmuGL layer are generated with a tool called emugen (see
external/android-emugl/host/tools/emugen).
To generate the source again after a modification simply call
```
$ scripts/update-emugl-sources.sh --emugen=<path to emugen>/emugen
```
The definition of the various attributes/types/functions can be found in
* external/android-emugl/host/libs/renderControl_dec
* external/android-emugl/host/libs/GLESv1_dec
* external/android-emugl/host/libs/GLESv2_dec

View file

@ -10,6 +10,7 @@ include_directories(
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/external/android-emugl/shared
${CMAKE_SOURCE_DIR}/external/android-emugl/host/include
${CMAKE_BINARY_DIR}/external/android-emugl/host/include
${CMAKE_SOURCE_DIR}/external/android-emugl/shared/OpenglCodecCommon
${CMAKE_SOURCE_DIR}/external/android-emugl/host/libs
${CMAKE_SOURCE_DIR}/external/android-emugl/host/include/libOpenglRender

View file

@ -1,15 +0,0 @@
// Auto-generated with: android/scripts/gen-entries.py --mode=functions distrib/android-emugl/host/libs/libOpenGLESDispatch/render_egl_extensions.entries --output=distrib/android-emugl/host/include/OpenGLESDispatch/RenderEGL_extensions_functions.h
// DO NOT EDIT THIS FILE
#ifndef RENDER_EGL_EXTENSIONS_FUNCTIONS_H
#define RENDER_EGL_EXTENSIONS_FUNCTIONS_H
#include <EGL/egl.h>
#define EGL_EGLEXT_PROTOTYPES
#include <EGL/eglext.h>
#define LIST_RENDER_EGL_EXTENSIONS_FUNCTIONS(X) \
X(EGLImageKHR, eglCreateImageKHR, (EGLDisplay display, EGLContext context, EGLenum target, EGLClientBuffer buffer, const EGLint* attrib_list)) \
X(EGLBoolean, eglDestroyImageKHR, (EGLDisplay display, EGLImageKHR image)) \
#endif // RENDER_EGL_EXTENSIONS_FUNCTIONS_H

View file

@ -1,31 +0,0 @@
// Auto-generated with: android/scripts/gen-entries.py --mode=functions distrib/android-emugl/host/libs/libOpenGLESDispatch/render_egl.entries --output=distrib/android-emugl/host/include/OpenGLESDispatch/RenderEGL_functions.h
// DO NOT EDIT THIS FILE
#ifndef RENDER_EGL_FUNCTIONS_H
#define RENDER_EGL_FUNCTIONS_H
#include <EGL/egl.h>
#define LIST_RENDER_EGL_FUNCTIONS(X) \
X(EGLint, eglGetError, ()) \
X(EGLDisplay, eglGetDisplay, (EGLNativeDisplayType dpy)) \
X(EGLBoolean, eglInitialize, (EGLDisplay dpy, EGLint* major, EGLint* minor)) \
X(char*, eglQueryString, (EGLDisplay dpy, EGLint id)) \
X(EGLBoolean, eglGetConfigs, (EGLDisplay display, EGLConfig* configs, EGLint config_size, EGLint* num_config)) \
X(EGLBoolean, eglChooseConfig, (EGLDisplay display, const EGLint* attribs, EGLConfig* configs, EGLint config_size, EGLint* num_config)) \
X(EGLBoolean, eglGetConfigAttrib, (EGLDisplay display, EGLConfig config, EGLint attribute, EGLint* value)) \
X(EGLSurface, eglCreateWindowSurface, (EGLDisplay display, EGLConfig config, EGLNativeWindowType native_window, const EGLint* attrib_list)) \
X(EGLSurface, eglCreatePbufferSurface, (EGLDisplay display, EGLConfig config, const EGLint* attrib_list)) \
X(EGLBoolean, eglDestroySurface, (EGLDisplay display, EGLSurface surface)) \
X(EGLBoolean, eglBindAPI, (EGLenum api)) \
X(EGLenum, eglQueryAPI, ()) \
X(EGLBoolean, eglReleaseThread, ()) \
X(EGLContext, eglCreateContext, (EGLDisplay display, EGLConfig config, EGLContext share_context, const EGLint* attrib_list)) \
X(EGLBoolean, eglDestroyContext, (EGLDisplay display, EGLContext context)) \
X(EGLBoolean, eglMakeCurrent, (EGLDisplay display, EGLSurface draw, EGLSurface read, EGLContext context)) \
X(EGLContext, eglGetCurrentContext, ()) \
X(EGLSurface, eglGetCurrentSurface, (EGLint readdraw)) \
X(EGLBoolean, eglSwapBuffers, (EGLDisplay display, EGLSurface surface)) \
X(void*, eglGetProcAddress, (const char* function_name)) \
#endif // RENDER_EGL_FUNCTIONS_H

View file

@ -1,27 +0,0 @@
// Auto-generated with: android/scripts/gen-entries.py --mode=funcargs distrib/android-emugl/host/libs/libOpenGLESDispatch/gles1_extensions.entries --output=distrib/android-emugl/host/include/OpenGLESDispatch/gles1_extensions_functions.h
// DO NOT EDIT THIS FILE
#ifndef GLES1_EXTENSIONS_FUNCTIONS_H
#define GLES1_EXTENSIONS_FUNCTIONS_H
#define LIST_GLES1_EXTENSIONS_FUNCTIONS(X) \
X(void, glCurrentPaletteMatrixARB, (GLint index), (index)) \
X(void, glMatrixIndexuivARB, (GLint size, GLuint * indices), (size, indices)) \
X(void, glMatrixIndexPointerARB, (GLint size, GLenum type, GLsizei stride, const GLvoid* pointer), (size, type, stride, pointer)) \
X(void, glWeightPointerARB, (GLint size, GLenum type, GLsizei stride, const GLvoid* pointer), (size, type, stride, pointer)) \
X(void, glTexGenf, (GLenum coord, GLenum pname, GLfloat param), (coord, pname, param)) \
X(void, glTexGeni, (GLenum coord, GLenum pname, GLint param), (coord, pname, param)) \
X(void, glTexGenfv, (GLenum coord, GLenum pname, const GLfloat * params), (coord, pname, params)) \
X(void, glTexGeniv, (GLenum coord, GLenum pname, const GLint * params), (coord, pname, params)) \
X(void, glGetTexGenfv, (GLenum coord, GLenum pname, GLfloat * params), (coord, pname, params)) \
X(void, glGetTexGeniv, (GLenum coord, GLenum pname, GLint * params), (coord, pname, params)) \
X(void, glDrawTexsOES, (GLshort x, GLshort y, GLshort z, GLshort width, GLshort height), (x, y, z, width, height)) \
X(void, glDrawTexiOES, (GLshort x, GLint y, GLint z, GLint width, GLshort height), (x, y, z, width, height)) \
X(void, glDrawTexfOES, (GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height), (x, y, z, width, height)) \
X(void, glDrawTexxOES, (GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height), (x, y, z, width, height)) \
X(void, glDrawTexsvOES, (const GLshort *coords), (coords)) \
X(void, glDrawTexivOES, (const GLint *coords), (coords)) \
X(void, glDrawTexxvOES, (const GLfixed *coords), (coords)) \
X(void, glDrawTexfvOES, (const GLfloat *coords), (coords)) \
#endif // GLES1_EXTENSIONS_FUNCTIONS_H

View file

@ -1,71 +0,0 @@
// Auto-generated with: android/scripts/gen-entries.py --mode=funcargs distrib/android-emugl/host/libs/libOpenGLESDispatch/gles1_only.entries --output=distrib/android-emugl/host/include/OpenGLESDispatch/gles1_only_functions.h
// DO NOT EDIT THIS FILE
#ifndef GLES1_ONLY_FUNCTIONS_H
#define GLES1_ONLY_FUNCTIONS_H
#define LIST_GLES1_ONLY_FUNCTIONS(X) \
X(void, glAlphaFunc, (GLenum func, GLclampf ref), (func, ref)) \
X(void, glBegin, (GLenum mode), (mode)) \
X(void, glClientActiveTexture, (GLenum texture), (texture)) \
X(void, glClipPlane, (GLenum plane, const GLdouble * equation), (plane, equation)) \
X(void, glColor4d, (GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha), (red, green, blue, alpha)) \
X(void, glColor4f, (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha), (red, green, blue, alpha)) \
X(void, glColor4fv, (const GLfloat * v), (v)) \
X(void, glColor4ub, (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha), (red, green, blue, alpha)) \
X(void, glColor4ubv, (const GLubyte * v), (v)) \
X(void, glColorPointer, (GLint size, GLenum type, GLsizei stride, const GLvoid * pointer), (size, type, stride, pointer)) \
X(void, glDisableClientState, (GLenum array), (array)) \
X(void, glEnableClientState, (GLenum array), (array)) \
X(void, glEnd, (), ()) \
X(void, glFogf, (GLenum pname, GLfloat param), (pname, param)) \
X(void, glFogfv, (GLenum pname, const GLfloat * params), (pname, params)) \
X(void, glFrustum, (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar), (left, right, bottom, top, zNear, zFar)) \
X(void, glGetClipPlane, (GLenum plane, GLdouble * equation), (plane, equation)) \
X(void, glGetDoublev, (GLenum pname, GLdouble * params), (pname, params)) \
X(void, glGetLightfv, (GLenum light, GLenum pname, GLfloat * params), (light, pname, params)) \
X(void, glGetMaterialfv, (GLenum face, GLenum pname, GLfloat * params), (face, pname, params)) \
X(void, glGetPointerv, (GLenum pname, GLvoid* * params), (pname, params)) \
X(void, glGetTexEnvfv, (GLenum target, GLenum pname, GLfloat * params), (target, pname, params)) \
X(void, glGetTexEnviv, (GLenum target, GLenum pname, GLint * params), (target, pname, params)) \
X(void, glLightf, (GLenum light, GLenum pname, GLfloat param), (light, pname, param)) \
X(void, glLightfv, (GLenum light, GLenum pname, const GLfloat * params), (light, pname, params)) \
X(void, glLightModelf, (GLenum pname, GLfloat param), (pname, param)) \
X(void, glLightModelfv, (GLenum pname, const GLfloat * params), (pname, params)) \
X(void, glLoadIdentity, (), ()) \
X(void, glLoadMatrixf, (const GLfloat * m), (m)) \
X(void, glLogicOp, (GLenum opcode), (opcode)) \
X(void, glMaterialf, (GLenum face, GLenum pname, GLfloat param), (face, pname, param)) \
X(void, glMaterialfv, (GLenum face, GLenum pname, const GLfloat * params), (face, pname, params)) \
X(void, glMultiTexCoord2fv, (GLenum target, const GLfloat * v), (target, v)) \
X(void, glMultiTexCoord2sv, (GLenum target, const GLshort * v), (target, v)) \
X(void, glMultiTexCoord3fv, (GLenum target, const GLfloat * v), (target, v)) \
X(void, glMultiTexCoord3sv, (GLenum target, const GLshort * v), (target, v)) \
X(void, glMultiTexCoord4f, (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q), (target, s, t, r, q)) \
X(void, glMultiTexCoord4fv, (GLenum target, const GLfloat * v), (target, v)) \
X(void, glMultiTexCoord4sv, (GLenum target, const GLshort * v), (target, v)) \
X(void, glMultMatrixf, (const GLfloat * m), (m)) \
X(void, glNormal3f, (GLfloat nx, GLfloat ny, GLfloat nz), (nx, ny, nz)) \
X(void, glNormal3fv, (const GLfloat * v), (v)) \
X(void, glNormal3sv, (const GLshort * v), (v)) \
X(void, glOrtho, (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar), (left, right, bottom, top, zNear, zFar)) \
X(void, glPointParameterf, (GLenum param, GLfloat value), (param, value)) \
X(void, glPointParameterfv, (GLenum param, const GLfloat * values), (param, values)) \
X(void, glPointSize, (GLfloat size), (size)) \
X(void, glRotatef, (GLfloat angle, GLfloat x, GLfloat y, GLfloat z), (angle, x, y, z)) \
X(void, glScalef, (GLfloat x, GLfloat y, GLfloat z), (x, y, z)) \
X(void, glTexEnvf, (GLenum target, GLenum pname, GLfloat param), (target, pname, param)) \
X(void, glTexEnvfv, (GLenum target, GLenum pname, const GLfloat * params), (target, pname, params)) \
X(void, glMatrixMode, (GLenum mode), (mode)) \
X(void, glNormalPointer, (GLenum type, GLsizei stride, const GLvoid * pointer), (type, stride, pointer)) \
X(void, glPopMatrix, (), ()) \
X(void, glPushMatrix, (), ()) \
X(void, glShadeModel, (GLenum mode), (mode)) \
X(void, glTexCoordPointer, (GLint size, GLenum type, GLsizei stride, const GLvoid * pointer), (size, type, stride, pointer)) \
X(void, glTexEnvi, (GLenum target, GLenum pname, GLint param), (target, pname, param)) \
X(void, glTexEnviv, (GLenum target, GLenum pname, const GLint * params), (target, pname, params)) \
X(void, glTranslatef, (GLfloat x, GLfloat y, GLfloat z), (x, y, z)) \
X(void, glVertexPointer, (GLint size, GLenum type, GLsizei stride, const GLvoid * pointer), (size, type, stride, pointer)) \
#endif // GLES1_ONLY_FUNCTIONS_H

View file

@ -1,13 +0,0 @@
// Auto-generated with: android/scripts/gen-entries.py --mode=funcargs distrib/android-emugl/host/libs/libOpenGLESDispatch/gles2_extensions.entries --output=distrib/android-emugl/host/include/OpenGLESDispatch/gles2_extensions_functions.h
// DO NOT EDIT THIS FILE
#ifndef GLES2_EXTENSIONS_FUNCTIONS_H
#define GLES2_EXTENSIONS_FUNCTIONS_H
#define LIST_GLES2_EXTENSIONS_FUNCTIONS(X) \
X(void, glGetShaderPrecisionFormat, (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision), (shadertype, precisiontype, range, precision)) \
X(void, glReleaseShaderCompiler, (), ()) \
X(void, glShaderBinary, (GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length), (n, shaders, binaryformat, binary, length)) \
#endif // GLES2_EXTENSIONS_FUNCTIONS_H

View file

@ -1,85 +0,0 @@
// Auto-generated with: android/scripts/gen-entries.py --mode=funcargs distrib/android-emugl/host/libs/libOpenGLESDispatch/gles2_only.entries --output=distrib/android-emugl/host/include/OpenGLESDispatch/gles2_only_functions.h
// DO NOT EDIT THIS FILE
#ifndef GLES2_ONLY_FUNCTIONS_H
#define GLES2_ONLY_FUNCTIONS_H
#define LIST_GLES2_ONLY_FUNCTIONS(X) \
X(void, glBlendColor, (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha), (red, green, blue, alpha)) \
X(void, glStencilFuncSeparate, (GLenum face, GLenum func, GLint ref, GLuint mask), (face, func, ref, mask)) \
X(void, glStencilMaskSeparate, (GLenum face, GLuint mask), (face, mask)) \
X(void, glStencilOpSeparate, (GLenum face, GLenum fail, GLenum zfail, GLenum zpass), (face, fail, zfail, zpass)) \
X(GLboolean, glIsProgram, (GLuint program), (program)) \
X(GLboolean, glIsShader, (GLuint shader), (shader)) \
X(void, glVertexAttrib1f, (GLuint indx, GLfloat x), (indx, x)) \
X(void, glVertexAttrib1fv, (GLuint indx, const GLfloat* values), (indx, values)) \
X(void, glVertexAttrib2f, (GLuint indx, GLfloat x, GLfloat y), (indx, x, y)) \
X(void, glVertexAttrib2fv, (GLuint indx, const GLfloat* values), (indx, values)) \
X(void, glVertexAttrib3f, (GLuint indx, GLfloat x, GLfloat y, GLfloat z), (indx, x, y, z)) \
X(void, glVertexAttrib3fv, (GLuint indx, const GLfloat* values), (indx, values)) \
X(void, glVertexAttrib4f, (GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w), (indx, x, y, z, w)) \
X(void, glVertexAttrib4fv, (GLuint indx, const GLfloat* values), (indx, values)) \
X(void, glVertexAttribPointer, (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr), (indx, size, type, normalized, stride, ptr)) \
X(void, glDisableVertexAttribArray, (GLuint index), (index)) \
X(void, glEnableVertexAttribArray, (GLuint index), (index)) \
X(void, glGetVertexAttribfv, (GLuint index, GLenum pname, GLfloat* params), (index, pname, params)) \
X(void, glGetVertexAttribiv, (GLuint index, GLenum pname, GLint* params), (index, pname, params)) \
X(void, glGetVertexAttribPointerv, (GLuint index, GLenum pname, GLvoid** pointer), (index, pname, pointer)) \
X(void, glUniform1f, (GLint location, GLfloat x), (location, x)) \
X(void, glUniform1fv, (GLint location, GLsizei count, const GLfloat* v), (location, count, v)) \
X(void, glUniform1i, (GLint location, GLint x), (location, x)) \
X(void, glUniform1iv, (GLint location, GLsizei count, const GLint* v), (location, count, v)) \
X(void, glUniform2f, (GLint location, GLfloat x, GLfloat y), (location, x, y)) \
X(void, glUniform2fv, (GLint location, GLsizei count, const GLfloat* v), (location, count, v)) \
X(void, glUniform2i, (GLint location, GLint x, GLint y), (location, x, y)) \
X(void, glUniform2iv, (GLint location, GLsizei count, const GLint* v), (location, count, v)) \
X(void, glUniform3f, (GLint location, GLfloat x, GLfloat y, GLfloat z), (location, x, y, z)) \
X(void, glUniform3fv, (GLint location, GLsizei count, const GLfloat* v), (location, count, v)) \
X(void, glUniform3i, (GLint location, GLint x, GLint y, GLint z), (location, x, y, z)) \
X(void, glUniform3iv, (GLint location, GLsizei count, const GLint* v), (location, count, v)) \
X(void, glUniform4f, (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w), (location, x, y, z, w)) \
X(void, glUniform4fv, (GLint location, GLsizei count, const GLfloat* v), (location, count, v)) \
X(void, glUniform4i, (GLint location, GLint x, GLint y, GLint z, GLint w), (location, x, y, z, w)) \
X(void, glUniform4iv, (GLint location, GLsizei count, const GLint* v), (location, count, v)) \
X(void, glUniformMatrix2fv, (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value), (location, count, transpose, value)) \
X(void, glUniformMatrix3fv, (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value), (location, count, transpose, value)) \
X(void, glUniformMatrix4fv, (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value), (location, count, transpose, value)) \
X(void, glAttachShader, (GLuint program, GLuint shader), (program, shader)) \
X(void, glBindAttribLocation, (GLuint program, GLuint index, const GLchar* name), (program, index, name)) \
X(void, glCompileShader, (GLuint shader), (shader)) \
X(GLuint, glCreateProgram, (), ()) \
X(GLuint, glCreateShader, (GLenum type), (type)) \
X(void, glDeleteProgram, (GLuint program), (program)) \
X(void, glDeleteShader, (GLuint shader), (shader)) \
X(void, glDetachShader, (GLuint program, GLuint shader), (program, shader)) \
X(void, glLinkProgram, (GLuint program), (program)) \
X(void, glUseProgram, (GLuint program), (program)) \
X(void, glValidateProgram, (GLuint program), (program)) \
X(void, glGetActiveAttrib, (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name), (program, index, bufsize, length, size, type, name)) \
X(void, glGetActiveUniform, (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name), (program, index, bufsize, length, size, type, name)) \
X(void, glGetAttachedShaders, (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders), (program, maxcount, count, shaders)) \
X(int, glGetAttribLocation, (GLuint program, const GLchar* name), (program, name)) \
X(void, glGetProgramiv, (GLuint program, GLenum pname, GLint* params), (program, pname, params)) \
X(void, glGetProgramInfoLog, (GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog), (program, bufsize, length, infolog)) \
X(void, glGetShaderiv, (GLuint shader, GLenum pname, GLint* params), (shader, pname, params)) \
X(void, glGetShaderInfoLog, (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog), (shader, bufsize, length, infolog)) \
X(void, glGetShaderSource, (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source), (shader, bufsize, length, source)) \
X(void, glGetUniformfv, (GLuint program, GLint location, GLfloat* params), (program, location, params)) \
X(void, glGetUniformiv, (GLuint program, GLint location, GLint* params), (program, location, params)) \
X(int, glGetUniformLocation, (GLuint program, const GLchar* name), (program, name)) \
X(void, glShaderSource, (GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length), (shader, count, string, length)) \
X(void, glBindFramebuffer, (GLenum target, GLuint framebuffer), (target, framebuffer)) \
X(void, glGenFramebuffers, (GLsizei n, GLuint* framebuffers), (n, framebuffers)) \
X(void, glFramebufferTexture2D, (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level), (target, attachment, textarget, texture, level)) \
X(GLenum, glCheckFramebufferStatus, (GLenum target), (target)) \
X(void, glDeleteFramebuffers, (GLsizei n, const GLuint* framebuffers), (n, framebuffers)) \
X(GLboolean, glIsRenderbuffer, (GLuint renderbuffer), (renderbuffer)) \
X(void, glBindRenderbuffer, (GLenum target, GLuint renderbuffer), (target, renderbuffer)) \
X(void, glDeleteRenderbuffers, (GLsizei n, const GLuint * renderbuffers), (n, renderbuffers)) \
X(void, glGenRenderbuffers, (GLsizei n, GLuint * renderbuffers), (n, renderbuffers)) \
X(void, glRenderbufferStorage, (GLenum target, GLenum internalformat, GLsizei width, GLsizei height), (target, internalformat, width, height)) \
X(void, glGetRenderbufferParameteriv, (GLenum target, GLenum pname, GLint * params), (target, pname, params)) \
X(void, glFramebufferRenderbuffer, (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer), (target, attachment, renderbuffertarget, renderbuffer)) \
#endif // GLES2_ONLY_FUNCTIONS_H

View file

@ -1,18 +0,0 @@
// Auto-generated with: android/scripts/gen-entries.py --mode=funcargs distrib/android-emugl/host/libs/libOpenGLESDispatch/gles3_only.entries --output=distrib/android-emugl/host/include/OpenGLESDispatch/gles3_only_functions.h
// DO NOT EDIT THIS FILE
#ifndef GLES3_ONLY_FUNCTIONS_H
#define GLES3_ONLY_FUNCTIONS_H
#include <GLES/gl.h>
// Used to avoid adding GLES3/gl3.h to our headers.
#ifndef GL_NUM_EXTENSIONS
#define GL_NUM_EXTENSIONS 0x821D
#endif
typedef const GLubyte* GLconstubyteptr;
#define LIST_GLES3_ONLY_FUNCTIONS(X) \
X(GLconstubyteptr, glGetStringi, (GLenum name, GLint index), (name, index)) \
#endif // GLES3_ONLY_FUNCTIONS_H

View file

@ -1,79 +0,0 @@
// Auto-generated with: android/scripts/gen-entries.py --mode=funcargs distrib/android-emugl/host/libs/libOpenGLESDispatch/gles_common.entries --output=distrib/android-emugl/host/include/OpenGLESDispatch/gles_common_functions.h
// DO NOT EDIT THIS FILE
#ifndef GLES_COMMON_FUNCTIONS_H
#define GLES_COMMON_FUNCTIONS_H
#include <GLES/gl.h>
// Return types must be single words, see GLDispatch.cpp
typedef const GLubyte* GLconstubyteptr;
#define LIST_GLES_COMMON_FUNCTIONS(X) \
X(void, glActiveTexture, (GLenum texture), (texture)) \
X(void, glBindBuffer, (GLenum target, GLuint buffer), (target, buffer)) \
X(void, glBindTexture, (GLenum target, GLuint texture), (target, texture)) \
X(void, glBlendFunc, (GLenum sfactor, GLenum dfactor), (sfactor, dfactor)) \
X(void, glBlendEquation, (GLenum mode), (mode)) \
X(void, glBlendEquationSeparate, (GLenum modeRGB, GLenum modeAlpha), (modeRGB, modeAlpha)) \
X(void, glBlendFuncSeparate, (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha), (srcRGB, dstRGB, srcAlpha, dstAlpha)) \
X(void, glBufferData, (GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage), (target, size, data, usage)) \
X(void, glBufferSubData, (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data), (target, offset, size, data)) \
X(void, glClear, (GLbitfield mask), (mask)) \
X(void, glClearColor, (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha), (red, green, blue, alpha)) \
X(void, glClearDepth, (GLclampd depth), (depth)) \
X(void, glClearStencil, (GLint s), (s)) \
X(void, glColorMask, (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha), (red, green, blue, alpha)) \
X(void, glCompressedTexImage2D, (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid * data), (target, level, internalformat, width, height, border, imageSize, data)) \
X(void, glCompressedTexSubImage2D, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid * data), (target, level, xoffset, yoffset, width, height, format, imageSize, data)) \
X(void, glCopyTexImage2D, (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border), (target, level, internalFormat, x, y, width, height, border)) \
X(void, glCopyTexSubImage2D, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height), (target, level, xoffset, yoffset, x, y, width, height)) \
X(void, glCullFace, (GLenum mode), (mode)) \
X(void, glDeleteBuffers, (GLsizei n, const GLuint * buffers), (n, buffers)) \
X(void, glDeleteTextures, (GLsizei n, const GLuint * textures), (n, textures)) \
X(void, glDepthFunc, (GLenum func), (func)) \
X(void, glDepthMask, (GLboolean flag), (flag)) \
X(void, glDepthRange, (GLclampd zNear, GLclampd zFar), (zNear, zFar)) \
X(void, glDisable, (GLenum cap), (cap)) \
X(void, glDrawArrays, (GLenum mode, GLint first, GLsizei count), (mode, first, count)) \
X(void, glDrawElements, (GLenum mode, GLsizei count, GLenum type, const GLvoid * indices), (mode, count, type, indices)) \
X(void, glEnable, (GLenum cap), (cap)) \
X(void, glFinish, (), ()) \
X(void, glFlush, (), ()) \
X(void, glFrontFace, (GLenum mode), (mode)) \
X(void, glGenBuffers, (GLsizei n, GLuint * buffers), (n, buffers)) \
X(void, glGenTextures, (GLsizei n, GLuint * textures), (n, textures)) \
X(void, glGetBooleanv, (GLenum pname, GLboolean * params), (pname, params)) \
X(void, glGetBufferParameteriv, (GLenum buffer, GLenum parameter, GLint * value), (buffer, parameter, value)) \
X(GLenum, glGetError, (), ()) \
X(void, glGetFloatv, (GLenum pname, GLfloat * params), (pname, params)) \
X(void, glGetIntegerv, (GLenum pname, GLint * params), (pname, params)) \
X(GLconstubyteptr, glGetString, (GLenum name), (name)) \
X(void, glTexParameterf, (GLenum target, GLenum pname, GLfloat param), (target, pname, param)) \
X(void, glTexParameterfv, (GLenum target, GLenum pname, const GLfloat * params), (target, pname, params)) \
X(void, glGetTexParameterfv, (GLenum target, GLenum pname, GLfloat * params), (target, pname, params)) \
X(void, glGetTexParameteriv, (GLenum target, GLenum pname, GLint * params), (target, pname, params)) \
X(void, glGetTexLevelParameteriv, (GLenum target, GLint level, GLenum pname, GLint * params), (target, level, pname, params)) \
X(void, glHint, (GLenum target, GLenum mode), (target, mode)) \
X(GLboolean, glIsBuffer, (GLuint buffer), (buffer)) \
X(GLboolean, glIsEnabled, (GLenum cap), (cap)) \
X(GLboolean, glIsTexture, (GLuint texture), (texture)) \
X(void, glLineWidth, (GLfloat width), (width)) \
X(void, glPolygonOffset, (GLfloat factor, GLfloat units), (factor, units)) \
X(void, glPixelStorei, (GLenum pname, GLint param), (pname, param)) \
X(void, glReadPixels, (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid * pixels), (x, y, width, height, format, type, pixels)) \
X(void, glSampleCoverage, (GLclampf value, GLboolean invert), (value, invert)) \
X(void, glScissor, (GLint x, GLint y, GLsizei width, GLsizei height), (x, y, width, height)) \
X(void, glStencilFunc, (GLenum func, GLint ref, GLuint mask), (func, ref, mask)) \
X(void, glStencilMask, (GLuint mask), (mask)) \
X(void, glStencilOp, (GLenum fail, GLenum zfail, GLenum zpass), (fail, zfail, zpass)) \
X(void, glTexImage2D, (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid * pixels), (target, level, internalformat, width, height, border, format, type, pixels)) \
X(void, glTexParameteri, (GLenum target, GLenum pname, GLint param), (target, pname, param)) \
X(void, glTexParameteriv, (GLenum target, GLenum pname, const GLint * params), (target, pname, params)) \
X(void, glTexSubImage2D, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels), (target, level, xoffset, yoffset, width, height, format, type, pixels)) \
X(void, glViewport, (GLint x, GLint y, GLsizei width, GLsizei height), (x, y, width, height)) \
X(void, glPushAttrib, (GLbitfield mask), (mask)) \
X(void, glPushClientAttrib, (GLbitfield mask), (mask)) \
X(void, glPopAttrib, (), ()) \
X(void, glPopClientAttrib, (), ()) \
#endif // GLES_COMMON_FUNCTIONS_H

View file

@ -1,29 +0,0 @@
// Auto-generated with: android/scripts/gen-entries.py --mode=funcargs distrib/android-emugl/host/libs/libOpenGLESDispatch/gles_extensions.entries --output=distrib/android-emugl/host/include/OpenGLESDispatch/gles_extensions_functions.h
// DO NOT EDIT THIS FILE
#ifndef GLES_EXTENSIONS_FUNCTIONS_H
#define GLES_EXTENSIONS_FUNCTIONS_H
#define LIST_GLES_EXTENSIONS_FUNCTIONS(X) \
X(GLboolean, glIsRenderbufferEXT, (GLuint renderbuffer), (renderbuffer)) \
X(void, glBindRenderbufferEXT, (GLenum target, GLuint renderbuffer), (target, renderbuffer)) \
X(void, glDeleteRenderbuffersEXT, (GLsizei n, const GLuint * renderbuffers), (n, renderbuffers)) \
X(void, glGenRenderbuffersEXT, (GLsizei n, GLuint * renderbuffers), (n, renderbuffers)) \
X(void, glRenderbufferStorageEXT, (GLenum target, GLenum internalformat, GLsizei width, GLsizei height), (target, internalformat, width, height)) \
X(void, glGetRenderbufferParameterivEXT, (GLenum target, GLenum pname, GLint * params), (target, pname, params)) \
X(GLboolean, glIsFramebufferEXT, (GLuint framebuffer), (framebuffer)) \
X(void, glBindFramebufferEXT, (GLenum target, GLuint framebuffer), (target, framebuffer)) \
X(void, glDeleteFramebuffersEXT, (GLsizei n, const GLuint * framebuffers), (n, framebuffers)) \
X(void, glGenFramebuffersEXT, (GLsizei n, GLuint * framebuffers), (n, framebuffers)) \
X(GLenum, glCheckFramebufferStatusEXT, (GLenum target), (target)) \
X(void, glFramebufferTexture1DEXT, (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level), (target, attachment, textarget, texture, level)) \
X(void, glFramebufferTexture2DEXT, (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level), (target, attachment, textarget, texture, level)) \
X(void, glFramebufferTexture3DEXT, (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset), (target, attachment, textarget, texture, level, zoffset)) \
X(void, glFramebufferRenderbufferEXT, (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer), (target, attachment, renderbuffertarget, renderbuffer)) \
X(void, glGetFramebufferAttachmentParameterivEXT, (GLenum target, GLenum attachment, GLenum pname, GLint * params), (target, attachment, pname, params)) \
X(void, glGenerateMipmapEXT, (GLenum target), (target)) \
X(void, glEGLImageTargetTexture2DOES, (GLenum target, GLeglImageOES image), (target, image)) \
X(void, glEGLImageTargetRenderbufferStorageOES, (GLenum target, GLeglImageOES image), (target, image)) \
#endif // GLES_EXTENSIONS_FUNCTIONS_H

View file

@ -1,3 +1,22 @@
set(GENERATED_SOURCES
gles1_extensions_functions.h
gles1_only_functions.h
gles2_extensions_functions.h
gles2_only_functions.h
gles3_only_functions.h
gles_common_functions.h
gles_extensions_functions.h
gles_functions.h
RenderEGL_extensions_functions.h
RenderEGL_functions.h)
add_custom_target(GLHeaders)
add_custom_command(
TARGET GLHeaders
POST_BUILD
COMMAND ${CMAKE_SOURCE_DIR}/scripts/gen-emugl-headers.sh ${CMAKE_BINARY_DIR}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
add_subdirectory(GLESv1_dec)
add_subdirectory(GLESv2_dec)
add_subdirectory(libOpenGLESDispatch)

View file

@ -21,4 +21,5 @@ if ("${cmake_build_type_lower}" STREQUAL "trace")
endif()
add_library(GLESv1_dec STATIC ${SOURCES} ${GENERATED_SOURCES})
add_dependencies(GLESv1_dec GLHeaders)
target_link_libraries(GLESv1_dec OpenglCodecCommon)

View file

@ -21,4 +21,5 @@ if ("${cmake_build_type_lower}" STREQUAL "trace")
endif()
add_library(GLESv2_dec STATIC ${SOURCES} ${GENERATED_SOURCES})
add_dependencies(GLESv2_dec GLHeaders)
target_link_libraries(GLESv2_dec OpenglCodecCommon)

View file

@ -1,6 +1,6 @@
GLOBAL
base_opcode 2048
encoder_headers <string.h> "glUtils.h" "GLESv2EncoderUtils.h"
encoder_headers <string.h> "glUtils.h" "GL2EncoderUtils.h"
#void glBindAttribLocation(GLuint program, GLuint index, GLchar *name)
glBindAttribLocation

View file

@ -3,7 +3,8 @@ set(SOURCES
GLESv2Dispatch.cpp
GLESv1Dispatch.cpp)
add_library(OpenGLESDispatch STATIC ${SOURCES} ${GENERATED_SOURCES})
add_library(OpenGLESDispatch STATIC ${SOURCES})
add_dependencies(OpenGLESDispatch GLHeaders)
target_link_libraries(OpenGLESDispatch
emugl_common
GLESv2_dec

View file

@ -5,9 +5,17 @@ void glCurrentPaletteMatrixARB(GLint index);
void glMatrixIndexuivARB(GLint size, GLuint * indices);
void glMatrixIndexPointerARB(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
void glWeightPointerARB(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
void glTexGenf(GLenum coord, GLenum pname, GLfloat param );
void glTexGeni(GLenum coord, GLenum pname, GLint param );
void glTexGenfv(GLenum coord, GLenum pname, const GLfloat *params );
void glTexGeniv(GLenum coord, GLenum pname, const GLint *params );
void glGetTexGenfv(GLenum coord, GLenum pname, GLfloat *params );
void glGetTexGeniv(GLenum coord, GLenum pname, GLint *params );
void glTexGenf(GLenum coord, GLenum pname, GLfloat param);
void glTexGeni(GLenum coord, GLenum pname, GLint param);
void glTexGenfv(GLenum coord, GLenum pname, const GLfloat *params);
void glTexGeniv(GLenum coord, GLenum pname, const GLint *params);
void glGetTexGenfv(GLenum coord, GLenum pname, GLfloat *params);
void glGetTexGeniv(GLenum coord, GLenum pname, GLint *params);
void glDrawTexsOES(GLshort x, GLshort y, GLshort z, GLshort width, GLshort height);
void glDrawTexiOES(GLint x, GLint y, GLint z, GLint width, GLint height);
void glDrawTexfOES(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height);
void glDrawTexxOES(GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height);
void glDrawTexsvOES(const GLshort *coords);
void glDrawTexivOES(const GLint *coords);
void glDrawTexfvOES(const GLfloat *coords);
void glDrawTexxvOES(const GLfixed *coords);

View file

@ -4,6 +4,7 @@
void glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
void glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask);
void glStencilMaskSeparate(GLenum face, GLuint mask);
void glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass);
GLboolean glIsProgram(GLuint program);
GLboolean glIsShader(GLuint shader);
void glVertexAttrib1f(GLuint indx, GLfloat x);

478
scripts/gen-emugl-entries.py Executable file
View file

@ -0,0 +1,478 @@
#!/usr/bin/env python
# Copyright 2015 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Utility functions used to parse a list of DLL entry points.
# Expected format:
#
# <empty-line> -> ignored
# #<comment> -> ignored
# %<verbatim> -> verbatim output for header files.
# !<prefix> -> prefix name for header files.
# <return-type> <function-name> <signature> ; -> entry point declaration.
#
# Anything else is an error.
import re
import sys
import argparse
re_func = re.compile(r"""^(.*[\* ])([A-Za-z_][A-Za-z0-9_]*)\((.*)\);$""")
re_param = re.compile(r"""^(.*[\* ])([A-Za-z_][A-Za-z0-9_]*)$""")
class Entry:
"""Small class used to model a single DLL entry point."""
def __init__(self, func_name, return_type, parameters):
"""Initialize Entry instance. |func_name| is the function name,
|return_type| its return type, and |parameters| is a list of
(type,name) tuples from the entry's signature.
"""
self.func_name = func_name
self.return_type = return_type
self.parameters = ""
self.vartypes = []
self.varnames = []
self.call = ""
comma = ""
for param in parameters:
self.vartypes.append(param[0])
self.varnames.append(param[1])
self.parameters += "%s%s %s" % (comma, param[0], param[1])
self.call += "%s%s" % (comma, param[1])
comma = ", "
def banner_command(argv):
"""Return sanitized command-line description.
|argv| must be a list of command-line parameters, e.g. sys.argv.
Return a string corresponding to the command, with platform-specific
paths removed."""
# Remove path from first parameter
argv = argv[:]
argv[0] = "android/scripts/gen-entries.py"
return ' '.join(argv)
def parse_entries_file(lines):
"""Parse an .entries file and return a tuple of:
entries: list of Entry instances from the file.
prefix_name: prefix name from the file, or None.
verbatim: list of verbatim lines from the file.
errors: list of errors in the file, prefixed by line number.
"""
entries = []
verbatim = []
errors = []
lineno = 0
prefix_name = None
for line in lines:
lineno += 1
line = line.strip()
if len(line) == 0: # Ignore empty lines
continue
if line[0] == '#': # Ignore comments
continue
if line[0] == '!': # Prefix name
prefix_name = line[1:]
continue
if line[0] == '%': # Verbatim line copy
verbatim.append(line[1:])
continue
# Must be a function signature.
m = re_func.match(line)
if not m:
errors.append("%d: '%s'" % (lineno, line))
continue
return_type, func_name, parameters = m.groups()
return_type = return_type.strip()
parameters = parameters.strip()
params = []
failure = False
if parameters != "void":
for parameter in parameters.split(','):
parameter = parameter.strip()
m = re_param.match(parameter)
if not m:
errors.append("%d: parameter '%s'" % (lineno, parameter))
failure = True
break
else:
param_type, param_name = m.groups()
params.append((param_type.strip(), param_name.strip()))
if not failure:
entries.append(Entry(func_name, return_type, params))
return (entries, prefix_name, verbatim, errors)
def gen_functions_header(entries, prefix_name, verbatim, filename, with_args):
"""Generate a C header containing a macro listing all entry points.
|entries| is a list of Entry instances.
|prefix_name| is a prefix-name, it will be converted to upper-case.
|verbatim| is a list of verbatim lines that must appear before the
macro declaration. Useful to insert #include <> statements.
|filename| is the name of the original file.
"""
prefix_name = prefix_name.upper()
print "// Auto-generated with: %s" % banner_command(sys.argv)
print "// DO NOT EDIT THIS FILE"
print ""
print "#ifndef %s_FUNCTIONS_H" % prefix_name
print "#define %s_FUNCTIONS_H" % prefix_name
print ""
for line in verbatim:
print line
print "#define LIST_%s_FUNCTIONS(X) \\" % prefix_name
for entry in entries:
if with_args:
print " X(%s, %s, (%s), (%s)) \\" % \
(entry.return_type, entry.func_name, entry.parameters,
entry.call)
else:
print " X(%s, %s, (%s)) \\" % \
(entry.return_type, entry.func_name, entry.parameters)
print ""
print ""
print "#endif // %s_FUNCTIONS_H" % prefix_name
# The purpose of gen_translator()
# is to quickly generate implementations on the host Translator,
# which processes commands that just got onto the renderthread off goldfish pipe
# and are fed to system OpenGL.
def gen_translator(entries):
# Definitions for custom implementation bodies go in
# android/scripts/gles3translatorgen/gles30_custom.py
# android/scripts/gles3translatorgen/gles31_custom.py
from gles3translatorgen import gles30_custom
from gles3translatorgen import gles31_custom
translator_custom_share_processing = { }
for (k, v) in gles30_custom.custom_share_processing.items():
translator_custom_share_processing[k] = v
for (k, v) in gles31_custom.custom_share_processing.items():
translator_custom_share_processing[k] = v
translator_custom_pre = { }
for (k, v) in gles30_custom.custom_preprocesses.items():
translator_custom_pre[k] = v
for (k, v) in gles31_custom.custom_preprocesses.items():
translator_custom_pre[k] = v
translator_custom_post = { }
for (k, v) in gles30_custom.custom_postprocesses.items():
translator_custom_post[k] = v
for (k, v) in gles31_custom.custom_postprocesses.items():
translator_custom_post[k] = v
translator_no_passthrough = {}
for (k, v) in gles30_custom.no_passthrough.items():
translator_no_passthrough[k] = v
for (k, v) in gles31_custom.no_passthrough.items():
translator_no_passthrough[k] = v
translator_needexternc = {
"glGetStringi": 1,
"glUniform4ui": 1,
"glGetUniformIndices": 1,
"glTransformFeedbackVaryings": 1,
"glCreateShaderProgramv": 1,
"glProgramUniform2ui": 1,
"glProgramUniform3ui": 1,
"glProgramUniform4ui": 1,
"glBindVertexBuffer": 1,
};
translator_nocontext_fail_codes = {
"glClientWaitSync" : "GL_WAIT_FAILED",
};
def needExternC(entry):
if translator_needexternc.has_key(entry.func_name):
return "extern \"C\" "
else:
return ""
def get_fail_code(entry):
if translator_nocontext_fail_codes.has_key(entry.func_name):
return translator_nocontext_fail_codes[entry.func_name];
else:
return "0"
def gen_cxt_getter(entry):
if (entry.return_type == "void"):
print " GET_CTX_V2();"
else:
print " GET_CTX_V2_RET(%s);" % get_fail_code(entry)
def gen_validations_custom_impl(entry):
isGen = entry.func_name.startswith("glGen")
isDelete = entry.func_name.startswith("glDelete")
isBufferOp = "Buffer" in entry.func_name
hasTargetArg = "target" in entry.varnames
hasProgramArg = "program" in entry.varnames
def mySetError(condition, glerr):
if entry.return_type == "void":
return "SET_ERROR_IF(%s,%s)" % (condition, glerr);
else:
return "RET_AND_SET_ERROR_IF(%s,%s,%s)" % (condition, glerr, get_fail_code(entry));
if (isGen or isDelete) and ("n" in entry.varnames):
print " %s;" % mySetError("n < 0", "GL_INVALID_VALUE");
if (isBufferOp and hasTargetArg):
print " %s;" % mySetError("!GLESv2Validate::bufferTarget(ctx, target)", "GL_INVALID_ENUM");
if translator_custom_pre.has_key(entry.func_name):
print translator_custom_pre[entry.func_name],
def gen_call_ret(entry):
globalNameTypes = {
("GLuint", "program") : "NamedObjectType::SHADER_OR_PROGRAM",
("GLuint", "texture") : "NamedObjectType::TEXTURE",
("GLuint", "buffer") : "NamedObjectType::VERTEXBUFFER",
("GLuint", "sampler") : "NamedObjectType::SAMPLER",
("GLuint", "query") : "NamedObjectType::QUERY",
}
globalNames = {
("GLuint", "program") : "globalProgramName",
("GLuint", "texture") : "globalTextureName",
("GLuint", "buffer") : "globalBufferName",
("GLuint", "sampler") : "globalSampler",
("GLuint", "query") : "globalQuery",
}
needsShareGroup = False
for v in zip(entry.vartypes, entry.varnames):
if v in globalNameTypes.keys():
needsShareGroup = True
if needsShareGroup:
print " if (ctx->shareGroup().get()) {"
for key in zip(entry.vartypes, entry.varnames):
vartype, varname = key
if globalNames.has_key(key):
print " const GLuint %s = ctx->shareGroup()->getGlobalName(%s, %s);" % (globalNames[key], globalNameTypes[key], varname)
globalCall = ", ".join(map(lambda k: globalNames.get(k, k[1]), zip(entry.vartypes, entry.varnames)))
if needsShareGroup and translator_custom_share_processing.has_key(entry.func_name):
print translator_custom_share_processing[entry.func_name],
if (entry.return_type == "void"):
if (needsShareGroup):
print " ",
if not translator_no_passthrough.has_key(entry.func_name):
print " ctx->dispatcher().%s(%s);" % (entry.func_name, globalCall)
if needsShareGroup:
print " }"
if translator_custom_post.has_key(entry.func_name):
print translator_custom_post[entry.func_name];
else:
if (needsShareGroup):
print " ",
if not translator_no_passthrough.has_key(entry.func_name):
print " %s %s = ctx->dispatcher().%s(%s);" % (entry.return_type, entry.func_name + "RET", entry.func_name, globalCall)
else:
print " %s %s = %s" % (entry.return_type, entry_func_name + "RET", get_fail_code(entry))
if translator_custom_post.has_key(entry.func_name):
print translator_custom_post[entry.func_name];
print " return %s;" % (entry.func_name + "RET");
if needsShareGroup:
print " } else return %s;" % (get_fail_code(entry))
print "// Auto-generated with: %s" % banner_command(sys.argv)
print "// This file is best left unedited."
print "// Try to make changes through gen_translator in gen-entries.py,"
print "// and/or parcel out custom functionality in separate code."
for entry in entries:
print "%sGL_APICALL %s GL_APIENTRY %s(%s) {" % (needExternC(entry), entry.return_type, entry.func_name, entry.parameters)
gen_cxt_getter(entry);
gen_validations_custom_impl(entry);
gen_call_ret(entry);
print "}\n"
def gen_dll_wrapper(entries, prefix_name, verbatim, filename):
"""Generate a C source file that contains functions that act as wrappers
for entry points located in another shared library. This allows the
code that calls these functions to perform lazy-linking to system
libraries.
|entries|, |prefix_name|, |verbatim| and |filename| are the same as
for gen_functions_header() above.
"""
upper_name = prefix_name.upper()
ENTRY_PREFIX = "__dll_"
print "// Auto-generated with: %s" % banner_command(sys.argv)
print "// DO NOT EDIT THIS FILE"
print ""
print "#include <dlfcn.h>"
for line in verbatim:
print line
print ""
print "///"
print "/// W R A P P E R P O I N T E R S"
print "///"
print ""
for entry in entries:
ptr_name = ENTRY_PREFIX + entry.func_name
print "static %s (*%s)(%s) = 0;" % \
(entry.return_type, ptr_name, entry.parameters)
print ""
print "///"
print "/// W R A P P E R F U N C T I O N S"
print "///"
print ""
for entry in entries:
print "%s %s(%s) {" % \
(entry.return_type, entry.func_name, entry.parameters)
ptr_name = ENTRY_PREFIX + entry.func_name
if entry.return_type != "void":
print " return %s(%s);" % (ptr_name, entry.call)
else:
print " %s(%s);" % (ptr_name, entry.call)
print "}\n"
print ""
print "///"
print "/// I N I T I A L I Z A T I O N F U N C T I O N"
print "///"
print ""
print "int %s_dynlink_init(void* lib) {" % prefix_name
for entry in entries:
ptr_name = ENTRY_PREFIX + entry.func_name
print " %s = (%s(*)(%s))dlsym(lib, \"%s\");" % \
(ptr_name,
entry.return_type,
entry.parameters,
entry.func_name)
print " if (!%s) return -1;" % ptr_name
print " return 0;"
print "}"
def gen_windows_def_file(entries):
"""Generate a windows DLL .def file. |entries| is a list of Entry instances.
"""
print "EXPORTS"
for entry in entries:
print " %s" % entry.func_name
def gen_unix_sym_file(entries):
"""Generate an ELF linker version file. |entries| is a list of Entry
instances.
"""
print "VERSION {"
print "\tglobal:"
for entry in entries:
print "\t\t%s;" % entry.func_name
print "\tlocal:"
print "\t\t*;"
print "};"
def gen_symbols(entries, underscore):
"""Generate a list of symbols from |entries|, a list of Entry instances.
|underscore| is a boolean. If True, then prepend an underscore to each
symbol name.
"""
prefix = ""
if underscore:
prefix = "_"
for entry in entries:
print "%s%s" % (prefix, entry.func_name)
def parse_file(filename, lines, mode):
"""Generate one of possible outputs from |filename|. |lines| must be a list
of text lines from the file, and |mode| is one of the --mode option
values.
"""
entries, prefix_name, verbatim, errors = parse_entries_file(lines)
if errors:
for error in errors:
print >> sys.stderr, "ERROR: %s:%s" % (filename, error)
sys.exit(1)
if not prefix_name:
prefix_name = "unknown"
if mode == 'def':
gen_windows_def_file(entries)
elif mode == 'sym':
gen_unix_sym_file(entries)
elif mode == 'translator_passthrough':
gen_translator(entries)
elif mode == 'wrapper':
gen_dll_wrapper(entries, prefix_name, verbatim, filename)
elif mode == 'symbols':
gen_symbols(entries, False)
elif mode == '_symbols':
gen_symbols(entries, True)
elif mode == 'functions':
gen_functions_header(entries, prefix_name, verbatim, filename, False)
elif mode == 'funcargs':
gen_functions_header(entries, prefix_name, verbatim, filename, True)
# List of valid --mode option values.
mode_list = [
'def', 'sym', 'translator_passthrough', 'wrapper', 'symbols', '_symbols', 'functions', 'funcargs'
]
# Argument parsing.
parser = argparse.ArgumentParser(
formatter_class=argparse.RawDescriptionHelpFormatter,
description="""\
A script used to parse an .entries input file containing a list of function
declarations, and generate various output files depending on the value of
the --mode option, which can be:
def Generate a windows DLL .def file.
sym Generate a Unix .so linker script.
wrapper Generate a C source file containing wrapper functions.
symbols Generate a simple list of symbols, one per line.
_symbols Generate a simple list of symbols, prefixed with _.
functions Generate a C header containing a macro listing all functions.
funcargs Like 'functions', but adds function call arguments to listing.
""")
parser.add_argument("--mode", help="Output mode", choices=mode_list)
parser.add_argument("--output", help="output file")
parser.add_argument("file", help=".entries file path")
args = parser.parse_args()
if not args.mode:
print >> sys.stderr, "ERROR: Please use --mode=<name>, see --help."
sys.exit(1)
if args.output:
sys.stdout = open(args.output, "w+")
if args.file == '--':
parse_file("<stdin>", sys.stdin, args.mode)
else:
parse_file(args.file, open(args.file), args.mode)

110
scripts/gen-emugl-headers.sh Executable file
View file

@ -0,0 +1,110 @@
#!/bin/sh
# Copyright (C) 2015 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Run this script to re-generate headers with the gen-entries.py script.
set -e
export LANG=C
export LC_ALL=C
PROGDIR=$(dirname "$0")
OUTDIR=$1
panic () {
echo "ERROR: $@"
exit 1
}
if [ -z "$OUTDIR" ]; then
panic "No output dir defined!"
fi
QEMU_TOP_DIR=$(cd $PROGDIR/../ && pwd -P)
SCRIPT_DIR=scripts
if [ ! -d "$QEMU_TOP_DIR/$SCRIPT_DIR" ]; then
panic "Missing scripts directory: $QEMU_TOP_DIR/$SCRIPT_DIR"
fi
cd $QEMU_TOP_DIR
GEN_ENTRIES=$SCRIPT_DIR/gen-emugl-entries.py
if [ ! -f "$GEN_ENTRIES" ]; then
panic "Missing script: $GEN_ENTRIES"
fi
FAILURES=
# $1: Source file
# $2: Target file
# $3: gen-entries script.
gen_functions_header () {
local SRC_FILE="$1"
local DST_FILE="$2"
local GEN_ENTRIES="$3"
if [ ! -f "$SRC_FILE" ]; then
echo "ERROR: Missing source file: $SRC_FILE"
FAILURES=true
else
echo "Generating $DST_FILE"
$GEN_ENTRIES --mode=functions $SRC_FILE --output=$DST_FILE
fi
}
# $1: Source file
# $2: Target file
# $3: gen-entries script.
gen_funcargs_header () {
local SRC_FILE="$1"
local DST_FILE="$2"
local GEN_ENTRIES="$3"
if [ ! -f "$SRC_FILE" ]; then
echo "ERROR: Missing source file: $SRC_FILE"
FAILURES=true
else
echo "Generating $DST_FILE"
$GEN_ENTRIES --mode=funcargs $SRC_FILE --output=$DST_FILE
fi
}
##
## libOpenGLESDispatch headers.
##
OPENGLES_DISPATCH_SRCDIR=external/android-emugl/host/libs/libOpenGLESDispatch
OPENGLES_DISPATCH_INCLUDE=$OUTDIR/external/android-emugl/host/include/OpenGLESDispatch
mkdir -p $OPENGLES_DISPATCH_INCLUDE
gen_functions_header \
"$OPENGLES_DISPATCH_SRCDIR"/render_egl.entries \
"$OPENGLES_DISPATCH_INCLUDE"/RenderEGL_functions.h \
"$GEN_ENTRIES"
gen_functions_header \
"$OPENGLES_DISPATCH_SRCDIR"/render_egl_extensions.entries \
"$OPENGLES_DISPATCH_INCLUDE"/RenderEGL_extensions_functions.h \
"$GEN_ENTRIES"
GLES_ENTRIES="gles_common gles_extensions gles1_only gles1_extensions gles2_only \
gles2_extensions gles3_only"
for ENTRY in $GLES_ENTRIES; do
SRC_FILE=$OPENGLES_DISPATCH_SRCDIR/${ENTRY}.entries
DST_FILE=$OPENGLES_DISPATCH_INCLUDE/${ENTRY}_functions.h
gen_funcargs_header "$SRC_FILE" "$DST_FILE" "$GEN_ENTRIES"
done
if [ "$FAILURES" ]; then
exit 1
fi

136
scripts/update-emugl-sources.sh Executable file
View file

@ -0,0 +1,136 @@
#!/bin/sh
# Copyright 2014 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
set -e
export LANG=C
export LC_ALL=C
PROGDIR=$(dirname "$0")
PROGNAME=$(basename "$0")
fatal () {
echo "ERROR: $@"
exit 1
}
ANBOX_DIR="$PWD"
OPT_ANBOX_DIR=
OPT_EMUGEN=
OPT_HELP=
for OPT; do
OPTARG=$(expr "x$OPT" : "x[^=]*=\\(.*\\)" || true)
case $OPT in
--help|-h|-\?)
OPT_HELP=true
;;
--anbox-dir=*)
OPT_ANBOX_DIR=$OPTARG
;;
--emugen=*)
OPT_EMUGEN=$OPTARG
;;
-*)
fatal "Invalid option '$OPT', see --help."
;;
*)
fatal "This script doesn't take arguments, see --help."
;;
esac
done
if [ "$OPT_HELP" ]; then
cat <<EOF
Usage: $PROGNAME [options]
Update the sources of the GPU emulation encoder and decoder, after an update
to the 'emugen' tool.
Valid options (defaults are in brackets):
--help|-h|-? Print this help.
--anbox-dir=<dir> Specify top-level Anbox directory [$ANBOX_DIR].
--emugen=<program> Emugen program path, if not in path.
EOF
exit 0
fi
EMUGEN=
if [ "$OPT_EMUGEN" ]; then
EMUGEN=$OPT_EMUGEN
if [ ! -f "$EMUGEN" ]; then
fatal "Missing emugen binary: $EMUGEN"
fi
else
EMUGEN=$PROGDIR/../../../objs/build/intermediates64/emugen/emugen
if [ ! -f "$EMUGEN" ]; then
fatal "Missing emugen binary: $EMUGEN, please build it or use --emugen=<program>"
fi
echo "Auto-config: --emugen=$EMUGEN"
fi
if [ "$OPT_ANBOX_DIR" ]; then
ANBOX_DIR=$OPT_ANBOX_DIR
else
echo "Auto-config: --anbox-dir=$ANBOX_DIR"
fi
if [ ! -d "$ANBOX_DIR/src/anbox" ]; then
fatal "Not an Anbox directory: $ANBOX_DIR"
fi
ANBOX_DIR=$(cd "$ANBOX_DIR" && pwd -P)
# Find the sources for the encoder:
ENCODER_TOP_DIR=$ANBOX_DIR/android/opengl/system
DECODER_TOP_DIR=$ANBOX_DIR/external/android-emugl/host/libs
if [ ! -d "$ENCODER_TOP_DIR" ]; then
fatal "Missing encoder source directory: $ENCODER_TOP_DIR"
fi
if [ ! -d "$DECODER_TOP_DIR" ]; then
fatal "Missing decoder source directory: $DECODER_TOP_DIR"
fi
# GLESv1 encoder
GLESv1_INPUT_DIR=$DECODER_TOP_DIR/GLESv1_dec
GLESv2_INPUT_DIR=$DECODER_TOP_DIR/GLESv2_dec
RENDERCONTROL_INPUT_DIR=$DECODER_TOP_DIR/renderControl_dec
# The encoder has prefix GL while decoder has GLES
cp -f $DECODER_TOP_DIR/GLESv1_dec/gles1.attrib $DECODER_TOP_DIR/GLESv1_dec/gl.attrib
cp -f $DECODER_TOP_DIR/GLESv1_dec/gles1.in $DECODER_TOP_DIR/GLESv1_dec/gl.in
cp -f $DECODER_TOP_DIR/GLESv1_dec/gles1.types $DECODER_TOP_DIR/GLESv1_dec/gl.types
cp -f $DECODER_TOP_DIR/GLESv2_dec/gles2.attrib $DECODER_TOP_DIR/GLESv2_dec/gl2.attrib
cp -f $DECODER_TOP_DIR/GLESv2_dec/gles2.in $DECODER_TOP_DIR/GLESv2_dec/gl2.in
cp -f $DECODER_TOP_DIR/GLESv2_dec/gles2.types $DECODER_TOP_DIR/GLESv2_dec/gl2.types
$EMUGEN -i $DECODER_TOP_DIR/GLESv1_dec -E $ENCODER_TOP_DIR/GLESv1_enc gl
$EMUGEN -i $DECODER_TOP_DIR/GLESv2_dec -E $ENCODER_TOP_DIR/GLESv2_enc gl2
$EMUGEN -i $DECODER_TOP_DIR/renderControl_dec -E $ENCODER_TOP_DIR/renderControl_enc renderControl
rm $DECODER_TOP_DIR/GLESv1_dec/gl.attrib
rm $DECODER_TOP_DIR/GLESv1_dec/gl.in
rm $DECODER_TOP_DIR/GLESv1_dec/gl.types
rm $DECODER_TOP_DIR/GLESv2_dec/gl2.attrib
rm $DECODER_TOP_DIR/GLESv2_dec/gl2.in
rm $DECODER_TOP_DIR/GLESv2_dec/gl2.types
echo "Done, see $ENCODER_TOP_DIR"
exit 0

View file

@ -18,6 +18,7 @@ include_directories(
${CMAKE_SOURCE_DIR}/external/process-cpp-minimal/include
${CMAKE_SOURCE_DIR}/external/android-emugl/shared
${CMAKE_SOURCE_DIR}/external/android-emugl/host/include
${CMAKE_BINARY_DIR}/external/android-emugl/host/include
${CMAKE_SOURCE_DIR}/external/android-emugl/shared/OpenglCodecCommon
${CMAKE_SOURCE_DIR}/external/android-emugl/host/libs
${CMAKE_SOURCE_DIR}/external/android-emugl/host/include/libOpenglRender

View file

@ -1,129 +0,0 @@
!render_api
%#include "OpenglRender/render_api_platform_types.h"
%
%#include <stdbool.h>
%#include <stddef.h>
%#include <stdint.h>
%
%/* list of constants to be passed to setStreamMode */
%#define RENDER_API_STREAM_MODE_DEFAULT 0
%#define RENDER_API_STREAM_MODE_TCP 1
%#define RENDER_API_STREAM_MODE_UNIX 2
%#define RENDER_API_STREAM_MODE_PIPE 3
%
%typedef void (*OnPostFn)(void* context, int width, int height, int ydir,
% int format, int type, unsigned char* pixels);
# Initialize the library and tries to load the corresponding EGL/GLES
# translation libraries. Must be called before anything else to ensure that
# everything works. Returns 0 on success, error code otherwise.
# If it returns an error, you cannot use the library at all.
int initLibrary(void);
# Change the stream mode. This must be called before initOpenGLRenderer()
# |mode| is one of STREAM_DEFAULT, STREAM_UNIX, STREAM_TCP or STREAM_PIPE.
int setStreamMode(int mode);
# initOpenGLRenderer - initialize the OpenGL renderer process.
#
# width and height are the framebuffer dimensions that will be reported to the
# guest display driver.
#
# useSubWindow is true to indicate that createOpenGLSubWindow() will be called
# later. If false, only setPostCallback() is supported.
#
# addr is a buffer of addrLen bytes that will receive the address that clients
# should connect to. The interpretation depends on the transport:
# - TCP: The buffer contains the port number as a string. The server is
# listening only on the loopback address.
# - Win32 and UNIX named pipes: The buffer contains the full path clients
# should connect to.
#
# This function is *NOT* thread safe and should be called first
# to initialize the renderer after initLibrary().
int initOpenGLRenderer(int width, int height, bool useSubWindow, char* addr, size_t addrLen, emugl_logger_struct logfuncs);
# getHardwareStrings - describe the GPU hardware and driver.
# The underlying GL's vendor/renderer/version strings are returned to the
# caller. The pointers become invalid after a call to stopOpenGLRenderer().
void getHardwareStrings(const char** vendor, const char** renderer, const char** version);
# A per-frame callback can be registered with setPostCallback(); to remove it
# pass NULL for both parameters. While a callback is registered, the renderer
# will call it just before each new frame is displayed, providing a copy of
# the framebuffer contents.
#
# The callback will be called from one of the renderer's threads, so will
# probably need synchronization on any data structures it modifies. The
# pixels buffer may be overwritten as soon as the callback returns; if it
# needs the pixels afterwards it must copy them.
#
# The pixels buffer is intentionally not const: the callback may modify the
# data without copying to another buffer if it wants, e.g. in-place RGBA to
# RGB conversion, or in-place y-inversion.
#
# Parameters are:
# context The pointer optionally provided when the callback was
# registered. The client can use this to pass whatever
# information it wants to the callback.
# width, height Dimensions of the image, in pixels. Rows are tightly
# packed; there is no inter-row padding.
# ydir Indicates row order: 1 means top-to-bottom order, -1 means
# bottom-to-top order.
# format, type Format and type GL enums, as used in glTexImage2D() or
# glReadPixels(), describing the pixel format.
# pixels The framebuffer image.
#
# In the first implementation, ydir is always -1 (bottom to top), format and
# type are always GL_RGBA and GL_UNSIGNED_BYTE, and the width and height will
# always be the same as the ones passed to initOpenGLRenderer().
void setPostCallback(OnPostFn onPost, void* onPostContext);
# showOpenGLSubwindow -
# Create or modify a native subwindow which is a child of 'window'
# to be used for framebuffer display. If a subwindow already exists,
# its properties will be updated to match the given parameters.
# wx,wy is the top left corner of the rendering subwindow.
# ww,wh are the dimensions of the rendering subwindow.
# fbw,fbh are the dimensions of the underlying guest framebuffer.
# dpr is the device pixel ratio, which is needed for higher density
# displays like retina.
# zRot is the rotation to apply on the framebuffer display image.
#
# Return true on success, false on failure, which can happen when using
# a software-only renderer like OSMesa. In this case, the client should
# call setPostCallback to get the content of each new frame when it is
# posted, and will be responsible for displaying it.
bool showOpenGLSubwindow(FBNativeWindowType window, int wx, int wy, int ww, int wh, int fbw, int fbh, float dpr, float zRot);
# destroyOpenGLSubwindow -
# destroys the created native subwindow. Once destroyed,
# Framebuffer content will not be visible until a new
# subwindow will be created.
# Return true on success, false otherwise.
bool destroyOpenGLSubwindow(void);
# setOpenGLDisplayRotation -
# set the framebuffer display image rotation in units
# of degrees around the z axis
void setOpenGLDisplayRotation(float zRot);
# setOpenGLDisplayTranslation
# change what coordinate of the guest framebuffer will be displayed at the
# corner of the GPU sub-window. Specifically, |px| and |py| = 0 means
# align the bottom-left of the framebuffer with the bottom-left of the
# sub-window, and |px| and |py| = 1 means align the top right of the
# framebuffer with the top right of the sub-window. Intermediate values
# interpolate between these states.
void setOpenGLDisplayTranslation(float px, float py);
# repaintOpenGLDisplay -
# causes the OpenGL subwindow to get repainted with the
# latest framebuffer content.
void repaintOpenGLDisplay(void);
# stopOpenGLRenderer - stops the OpenGL renderer process.
# This functions is#NOT* thread safe and should be called
# only if previous initOpenGLRenderer has returned true.
int stopOpenGLRenderer(void);