aboutsummaryrefslogtreecommitdiffstats
path: root/emulator/opengl
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@google.com>2014-10-31 14:05:29 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2014-10-31 14:05:30 +0000
commit72e9658d006ead8e59f3d08dcf79b516c7fb1fac (patch)
treed84226a10419bf4516de8fdfde6f6da81bd9b758 /emulator/opengl
parent791087a7c0f43f30d0fa71b0e83361a8ade83a72 (diff)
parentc4f3b66839698174b9f86c92b0a8efae5c80d415 (diff)
downloadsdk-72e9658d006ead8e59f3d08dcf79b516c7fb1fac.tar.gz
sdk-72e9658d006ead8e59f3d08dcf79b516c7fb1fac.tar.bz2
sdk-72e9658d006ead8e59f3d08dcf79b516c7fb1fac.zip
Merge changes I8cc8fdb0,I750f95f2,Ibab92ab3,Ib11fd06a,I9abc3f9a
* changes: emulator/opengl/emugen: Add new 'flushOnEncode' entry point flag. emulator/opengl: Fix glShaderSource() signature. emulator/opengl: Remove compiler warnings. emulator/opengl/emugen: Small cleanup of autogenerated sources. emulator/opengl: Add emugen test suite.
Diffstat (limited to 'emulator/opengl')
-rw-r--r--emulator/opengl/host/libs/GLESv2_dec/gl2.in2
-rw-r--r--emulator/opengl/host/libs/GLESv2_dec/gl2.types1
-rw-r--r--emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp2
-rw-r--r--emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.cpp2
-rw-r--r--emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.h2
-rw-r--r--emulator/opengl/host/libs/Translator/GLcommon/DummyGLfuncs.cpp2
-rw-r--r--emulator/opengl/host/libs/Translator/GLcommon/DummyGLfuncs.h2
-rw-r--r--emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp2
-rw-r--r--emulator/opengl/host/libs/Translator/include/GLES2/gl2.h2
-rw-r--r--emulator/opengl/host/libs/Translator/include/GLcommon/GLDispatch.h2
-rw-r--r--emulator/opengl/host/libs/libOpenglRender/NativeLinuxSubWindow.cpp2
-rw-r--r--emulator/opengl/host/libs/renderControl_dec/renderControl.attrib3
-rw-r--r--emulator/opengl/host/tools/emugen/ApiGen.cpp53
-rw-r--r--emulator/opengl/host/tools/emugen/EntryPoint.cpp3
-rw-r--r--emulator/opengl/host/tools/emugen/EntryPoint.h3
-rwxr-xr-xemulator/opengl/host/tools/emugen/tests/run-tests.sh129
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.cpp89
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.h18
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_opcodes.h13
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.cpp19
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.h19
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_proc.h18
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.cpp19
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.h24
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_proc.h18
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.cpp84
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.h21
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_entry.cpp46
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_ftable.h19
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_opcodes.h13
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.cpp19
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.h22
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_entry.cpp45
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_proc.h18
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/input/foo.attrib15
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/input/foo.in4
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/input/foo.types9
37 files changed, 731 insertions, 33 deletions
diff --git a/emulator/opengl/host/libs/GLESv2_dec/gl2.in b/emulator/opengl/host/libs/GLESv2_dec/gl2.in
index 916153b4e..925eb98cb 100644
--- a/emulator/opengl/host/libs/GLESv2_dec/gl2.in
+++ b/emulator/opengl/host/libs/GLESv2_dec/gl2.in
@@ -96,7 +96,7 @@ GL_ENTRY(void, glRenderbufferStorage, GLenum target, GLenum internalformat, GLsi
GL_ENTRY(void, glSampleCoverage, GLclampf value, GLboolean invert)
GL_ENTRY(void, glScissor, GLint x, GLint y, GLsizei width, GLsizei height)
GL_ENTRY(void, glShaderBinary, GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length)
-GL_ENTRY(void, glShaderSource, GLuint shader, GLsizei count, const GLchar** string, const GLint* length)
+GL_ENTRY(void, glShaderSource, GLuint shader, GLsizei count, const GLchar*const* string, const GLint* length)
GL_ENTRY(void, glStencilFunc, GLenum func, GLint ref, GLuint mask)
GL_ENTRY(void, glStencilFuncSeparate, GLenum face, GLenum func, GLint ref, GLuint mask)
GL_ENTRY(void, glStencilMask, GLuint mask)
diff --git a/emulator/opengl/host/libs/GLESv2_dec/gl2.types b/emulator/opengl/host/libs/GLESv2_dec/gl2.types
index ab4eae31e..2f5c0c333 100644
--- a/emulator/opengl/host/libs/GLESv2_dec/gl2.types
+++ b/emulator/opengl/host/libs/GLESv2_dec/gl2.types
@@ -34,3 +34,4 @@ GLvoid** 32 0x%08x
void* 32 0x%08x
GLstr* 32 0x%08x
GLvoidptr* 32 0x%08x
+GLchar*const* 32 0x%08x
diff --git a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp b/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
index c97e06164..133e5e99f 100644
--- a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
+++ b/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
@@ -1694,7 +1694,7 @@ GL_APICALL void GL_APIENTRY glShaderBinary(GLsizei n, const GLuint* shaders, GL
}
}
-GL_APICALL void GL_APIENTRY glShaderSource(GLuint shader, GLsizei count, const GLchar** string, const GLint* length){
+GL_APICALL void GL_APIENTRY glShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length){
GET_CTX_V2();
SET_ERROR_IF(count < 0,GL_INVALID_VALUE);
if(ctx->shareGroup().Ptr()){
diff --git a/emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.cpp b/emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.cpp
index 9bbedbf20..e0e19e999 100644
--- a/emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.cpp
+++ b/emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.cpp
@@ -35,7 +35,7 @@ ShaderParser::ShaderParser(GLenum type):ObjectData(SHADER_DATA),
m_infoLog[0] = '\0';
};
-void ShaderParser::setSrc(const Version& ver,GLsizei count,const GLchar** strings,const GLint* length){
+void ShaderParser::setSrc(const Version& ver,GLsizei count,const GLchar* const* strings,const GLint* length){
m_src.clear();
for(int i = 0;i<count;i++){
m_src.append(strings[i]);
diff --git a/emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.h b/emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.h
index 7b538c393..637400013 100644
--- a/emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.h
+++ b/emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.h
@@ -26,7 +26,7 @@ class ShaderParser:public ObjectData{
public:
ShaderParser();
ShaderParser(GLenum type);
- void setSrc(const Version& ver,GLsizei count,const GLchar** strings,const GLint* length);
+ void setSrc(const Version& ver,GLsizei count,const GLchar* const* strings,const GLint* length);
const char* getOriginalSrc();
const GLchar** parsedLines();
GLenum getType();
diff --git a/emulator/opengl/host/libs/Translator/GLcommon/DummyGLfuncs.cpp b/emulator/opengl/host/libs/Translator/GLcommon/DummyGLfuncs.cpp
index e4b632d4a..cc0e3ecab 100644
--- a/emulator/opengl/host/libs/Translator/GLcommon/DummyGLfuncs.cpp
+++ b/emulator/opengl/host/libs/Translator/GLcommon/DummyGLfuncs.cpp
@@ -251,6 +251,6 @@
void GL_APIENTRY dummy_glReleaseShaderCompiler(void){}
void GL_APIENTRY dummy_glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height){}
void GL_APIENTRY dummy_glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length){}
- void GL_APIENTRY dummy_glShaderSource(GLuint shader, GLsizei count, const GLchar** string, const GLint* length){}
+ void GL_APIENTRY dummy_glShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length){}
void GL_APIENTRY dummy_glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer){}
void GL_APIENTRY dummy_glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level){}
diff --git a/emulator/opengl/host/libs/Translator/GLcommon/DummyGLfuncs.h b/emulator/opengl/host/libs/Translator/GLcommon/DummyGLfuncs.h
index f72107c6f..dd5379c7c 100644
--- a/emulator/opengl/host/libs/Translator/GLcommon/DummyGLfuncs.h
+++ b/emulator/opengl/host/libs/Translator/GLcommon/DummyGLfuncs.h
@@ -258,7 +258,7 @@
void GL_APIENTRY dummy_glReleaseShaderCompiler(void);
void GL_APIENTRY dummy_glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
void GL_APIENTRY dummy_glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length);
- void GL_APIENTRY dummy_glShaderSource(GLuint shader, GLsizei count, const GLchar** string, const GLint* length);
+ void GL_APIENTRY dummy_glShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length);
void GL_APIENTRY dummy_glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
void GL_APIENTRY dummy_glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
diff --git a/emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp b/emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp
index 5da724729..3f091d1ac 100644
--- a/emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp
+++ b/emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp
@@ -293,7 +293,7 @@ void (GL_APIENTRY *GLDispatch::glGetUniformiv)(GLuint,GLint,GLint*) = NULL;
int (GL_APIENTRY *GLDispatch::glGetUniformLocation)(GLuint,const GLchar*) = NULL;
void (GL_APIENTRY *GLDispatch::glReleaseShaderCompiler)() = NULL;
void (GL_APIENTRY *GLDispatch::glShaderBinary)(GLsizei,const GLuint*,GLenum,const GLvoid*,GLsizei) = NULL;
-void (GL_APIENTRY *GLDispatch::glShaderSource)(GLuint,GLsizei,const GLchar**,const GLint*) = NULL;
+void (GL_APIENTRY *GLDispatch::glShaderSource)(GLuint,GLsizei,const GLchar* const*,const GLint*) = NULL;
GLDispatch::GLDispatch():m_isLoaded(false){};
diff --git a/emulator/opengl/host/libs/Translator/include/GLES2/gl2.h b/emulator/opengl/host/libs/Translator/include/GLES2/gl2.h
index e1d3b87cc..eae81f4cb 100644
--- a/emulator/opengl/host/libs/Translator/include/GLES2/gl2.h
+++ b/emulator/opengl/host/libs/Translator/include/GLES2/gl2.h
@@ -569,7 +569,7 @@ GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenum target, GLenum
GL_APICALL void GL_APIENTRY glSampleCoverage (GLclampf value, GLboolean invert);
GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height);
GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length);
-GL_APICALL void GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar** string, const GLint* length);
+GL_APICALL void GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length);
GL_APICALL void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask);
GL_APICALL void GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask);
GL_APICALL void GL_APIENTRY glStencilMask (GLuint mask);
diff --git a/emulator/opengl/host/libs/Translator/include/GLcommon/GLDispatch.h b/emulator/opengl/host/libs/Translator/include/GLcommon/GLDispatch.h
index 18a989cda..6eda55bf7 100644
--- a/emulator/opengl/host/libs/Translator/include/GLcommon/GLDispatch.h
+++ b/emulator/opengl/host/libs/Translator/include/GLcommon/GLDispatch.h
@@ -257,7 +257,7 @@ public:
static int (GL_APIENTRY *glGetUniformLocation)(GLuint program, const GLchar* name);
static void (GL_APIENTRY *glReleaseShaderCompiler)(void);
static void (GL_APIENTRY *glShaderBinary)(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length);
- static void (GL_APIENTRY *glShaderSource)(GLuint shader, GLsizei count, const GLchar** string, const GLint* length);
+ static void (GL_APIENTRY *glShaderSource)(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length);
private:
bool m_isLoaded;
diff --git a/emulator/opengl/host/libs/libOpenglRender/NativeLinuxSubWindow.cpp b/emulator/opengl/host/libs/libOpenglRender/NativeLinuxSubWindow.cpp
index ff335df2f..5f7184960 100644
--- a/emulator/opengl/host/libs/libOpenglRender/NativeLinuxSubWindow.cpp
+++ b/emulator/opengl/host/libs/libOpenglRender/NativeLinuxSubWindow.cpp
@@ -15,6 +15,8 @@
*/
#include "NativeSubWindow.h"
+#include <stdio.h>
+
static Bool WaitForMapNotify(Display *d, XEvent *e, char *arg)
{
if (e->type == MapNotify && e->xmap.window == (Window)arg) {
diff --git a/emulator/opengl/host/libs/renderControl_dec/renderControl.attrib b/emulator/opengl/host/libs/renderControl_dec/renderControl.attrib
index 8b9972ff7..0afa9d3c5 100644
--- a/emulator/opengl/host/libs/renderControl_dec/renderControl.attrib
+++ b/emulator/opengl/host/libs/renderControl_dec/renderControl.attrib
@@ -39,3 +39,6 @@ rcUpdateColorBuffer
dir pixels in
len pixels (((glUtilsPixelBitSize(format, type) * width) >> 3) * height)
var_flag pixels isLarge
+
+rcCloseColorBuffer
+ flag flushOnEncode
diff --git a/emulator/opengl/host/tools/emugen/ApiGen.cpp b/emulator/opengl/host/tools/emugen/ApiGen.cpp
index 71cd843cd..8be0270db 100644
--- a/emulator/opengl/host/tools/emugen/ApiGen.cpp
+++ b/emulator/opengl/host/tools/emugen/ApiGen.cpp
@@ -110,7 +110,7 @@ int ApiGen::genFuncTable(const std::string &filename, SideType side)
fprintf(fp, "#ifndef __%s_%s_ftable_t_h\n", m_basename.c_str(), sideString(side));
fprintf(fp, "#define __%s_%s_ftable_t_h\n", m_basename.c_str(), sideString(side));
fprintf(fp, "\n\n");
- fprintf(fp, "static struct _%s_funcs_by_name {\n", m_basename.c_str());
+ fprintf(fp, "static const struct _%s_funcs_by_name {\n", m_basename.c_str());
fprintf(fp,
"\tconst char *name;\n" \
"\tvoid *proc;\n" \
@@ -123,7 +123,7 @@ int ApiGen::genFuncTable(const std::string &filename, SideType side)
fprintf(fp, "\t{\"%s\", (void*)%s},\n", e->name().c_str(), e->name().c_str());
}
fprintf(fp, "};\n");
- fprintf(fp, "static int %s_num_funcs = sizeof(%s_funcs_by_name) / sizeof(struct _%s_funcs_by_name);\n",
+ fprintf(fp, "static const int %s_num_funcs = sizeof(%s_funcs_by_name) / sizeof(struct _%s_funcs_by_name);\n",
m_basename.c_str(), m_basename.c_str(), m_basename.c_str());
fprintf(fp, "\n\n#endif\n");
return 0;
@@ -171,7 +171,7 @@ int ApiGen::genContext(const std::string & filename, SideType side)
//client site set error virtual func
if (side == CLIENT_SIDE) {
- fprintf(fp, "\tvirtual void setError(unsigned int error){};\n");
+ fprintf(fp, "\tvirtual void setError(unsigned int error){ (void)error; };\n");
fprintf(fp, "\tvirtual unsigned int getError(){ return 0; };\n");
}
@@ -219,7 +219,7 @@ int ApiGen::genEntryPoints(const std::string & filename, SideType side)
fprintf(fp,
"void %s_%s_context_t::setContextAccessor(CONTEXT_ACCESSOR_TYPE *f) { getCurrentContext = f; }\n",
m_basename.c_str(), sideString(side));
- fprintf(fp, "#define GET_CONTEXT %s_%s_context_t * ctx = getCurrentContext() \n",
+ fprintf(fp, "#define GET_CONTEXT %s_%s_context_t * ctx = getCurrentContext()\n",
m_basename.c_str(), sideString(side));
fprintf(fp, "#endif\n\n");
@@ -228,7 +228,7 @@ int ApiGen::genEntryPoints(const std::string & filename, SideType side)
EntryPoint *e = &at(i);
e->print(fp);
fprintf(fp, "{\n");
- fprintf(fp, "\tGET_CONTEXT; \n");
+ fprintf(fp, "\tGET_CONTEXT;\n");
bool shouldReturn = !e->retval().isVoid();
bool shouldCallWithContext = (side == CLIENT_SIDE);
@@ -239,7 +239,7 @@ int ApiGen::genEntryPoints(const std::string & filename, SideType side)
fprintf(fp, "\t%s\n", e->vars()[j].paramCheckExpression().c_str());
}
}
- fprintf(fp, "\t %sctx->%s(%s",
+ fprintf(fp, "\t%sctx->%s(%s",
shouldReturn ? "return " : "",
e->name().c_str(),
shouldCallWithContext ? "ctx" : "");
@@ -325,18 +325,10 @@ int ApiGen::genEncoderHeader(const std::string &filename)
classname.c_str(), m_basename.c_str(), sideString(CLIENT_SIDE));
fprintf(fp, "\tIOStream *m_stream;\n\n");
- fprintf(fp, "\t%s(IOStream *stream);\n\n", classname.c_str());
- fprintf(fp, "\n};\n\n");
-
- fprintf(fp,"extern \"C\" {\n");
+ fprintf(fp, "\t%s(IOStream *stream);\n", classname.c_str());
+ fprintf(fp, "};\n\n");
- for (size_t i = 0; i < size(); i++) {
- fprintf(fp, "\t");
- at(i).print(fp, false, "_enc", /* classname + "::" */"", "void *self");
- fprintf(fp, ";\n");
- }
- fprintf(fp, "};\n");
- fprintf(fp, "#endif");
+ fprintf(fp, "#endif // GUARD_%s", classname.c_str());
fclose(fp);
return 0;
@@ -453,15 +445,20 @@ int ApiGen::genEncoderImpl(const std::string &filename)
fprintf(fp, "\n\n#include <string.h>\n");
fprintf(fp, "#include \"%s_opcodes.h\"\n\n", m_basename.c_str());
fprintf(fp, "#include \"%s_enc.h\"\n\n\n", m_basename.c_str());
- fprintf(fp, "#include <stdio.h>\n");
- std::string classname = m_basename + "_encoder_context_t";
- size_t n = size();
+ fprintf(fp, "#include <stdio.h>\n\n");
+ fprintf(fp, "namespace {\n\n");
// unsupport printout
fprintf(fp,
- "static void enc_unsupported()\n{\n\tALOGE(\"Function is unsupported\\n\");\n}\n\n");
+ "void enc_unsupported()\n"
+ "{\n"
+ "\tALOGE(\"Function is unsupported\\n\");\n"
+ "}\n\n");
// entry points;
+ std::string classname = m_basename + "_encoder_context_t";
+
+ size_t n = size();
for (size_t i = 0; i < n; i++) {
EntryPoint *e = &at(i);
@@ -633,19 +630,27 @@ int ApiGen::genEncoderImpl(const std::string &filename)
}
}
//XXX fprintf(fp, "\n\tDBG(\"<<<< %s\\n\");\n", e->name().c_str());
+
// todo - return value for pointers
if (e->retval().isPointer()) {
fprintf(stderr, "WARNING: %s : return value of pointer is unsupported\n",
e->name().c_str());
+ if (e->flushOnEncode()) {
+ fprintf(fp, "\tstream->flush();\n");
+ }
fprintf(fp, "\t return NULL;\n");
} else if (e->retval().type()->name() != "void") {
fprintf(fp, "\n\t%s retval;\n", e->retval().type()->name().c_str());
fprintf(fp, "\tstream->readback(&retval, %u);\n",(unsigned) e->retval().type()->bytes());
fprintf(fp, "\treturn retval;\n");
+ } else if (e->flushOnEncode()) {
+ fprintf(fp, "\tstream->flush();\n");
}
fprintf(fp, "}\n\n");
}
+ fprintf(fp, "} // namespace\n\n");
+
// constructor
fprintf(fp, "%s::%s(IOStream *stream)\n{\n", classname.c_str(), classname.c_str());
fprintf(fp, "\tm_stream = stream;\n\n");
@@ -654,13 +659,13 @@ int ApiGen::genEncoderImpl(const std::string &filename)
EntryPoint *e = &at(i);
if (e->unsupported()) {
fprintf(fp,
- "\t%s = (%s_%s_proc_t)(enc_unsupported);\n",
+ "\tthis->%s = (%s_%s_proc_t) &enc_unsupported;\n",
e->name().c_str(),
e->name().c_str(),
sideString(CLIENT_SIDE));
} else {
fprintf(fp,
- "\t%s = (%s_enc);\n",
+ "\tthis->%s = &%s_enc;\n",
e->name().c_str(),
e->name().c_str());
}
@@ -698,7 +703,7 @@ int ApiGen::genDecoderHeader(const std::string &filename)
classname.c_str(), m_basename.c_str(), sideString(SERVER_SIDE));
fprintf(fp, "\tsize_t decode(void *buf, size_t bufsize, IOStream *stream);\n");
fprintf(fp, "\n};\n\n");
- fprintf(fp, "#endif\n");
+ fprintf(fp, "#endif // GUARD_%s\n", classname.c_str());
fclose(fp);
return 0;
diff --git a/emulator/opengl/host/tools/emugen/EntryPoint.cpp b/emulator/opengl/host/tools/emugen/EntryPoint.cpp
index 43b904bee..55b30cfe7 100644
--- a/emulator/opengl/host/tools/emugen/EntryPoint.cpp
+++ b/emulator/opengl/host/tools/emugen/EntryPoint.cpp
@@ -35,6 +35,7 @@ void EntryPoint::reset()
m_unsupported = false;
m_customDecoder = false;
m_notApi = false;
+ m_flushOnEncode = false;
m_vars.empty();
}
@@ -365,6 +366,8 @@ int EntryPoint::setAttribute(const std::string &line, size_t lc)
setCustomDecoder(true);
} else if (flag == "not_api") {
setNotApi(true);
+ } else if (flag == "flushOnEncode") {
+ setFlushOnEncode(true);
} else {
fprintf(stderr, "WARNING: %u: unknown flag %s\n", (unsigned int)lc, flag.c_str());
}
diff --git a/emulator/opengl/host/tools/emugen/EntryPoint.h b/emulator/opengl/host/tools/emugen/EntryPoint.h
index 77b8a7f34..1061d255b 100644
--- a/emulator/opengl/host/tools/emugen/EntryPoint.h
+++ b/emulator/opengl/host/tools/emugen/EntryPoint.h
@@ -47,6 +47,8 @@ public:
void setCustomDecoder(bool state) { m_customDecoder = state; }
bool notApi() const { return m_notApi; }
void setNotApi(bool state) { m_notApi = state; }
+ bool flushOnEncode() const { return m_flushOnEncode; }
+ void setFlushOnEncode(bool state) { m_flushOnEncode = state; }
int setAttribute(const std::string &line, size_t lc);
private:
@@ -57,6 +59,7 @@ private:
bool m_unsupported;
bool m_customDecoder;
bool m_notApi;
+ bool m_flushOnEncode;
void err(unsigned int lc, const char *msg) {
fprintf(stderr, "line %d: %s\n", lc, msg);
diff --git a/emulator/opengl/host/tools/emugen/tests/run-tests.sh b/emulator/opengl/host/tools/emugen/tests/run-tests.sh
new file mode 100755
index 000000000..67409edcc
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/run-tests.sh
@@ -0,0 +1,129 @@
+#!/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
+}
+
+OPT_EMUGEN=
+OPT_HELP=
+OPT_OUT_DIR=
+OPT_TOOL=
+
+for OPT; do
+ OPTARG=$(expr "x$OPT" : "x[^=]*=\\(.*\\)" || true)
+ case $OPT in
+ --help|-h|-?)
+ OPT_HELP=true
+ ;;
+ --emugen=*)
+ OPT_EMUGEN=$OPTARG
+ ;;
+ --out-dir=*)
+ OPT_OUT_DIR=$OPTARG
+ ;;
+ --tool=*)
+ OPT_TOOL=$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]
+
+Run the emugen test suite. This scripts looks for sub-directories
+named t.<number>/input, and uses them as input to 'emugen'. It then
+compares the output to t.<number>/expected/ content.
+
+Valid options:
+ --help|-h|-? Print this help.
+ --out-dir=<dir> Generate outputs into <dir>.
+ --emugen=<program> Emugen program path, if not in path.
+ --tool=<tool> Launch visual diff tool in case of differences.
+EOF
+ exit 0
+fi
+
+# Find emugen program
+EMUGEN=
+if [ "$OPT_EMUGEN" ]; then
+ EMUGEN=$OPT_EMUGEN
+else
+ EMUGEN=$(which emugen 2>/dev/null || true)
+ if [ -z "$EMUGEN" ]; then
+ fatal "Cannot find 'emugen' program in PATH, use --emugen=<program> option."
+ fi
+ echo "Auto-config: --emugen=$EMUGEN"
+fi
+if [ ! -f "$EMUGEN" ]; then
+ fatal "Emugen program doesn't exist: $EMUGEN"
+fi
+
+# Create output directory.
+OUT_DIR=
+if [ "$OPT_OUT_DIR" ]; then
+ OUT_DIR=$OPT_OUT_DIR
+else
+ OUT_DIR=/tmp/$USER-emugen-testing
+ echo "Auto-config: --out-dir=$OUT_DIR"
+fi
+mkdir -p "$OUT_DIR" && rm -rf "$OUT_DIR/emugen"
+
+OUT_DIR=$OUT_DIR/emugen
+
+# Find test directories
+TEST_DIRS=$(cd "$PROGDIR" && find . -name "t.*" | sed -e 's|^\./||')
+for TEST_DIR in $TEST_DIRS; do
+ IN=$PROGDIR/$TEST_DIR/input
+ PREFIXES=$(cd $IN && find . -name "*.in" | sed -e 's|^\./||g' -e 's|\.in$||g')
+ OUT=$OUT_DIR/$TEST_DIR
+ mkdir -p "$OUT/encoder"
+ mkdir -p "$OUT/decoder"
+ mkdir -p "$OUT/wrapper"
+ for PREFIX in $PREFIXES; do
+ echo "Processing $IN/foo.*"
+ $EMUGEN -i "$PROGDIR/$TEST_DIR/input" -D "$OUT/decoder" -E "$OUT/encoder" -W "$OUT/wrapper" $PREFIX
+ done
+ if ! diff -qr "$PROGDIR/$TEST_DIR/expected" "$OUT"; then
+ if [ "$OPT_TOOL" ]; then
+ $OPT_TOOL "$PROGDIR/$TEST_DIR/expected" "$OUT"
+ else
+ echo "ERROR: Invalid differences between actual and expected output!"
+ diff -burN "$PROGDIR/$TEST_DIR/expected" "$OUT"
+ exit 1
+ fi
+ fi
+done
+
+echo "All good!"
+exit 0
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.cpp b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.cpp
new file mode 100644
index 000000000..d56653fb5
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.cpp
@@ -0,0 +1,89 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+
+
+#include <string.h>
+#include "foo_opcodes.h"
+
+#include "foo_dec.h"
+
+
+#include "ProtocolUtils.h"
+
+#include <stdio.h>
+
+typedef unsigned int tsize_t; // Target "size_t", which is 32-bit for now. It may or may not be the same as host's size_t when emugen is compiled.
+
+#ifdef DEBUG_PRINTOUT
+# define DEBUG(...) fprintf(stderr, __VA_ARGS__)
+#else
+# define DEBUG(...) ((void)0)
+#endif
+
+#ifdef CHECK_GLERROR
+# define SET_LASTCALL(name) sprintf(lastCall, #name)
+#else
+# define SET_LASTCALL(name) ((void)0)
+#endif
+
+using namespace emugl;
+
+size_t foo_decoder_context_t::decode(void *buf, size_t len, IOStream *stream)
+{
+
+ size_t pos = 0;
+ if (len < 8) return pos;
+ unsigned char *ptr = (unsigned char *)buf;
+ bool unknownOpcode = false;
+#ifdef CHECK_GL_ERROR
+ char lastCall[256] = {0};
+#endif
+ while ((len - pos >= 8) && !unknownOpcode) {
+ uint32_t opcode = *(uint32_t *)ptr;
+ size_t packetLen = *(uint32_t *)(ptr + 4);
+ if (len - pos < packetLen) return pos;
+ switch(opcode) {
+ case OP_fooAlphaFunc: {
+ FooInt var_func = Unpack<FooInt,uint32_t>(ptr + 8);
+ FooFloat var_ref = Unpack<FooFloat,uint32_t>(ptr + 8 + 4);
+ DEBUG("foo(%p): fooAlphaFunc(%d %f )\n", stream,var_func, var_ref);
+ this->fooAlphaFunc(var_func, var_ref);
+ SET_LASTCALL("fooAlphaFunc");
+ break;
+ }
+ case OP_fooIsBuffer: {
+ uint32_t size_stuff __attribute__((unused)) = Unpack<uint32_t,uint32_t>(ptr + 8);
+ InputBuffer inptr_stuff(ptr + 8 + 4, size_stuff);
+ size_t totalTmpSize = sizeof(FooBoolean);
+ unsigned char *tmpBuf = stream->alloc(totalTmpSize);
+ DEBUG("foo(%p): fooIsBuffer(%p(%u) )\n", stream,(void*)(inptr_stuff.get()), size_stuff);
+ *(FooBoolean *)(&tmpBuf[0]) = this->fooIsBuffer((void*)(inptr_stuff.get()));
+ stream->flush();
+ SET_LASTCALL("fooIsBuffer");
+ break;
+ }
+ case OP_fooUnsupported: {
+ uint32_t size_params __attribute__((unused)) = Unpack<uint32_t,uint32_t>(ptr + 8);
+ InputBuffer inptr_params(ptr + 8 + 4, size_params);
+ DEBUG("foo(%p): fooUnsupported(%p(%u) )\n", stream,(void*)(inptr_params.get()), size_params);
+ this->fooUnsupported((void*)(inptr_params.get()));
+ SET_LASTCALL("fooUnsupported");
+ break;
+ }
+ case OP_fooDoEncoderFlush: {
+ FooInt var_param = Unpack<FooInt,uint32_t>(ptr + 8);
+ DEBUG("foo(%p): fooDoEncoderFlush(%d )\n", stream,var_param);
+ this->fooDoEncoderFlush(var_param);
+ SET_LASTCALL("fooDoEncoderFlush");
+ break;
+ }
+ default:
+ unknownOpcode = true;
+ } //switch
+ if (!unknownOpcode) {
+ pos += packetLen;
+ ptr += packetLen;
+ }
+ } // while
+ return pos;
+}
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.h
new file mode 100644
index 000000000..3646de53a
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.h
@@ -0,0 +1,18 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+
+#ifndef GUARD_foo_decoder_context_t
+#define GUARD_foo_decoder_context_t
+
+#include "IOStream.h"
+#include "foo_server_context.h"
+
+
+
+struct foo_decoder_context_t : public foo_server_context_t {
+
+ size_t decode(void *buf, size_t bufsize, IOStream *stream);
+
+};
+
+#endif // GUARD_foo_decoder_context_t
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_opcodes.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_opcodes.h
new file mode 100644
index 000000000..154f2e1e2
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_opcodes.h
@@ -0,0 +1,13 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+#ifndef __GUARD_foo_opcodes_h_
+#define __GUARD_foo_opcodes_h_
+
+#define OP_fooAlphaFunc 200
+#define OP_fooIsBuffer 201
+#define OP_fooUnsupported 202
+#define OP_fooDoEncoderFlush 203
+#define OP_last 204
+
+
+#endif
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.cpp b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.cpp
new file mode 100644
index 000000000..e310e2f26
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.cpp
@@ -0,0 +1,19 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+
+
+#include <string.h>
+#include "foo_server_context.h"
+
+
+#include <stdio.h>
+
+int foo_server_context_t::initDispatchByName(void *(*getProc)(const char *, void *userData), void *userData)
+{
+ fooAlphaFunc = (fooAlphaFunc_server_proc_t) getProc("fooAlphaFunc", userData);
+ fooIsBuffer = (fooIsBuffer_server_proc_t) getProc("fooIsBuffer", userData);
+ fooUnsupported = (fooUnsupported_server_proc_t) getProc("fooUnsupported", userData);
+ fooDoEncoderFlush = (fooDoEncoderFlush_server_proc_t) getProc("fooDoEncoderFlush", userData);
+ return 0;
+}
+
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.h
new file mode 100644
index 000000000..3cc0fd5d5
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.h
@@ -0,0 +1,19 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+#ifndef __foo_server_context_t_h
+#define __foo_server_context_t_h
+
+#include "foo_server_proc.h"
+
+
+struct foo_server_context_t {
+
+ fooAlphaFunc_server_proc_t fooAlphaFunc;
+ fooIsBuffer_server_proc_t fooIsBuffer;
+ fooUnsupported_server_proc_t fooUnsupported;
+ fooDoEncoderFlush_server_proc_t fooDoEncoderFlush;
+ virtual ~foo_server_context_t() {}
+ int initDispatchByName( void *(*getProc)(const char *name, void *userData), void *userData);
+};
+
+#endif
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_proc.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_proc.h
new file mode 100644
index 000000000..e67ea2a64
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_proc.h
@@ -0,0 +1,18 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+#ifndef __foo_server_proc_t_h
+#define __foo_server_proc_t_h
+
+
+
+#include "foo_types.h"
+#ifndef foo_APIENTRY
+#define foo_APIENTRY
+#endif
+typedef void (foo_APIENTRY *fooAlphaFunc_server_proc_t) (FooInt, FooFloat);
+typedef FooBoolean (foo_APIENTRY *fooIsBuffer_server_proc_t) (void*);
+typedef void (foo_APIENTRY *fooUnsupported_server_proc_t) (void*);
+typedef void (foo_APIENTRY *fooDoEncoderFlush_server_proc_t) (FooInt);
+
+
+#endif
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.cpp b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.cpp
new file mode 100644
index 000000000..70a5f645a
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.cpp
@@ -0,0 +1,19 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+
+
+#include <string.h>
+#include "foo_client_context.h"
+
+
+#include <stdio.h>
+
+int foo_client_context_t::initDispatchByName(void *(*getProc)(const char *, void *userData), void *userData)
+{
+ fooAlphaFunc = (fooAlphaFunc_client_proc_t) getProc("fooAlphaFunc", userData);
+ fooIsBuffer = (fooIsBuffer_client_proc_t) getProc("fooIsBuffer", userData);
+ fooUnsupported = (fooUnsupported_client_proc_t) getProc("fooUnsupported", userData);
+ fooDoEncoderFlush = (fooDoEncoderFlush_client_proc_t) getProc("fooDoEncoderFlush", userData);
+ return 0;
+}
+
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.h
new file mode 100644
index 000000000..2dfc76a0f
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.h
@@ -0,0 +1,24 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+#ifndef __foo_client_context_t_h
+#define __foo_client_context_t_h
+
+#include "foo_client_proc.h"
+
+
+struct foo_client_context_t {
+
+ fooAlphaFunc_client_proc_t fooAlphaFunc;
+ fooIsBuffer_client_proc_t fooIsBuffer;
+ fooUnsupported_client_proc_t fooUnsupported;
+ fooDoEncoderFlush_client_proc_t fooDoEncoderFlush;
+ virtual ~foo_client_context_t() {}
+
+ typedef foo_client_context_t *CONTEXT_ACCESSOR_TYPE(void);
+ static void setContextAccessor(CONTEXT_ACCESSOR_TYPE *f);
+ int initDispatchByName( void *(*getProc)(const char *name, void *userData), void *userData);
+ virtual void setError(unsigned int error){ (void)error; };
+ virtual unsigned int getError(){ return 0; };
+};
+
+#endif
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_proc.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_proc.h
new file mode 100644
index 000000000..d39b73a3b
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_proc.h
@@ -0,0 +1,18 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+#ifndef __foo_client_proc_t_h
+#define __foo_client_proc_t_h
+
+
+
+#include "foo_types.h"
+#ifndef foo_APIENTRY
+#define foo_APIENTRY
+#endif
+typedef void (foo_APIENTRY *fooAlphaFunc_client_proc_t) (void * ctx, FooInt, FooFloat);
+typedef FooBoolean (foo_APIENTRY *fooIsBuffer_client_proc_t) (void * ctx, void*);
+typedef void (foo_APIENTRY *fooUnsupported_client_proc_t) (void * ctx, void*);
+typedef void (foo_APIENTRY *fooDoEncoderFlush_client_proc_t) (void * ctx, FooInt);
+
+
+#endif
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.cpp b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.cpp
new file mode 100644
index 000000000..5e1758e33
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.cpp
@@ -0,0 +1,84 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+
+
+#include <string.h>
+#include "foo_opcodes.h"
+
+#include "foo_enc.h"
+
+
+#include <stdio.h>
+
+namespace {
+
+void enc_unsupported()
+{
+ ALOGE("Function is unsupported\n");
+}
+
+void fooAlphaFunc_enc(void *self , FooInt func, FooFloat ref)
+{
+
+ foo_encoder_context_t *ctx = (foo_encoder_context_t *)self;
+ IOStream *stream = ctx->m_stream;
+
+ unsigned char *ptr;
+ const size_t packetSize = 8 + 4 + 4;
+ ptr = stream->alloc(packetSize);
+ int tmp = OP_fooAlphaFunc;memcpy(ptr, &tmp, 4); ptr += 4;
+ memcpy(ptr, &packetSize, 4); ptr += 4;
+
+ memcpy(ptr, &func, 4); ptr += 4;
+ memcpy(ptr, &ref, 4); ptr += 4;
+}
+
+FooBoolean fooIsBuffer_enc(void *self , void* stuff)
+{
+
+ foo_encoder_context_t *ctx = (foo_encoder_context_t *)self;
+ IOStream *stream = ctx->m_stream;
+
+ const unsigned int __size_stuff = (4 * sizeof(float));
+ unsigned char *ptr;
+ const size_t packetSize = 8 + __size_stuff + 1*4;
+ ptr = stream->alloc(packetSize);
+ int tmp = OP_fooIsBuffer;memcpy(ptr, &tmp, 4); ptr += 4;
+ memcpy(ptr, &packetSize, 4); ptr += 4;
+
+ *(unsigned int *)(ptr) = __size_stuff; ptr += 4;
+ memcpy(ptr, stuff, __size_stuff);ptr += __size_stuff;
+
+ FooBoolean retval;
+ stream->readback(&retval, 1);
+ return retval;
+}
+
+void fooDoEncoderFlush_enc(void *self , FooInt param)
+{
+
+ foo_encoder_context_t *ctx = (foo_encoder_context_t *)self;
+ IOStream *stream = ctx->m_stream;
+
+ unsigned char *ptr;
+ const size_t packetSize = 8 + 4;
+ ptr = stream->alloc(packetSize);
+ int tmp = OP_fooDoEncoderFlush;memcpy(ptr, &tmp, 4); ptr += 4;
+ memcpy(ptr, &packetSize, 4); ptr += 4;
+
+ memcpy(ptr, &param, 4); ptr += 4;
+ stream->flush();
+}
+
+} // namespace
+
+foo_encoder_context_t::foo_encoder_context_t(IOStream *stream)
+{
+ m_stream = stream;
+
+ this->fooAlphaFunc = &fooAlphaFunc_enc;
+ this->fooIsBuffer = &fooIsBuffer_enc;
+ this->fooUnsupported = (fooUnsupported_client_proc_t) &enc_unsupported;
+ this->fooDoEncoderFlush = &fooDoEncoderFlush_enc;
+}
+
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.h
new file mode 100644
index 000000000..195b37a25
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.h
@@ -0,0 +1,21 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+
+#ifndef GUARD_foo_encoder_context_t
+#define GUARD_foo_encoder_context_t
+
+#include "IOStream.h"
+#include "foo_client_context.h"
+
+
+#include "fooUtils.h"
+#include "fooBase.h"
+
+struct foo_encoder_context_t : public foo_client_context_t {
+
+ IOStream *m_stream;
+
+ foo_encoder_context_t(IOStream *stream);
+};
+
+#endif // GUARD_foo_encoder_context_t \ No newline at end of file
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_entry.cpp b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_entry.cpp
new file mode 100644
index 000000000..697f143a9
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_entry.cpp
@@ -0,0 +1,46 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+#include <stdio.h>
+#include <stdlib.h>
+#include "foo_client_context.h"
+
+#ifndef GL_TRUE
+extern "C" {
+ void fooAlphaFunc(FooInt func, FooFloat ref);
+ FooBoolean fooIsBuffer(void* stuff);
+ void fooUnsupported(void* params);
+ void fooDoEncoderFlush(FooInt param);
+};
+
+#endif
+#ifndef GET_CONTEXT
+static foo_client_context_t::CONTEXT_ACCESSOR_TYPE *getCurrentContext = NULL;
+void foo_client_context_t::setContextAccessor(CONTEXT_ACCESSOR_TYPE *f) { getCurrentContext = f; }
+#define GET_CONTEXT foo_client_context_t * ctx = getCurrentContext()
+#endif
+
+void fooAlphaFunc(FooInt func, FooFloat ref)
+{
+ GET_CONTEXT;
+ ctx->fooAlphaFunc(ctx, func, ref);
+}
+
+FooBoolean fooIsBuffer(void* stuff)
+{
+ GET_CONTEXT;
+ if (n == NULL) { LOG(ERROR) << "NULL stuff"; return; }
+ return ctx->fooIsBuffer(ctx, stuff);
+}
+
+void fooUnsupported(void* params)
+{
+ GET_CONTEXT;
+ ctx->fooUnsupported(ctx, params);
+}
+
+void fooDoEncoderFlush(FooInt param)
+{
+ GET_CONTEXT;
+ ctx->fooDoEncoderFlush(ctx, param);
+}
+
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_ftable.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_ftable.h
new file mode 100644
index 000000000..cba476bec
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_ftable.h
@@ -0,0 +1,19 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+#ifndef __foo_client_ftable_t_h
+#define __foo_client_ftable_t_h
+
+
+static const struct _foo_funcs_by_name {
+ const char *name;
+ void *proc;
+} foo_funcs_by_name[] = {
+ {"fooAlphaFunc", (void*)fooAlphaFunc},
+ {"fooIsBuffer", (void*)fooIsBuffer},
+ {"fooUnsupported", (void*)fooUnsupported},
+ {"fooDoEncoderFlush", (void*)fooDoEncoderFlush},
+};
+static const int foo_num_funcs = sizeof(foo_funcs_by_name) / sizeof(struct _foo_funcs_by_name);
+
+
+#endif
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_opcodes.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_opcodes.h
new file mode 100644
index 000000000..154f2e1e2
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_opcodes.h
@@ -0,0 +1,13 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+#ifndef __GUARD_foo_opcodes_h_
+#define __GUARD_foo_opcodes_h_
+
+#define OP_fooAlphaFunc 200
+#define OP_fooIsBuffer 201
+#define OP_fooUnsupported 202
+#define OP_fooDoEncoderFlush 203
+#define OP_last 204
+
+
+#endif
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.cpp b/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.cpp
new file mode 100644
index 000000000..46eb6ceb4
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.cpp
@@ -0,0 +1,19 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+
+
+#include <string.h>
+#include "foo_wrapper_context.h"
+
+
+#include <stdio.h>
+
+int foo_wrapper_context_t::initDispatchByName(void *(*getProc)(const char *, void *userData), void *userData)
+{
+ fooAlphaFunc = (fooAlphaFunc_wrapper_proc_t) getProc("fooAlphaFunc", userData);
+ fooIsBuffer = (fooIsBuffer_wrapper_proc_t) getProc("fooIsBuffer", userData);
+ fooUnsupported = (fooUnsupported_wrapper_proc_t) getProc("fooUnsupported", userData);
+ fooDoEncoderFlush = (fooDoEncoderFlush_wrapper_proc_t) getProc("fooDoEncoderFlush", userData);
+ return 0;
+}
+
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.h
new file mode 100644
index 000000000..166be4453
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.h
@@ -0,0 +1,22 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+#ifndef __foo_wrapper_context_t_h
+#define __foo_wrapper_context_t_h
+
+#include "foo_wrapper_proc.h"
+
+
+struct foo_wrapper_context_t {
+
+ fooAlphaFunc_wrapper_proc_t fooAlphaFunc;
+ fooIsBuffer_wrapper_proc_t fooIsBuffer;
+ fooUnsupported_wrapper_proc_t fooUnsupported;
+ fooDoEncoderFlush_wrapper_proc_t fooDoEncoderFlush;
+ virtual ~foo_wrapper_context_t() {}
+
+ typedef foo_wrapper_context_t *CONTEXT_ACCESSOR_TYPE(void);
+ static void setContextAccessor(CONTEXT_ACCESSOR_TYPE *f);
+ int initDispatchByName( void *(*getProc)(const char *name, void *userData), void *userData);
+};
+
+#endif
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_entry.cpp b/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_entry.cpp
new file mode 100644
index 000000000..2e32e9ca0
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_entry.cpp
@@ -0,0 +1,45 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+#include <stdio.h>
+#include <stdlib.h>
+#include "foo_wrapper_context.h"
+
+#ifndef GL_TRUE
+extern "C" {
+ void fooAlphaFunc(FooInt func, FooFloat ref);
+ FooBoolean fooIsBuffer(void* stuff);
+ void fooUnsupported(void* params);
+ void fooDoEncoderFlush(FooInt param);
+};
+
+#endif
+#ifndef GET_CONTEXT
+static foo_wrapper_context_t::CONTEXT_ACCESSOR_TYPE *getCurrentContext = NULL;
+void foo_wrapper_context_t::setContextAccessor(CONTEXT_ACCESSOR_TYPE *f) { getCurrentContext = f; }
+#define GET_CONTEXT foo_wrapper_context_t * ctx = getCurrentContext()
+#endif
+
+void fooAlphaFunc(FooInt func, FooFloat ref)
+{
+ GET_CONTEXT;
+ ctx->fooAlphaFunc( func, ref);
+}
+
+FooBoolean fooIsBuffer(void* stuff)
+{
+ GET_CONTEXT;
+ return ctx->fooIsBuffer( stuff);
+}
+
+void fooUnsupported(void* params)
+{
+ GET_CONTEXT;
+ ctx->fooUnsupported( params);
+}
+
+void fooDoEncoderFlush(FooInt param)
+{
+ GET_CONTEXT;
+ ctx->fooDoEncoderFlush( param);
+}
+
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_proc.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_proc.h
new file mode 100644
index 000000000..2fafa24d0
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_proc.h
@@ -0,0 +1,18 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+#ifndef __foo_wrapper_proc_t_h
+#define __foo_wrapper_proc_t_h
+
+
+
+#include "foo_types.h"
+#ifndef foo_APIENTRY
+#define foo_APIENTRY
+#endif
+typedef void (foo_APIENTRY *fooAlphaFunc_wrapper_proc_t) (FooInt, FooFloat);
+typedef FooBoolean (foo_APIENTRY *fooIsBuffer_wrapper_proc_t) (void*);
+typedef void (foo_APIENTRY *fooUnsupported_wrapper_proc_t) (void*);
+typedef void (foo_APIENTRY *fooDoEncoderFlush_wrapper_proc_t) (FooInt);
+
+
+#endif
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.attrib b/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.attrib
new file mode 100644
index 000000000..80644d8bb
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.attrib
@@ -0,0 +1,15 @@
+GLOBAL
+ base_opcode 200
+ encoder_headers "fooUtils.h" "fooBase.h"
+
+fooIsBuffer
+ dir stuff in
+ len stuff (4 * sizeof(float))
+ param_check stuff if (n == NULL) { LOG(ERROR) << "NULL stuff"; return; }
+
+fooUnsupported
+ dir params in
+ flag unsupported
+
+fooDoEncoderFlush
+ flag flushOnEncode
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.in b/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.in
new file mode 100644
index 000000000..e61fe572a
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.in
@@ -0,0 +1,4 @@
+FOO_ENTRY(void, fooAlphaFunc, FooInt func, FooFloat ref)
+FOO_ENTRY(FooBoolean, fooIsBuffer, void* stuff)
+FOO_ENTRY(void, fooUnsupported, void* params)
+FOO_ENTRY(void, fooDoEncoderFlush, FooInt param)
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.types b/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.types
new file mode 100644
index 000000000..c4140d197
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.types
@@ -0,0 +1,9 @@
+FooBoolean 8 %d
+FooInt 32 %d
+FooShort 16 %d
+FooFloat 32 %f
+FooEnum 32 %08x
+FooVoid 0 %x
+FooChar 8 %d
+FooChar* 32 0x%08x
+void* 32 0x%08x \ No newline at end of file