am b9cbdec5: Merge "emulator opengl: implemented getProcAddress in GLESv1."
* commit 'b9cbdec58ed9a5d78645fb200e58a8f32f59381b': emulator opengl: implemented getProcAddress in GLESv1.
This commit is contained in:
@@ -79,6 +79,38 @@ int ApiGen::genProcTypes(const std::string &filename, SideType side)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ApiGen::genFuncTable(const std::string &filename, SideType side)
|
||||
{
|
||||
FILE *fp = fopen(filename.c_str(), "wt");
|
||||
if (fp == NULL) {
|
||||
perror(filename.c_str());
|
||||
return -1;
|
||||
}
|
||||
printHeader(fp);
|
||||
|
||||
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,
|
||||
"\tconst char *name;\n" \
|
||||
"\tvoid *proc;\n" \
|
||||
"} %s_funcs_by_name[] = {\n", m_basename.c_str());
|
||||
|
||||
|
||||
for (size_t i = 0; i < size(); i++) {
|
||||
EntryPoint *e = &at(i);
|
||||
if (e->notApi()) continue;
|
||||
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",
|
||||
m_basename.c_str(), m_basename.c_str(), m_basename.c_str());
|
||||
fprintf(fp, "\n\n#endif\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int ApiGen::genContext(const std::string & filename, SideType side)
|
||||
{
|
||||
FILE *fp = fopen(filename.c_str(), "wt");
|
||||
|
||||
@@ -67,6 +67,7 @@ public:
|
||||
int genOpcodes(const std::string &filename);
|
||||
int genAttributesTemplate(const std::string &filename);
|
||||
int genProcTypes(const std::string &filename, SideType side);
|
||||
int genFuncTable(const std::string &filename, SideType side);
|
||||
|
||||
int genContext(const std::string &filename, SideType side);
|
||||
int genContextImpl(const std::string &filename, SideType side);
|
||||
|
||||
@@ -34,6 +34,7 @@ void EntryPoint::reset()
|
||||
{
|
||||
m_unsupported = false;
|
||||
m_customDecoder = false;
|
||||
m_notApi = false;
|
||||
m_vars.empty();
|
||||
}
|
||||
|
||||
@@ -313,6 +314,8 @@ int EntryPoint::setAttribute(const std::string &line, size_t lc)
|
||||
setUnsupported(true);
|
||||
} else if (flag == "custom_decoder") {
|
||||
setCustomDecoder(true);
|
||||
} else if (flag == "not_api") {
|
||||
setNotApi(true);
|
||||
} else {
|
||||
fprintf(stderr, "WARNING: %u: unknown flag %s\n", (unsigned int)lc, flag.c_str());
|
||||
}
|
||||
|
||||
@@ -45,6 +45,8 @@ public:
|
||||
void setUnsupported(bool state) { m_unsupported = state; }
|
||||
bool customDecoder() { return m_customDecoder; }
|
||||
void setCustomDecoder(bool state) { m_customDecoder = state; }
|
||||
bool notApi() const { return m_notApi; }
|
||||
void setNotApi(bool state) { m_notApi = state; }
|
||||
int setAttribute(const std::string &line, size_t lc);
|
||||
|
||||
private:
|
||||
@@ -54,6 +56,7 @@ private:
|
||||
VarsArray m_vars;
|
||||
bool m_unsupported;
|
||||
bool m_customDecoder;
|
||||
bool m_notApi;
|
||||
|
||||
void err(unsigned int lc, const char *msg) {
|
||||
fprintf(stderr, "line %d: %s\n", lc, msg);
|
||||
|
||||
@@ -324,5 +324,6 @@ custom_pack
|
||||
custom implementation. The call to the
|
||||
deocder function includes a pointer to the
|
||||
context
|
||||
not_api - the function is not native gl api
|
||||
|
||||
|
||||
|
||||
@@ -125,6 +125,7 @@ int main(int argc, char *argv[])
|
||||
apiEntries.genContextImpl(encoderDir + "/" + baseName + "_client_context.cpp", ApiGen::CLIENT_SIDE);
|
||||
|
||||
apiEntries.genProcTypes(encoderDir + "/" + baseName + "_client_proc.h", ApiGen::CLIENT_SIDE);
|
||||
apiEntries.genFuncTable(encoderDir + "/" + baseName + "_ftable.h", ApiGen::CLIENT_SIDE);
|
||||
|
||||
apiEntries.genEntryPoints(encoderDir + "/" + baseName + "_entry.cpp", ApiGen::CLIENT_SIDE);
|
||||
apiEntries.genEncoderHeader(encoderDir + "/" + baseName + "_enc.h");
|
||||
|
||||
@@ -15,7 +15,7 @@ LOCAL_SRC_FILES := \
|
||||
|
||||
|
||||
LOCAL_PRELINK_MODULE := false
|
||||
LOCAL_CFLAGS += -DLOG_TAG=\"GLES_emulation\"
|
||||
LOCAL_CFLAGS += -DLOG_TAG=\"GLES_emulation\" -DGL_GLEXT_PROTOTYPES
|
||||
LOCAL_C_INCLUDES += \
|
||||
$(emulatorOpengl)/host/include/libOpenglRender \
|
||||
$(emulatorOpengl)/shared/OpenglCodecCommon \
|
||||
|
||||
@@ -1,19 +1,34 @@
|
||||
#include "EGLClientIface.h"
|
||||
#include "HostConnection.h"
|
||||
#include "GLEncoder.h"
|
||||
|
||||
#include "GLES/gl.h"
|
||||
#include "GLES/glext.h"
|
||||
|
||||
//XXX: fix this macro to get the context from fast tls path
|
||||
#define GET_CONTEXT gl_client_context_t * ctx = HostConnection::get()->glEncoder();
|
||||
|
||||
#include "gl_entry.cpp"
|
||||
|
||||
//The functions table
|
||||
#include "gl_ftable.h"
|
||||
|
||||
static EGLClient_eglInterface * s_egl = NULL;
|
||||
static EGLClient_glesInterface * s_gl = NULL;
|
||||
|
||||
void * getProcAddress(const char * procname)
|
||||
{
|
||||
// search in GL function table
|
||||
for (int i=0; i<gl_num_funcs; i++) {
|
||||
if (!strcmp(gl_funcs_by_name[i].name, procname)) {
|
||||
return gl_funcs_by_name[i].proc;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void finish()
|
||||
{
|
||||
|
||||
glFinish();
|
||||
}
|
||||
|
||||
EGLClient_glesInterface * init_emul_gles(EGLClient_eglInterface *eglIface)
|
||||
@@ -22,7 +37,7 @@ EGLClient_glesInterface * init_emul_gles(EGLClient_eglInterface *eglIface)
|
||||
|
||||
if (!s_gl) {
|
||||
s_gl = new EGLClient_glesInterface();
|
||||
s_gl->getProcAddress = NULL; //TODO: what goes here?
|
||||
s_gl->getProcAddress = getProcAddress;
|
||||
s_gl->finish = finish;
|
||||
}
|
||||
|
||||
|
||||
@@ -268,30 +268,35 @@ glVertexPointerData
|
||||
len data datalen
|
||||
custom_pack data glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, size, type, stride, datalen)
|
||||
flag custom_decoder
|
||||
flag not_api
|
||||
|
||||
#void glColorPointerData(GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen)
|
||||
glColorPointerData
|
||||
len data datalen
|
||||
flag custom_decoder
|
||||
custom_pack data glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, size, type, stride, datalen)
|
||||
flag not_api
|
||||
|
||||
#void glNormalPointerData(GLenum type, GLsizei stride, void *data, GLuint datalen)
|
||||
glNormalPointerData
|
||||
len data datalen
|
||||
flag custom_decoder
|
||||
custom_pack data glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, 3, type, stride, datalen)
|
||||
flag not_api
|
||||
|
||||
#void glPointSizePointerData(GLenum type, GLsizei stride, void *data, GLuint datalen)
|
||||
glPointSizePointerData
|
||||
len data datalen
|
||||
flag custom_decoder
|
||||
custom_pack data glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, 1, type, stride, datalen)
|
||||
flag not_api
|
||||
|
||||
#void glTexCoordPointerData(GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen)
|
||||
glTexCoordPointerData
|
||||
len data datalen
|
||||
flag custom_decoder
|
||||
custom_pack data glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, size, type, stride, datalen)
|
||||
flag not_api
|
||||
|
||||
#void glWeightPointerData(GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen)
|
||||
glWeightPointerData
|
||||
@@ -309,30 +314,40 @@ glMatrixIndexPointerData
|
||||
|
||||
glVertexPointerOffset
|
||||
flag custom_decoder
|
||||
flag not_api
|
||||
glNormalPointerOffset
|
||||
flag custom_decoder
|
||||
flag not_api
|
||||
glTexCoordPointerOffset
|
||||
flag custom_decoder
|
||||
flag not_api
|
||||
glPointSizePointerOffset
|
||||
flag custom_decoder
|
||||
flag not_api
|
||||
glColorPointerOffset
|
||||
flag custom_decoder
|
||||
flag not_api
|
||||
glWeightPointerOffset
|
||||
flag custom_decoder
|
||||
flag not_api
|
||||
glMatrixIndexPointerOffset
|
||||
flag custom_decoder
|
||||
flag not_api
|
||||
|
||||
glDrawElementsData
|
||||
len data datalen
|
||||
flag custom_decoder
|
||||
flag not_api
|
||||
|
||||
glDrawElementsOffset
|
||||
flag custom_decoder
|
||||
flag not_api
|
||||
|
||||
glGetCompressedTextureFormats
|
||||
dir formats out
|
||||
len formats (count * sizeof(GLint))
|
||||
flag custom_decoder
|
||||
flag not_api
|
||||
|
||||
|
||||
#gles1 extensions
|
||||
|
||||
@@ -76,7 +76,7 @@ GL_ENTRY(void, glFrontFace, GLenum mode)
|
||||
GL_ENTRY(void, glFrustumx, GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar)
|
||||
GL_ENTRY(void, glGetBooleanv, GLenum pname, GLboolean *params)
|
||||
GL_ENTRY(void, glGetBufferParameteriv, GLenum target, GLenum pname, GLint *params)
|
||||
GL_ENTRY(void, glClipPlanex, GLenum pname, GLfixed * eqn)
|
||||
GL_ENTRY(void, glClipPlanex, GLenum pname, const GLfixed * eqn)
|
||||
GL_ENTRY(void, glGenBuffers, GLsizei n, GLuint *buffers)
|
||||
GL_ENTRY(void, glGenTextures, GLsizei n, GLuint *textures)
|
||||
GL_ENTRY(GLenum, glGetError, void)
|
||||
@@ -248,7 +248,7 @@ GL_ENTRY(void, glDepthRangefOES, GLclampf zNear, GLclampf zFar)
|
||||
GL_ENTRY(void, glFrustumfOES, GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
|
||||
GL_ENTRY(void, glOrthofOES, GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
|
||||
GL_ENTRY(void, glClipPlanefOES, GLenum plane, const GLfloat *equation)
|
||||
GL_ENTRY(void, glClipPlanefIMG, GLenum plane, GLfloat *equation)
|
||||
GL_ENTRY(void, glClipPlanefIMG, GLenum plane, const GLfloat *equation)
|
||||
GL_ENTRY(void, glGetClipPlanefOES, GLenum pname, GLfloat * eqn)
|
||||
GL_ENTRY(void, glClearDepthfOES, GLclampf depth)
|
||||
GL_ENTRY(void, glTexGenfOES, GLenum coord, GLenum pname, GLfloat param)
|
||||
|
||||
Reference in New Issue
Block a user