Skip to content

Commit

Permalink
Revert "Fix emscripten_GetProcAddress with various suffixes (emscript…
Browse files Browse the repository at this point in the history
…en-core#8430)"

This reverts commit c814f17.
  • Loading branch information
VirtualTim authored May 23, 2019
1 parent e37715d commit 4fc42ed
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 71 deletions.
1 change: 0 additions & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,5 @@ a license to everyone to use it as detailed in LICENSE.)
* Timothy Trindle <[email protected]> (copyright owned by Microsoft, Inc.)
* Matthew Andres Moreno <[email protected]>
* Eric Mandel <[email protected]>
* Anthony Catel <[email protected]>
* Simon Cooper <[email protected]>
* Amir Rasouli <[email protected]>
14 changes: 6 additions & 8 deletions system/lib/gl/gl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1570,9 +1570,7 @@ GLAPI void APIENTRY emscripten_glGetInfoLog (GLhandleARB obj, GLsizei maxLength,
GLAPI void APIENTRY emscripten_glBindProgram (GLenum target, GLuint program);

extern void *emscripten_webgl1_get_proc_address(const char *name);
extern void *emscripten_webgl1_ext_get_proc_address(const char *name);
extern void *emscripten_webgl2_get_proc_address(const char *name);
extern void *emscripten_webgl2_ext_get_proc_address(const char *name);

#ifdef LEGACY_GL_EMULATION

Expand Down Expand Up @@ -1796,7 +1794,12 @@ for line in open('a').readlines():
// behavior: different functionality is available under
// different vendor suffixes. In emscripten_GetProcAddress()
// function, all these suffixes will be ignored when performing
// the function pointer lookup.
// the function pointer lookup. The functions
// emscripten_webgl_get_proc_address(),
// emscripten_webgl1_get_proc_address() and
// emscripten_webgl2_get_proc_address() however are "strict"
// lookups, that provide WebGL specific function entry points that
// look up the exact function name with suffixes.
void* emscripten_GetProcAddress(const char *name_) {
char *name = malloc(strlen(name_)+1);
strcpy(name, name_);
Expand All @@ -1809,19 +1812,14 @@ void* emscripten_GetProcAddress(const char *name_) {
if (end) *end = 0;
end = strstr(name, "ANGLE");
if (end) *end = 0;
end = strstr(name, "WEBGL");
if (end) *end = 0;

void *ptr = emscripten_webgl1_get_proc_address(name);

if (!ptr) ptr = emscripten_webgl1_ext_get_proc_address(name);

#if LEGACY_GL_EMULATION
if (!ptr) ptr = emscripten_legacy_gl_emulation_GetProcAddress(name);
#endif
#if USE_WEBGL2
if (!ptr) ptr = emscripten_webgl2_get_proc_address(name);
if (!ptr) ptr = emscripten_webgl2_ext_get_proc_address(name);
#endif

free(name);
Expand Down
38 changes: 0 additions & 38 deletions system/lib/gl/webgl1.c
Original file line number Diff line number Diff line change
Expand Up @@ -627,44 +627,6 @@ RET_SYNC_GL_FUNCTION_3(EM_FUNC_SIG_VIII, void, glGetQueryObjectui64vEXT, GLenum,

#endif // ~__EMSCRIPTEN_PTHREADS__

void *emscripten_webgl1_ext_get_proc_address(const char *name)
{
RETURN_FN_WITH_SUFFIX(glGenQueries, EXT);
RETURN_FN_WITH_SUFFIX(glDeleteQueries, EXT);
RETURN_FN_WITH_SUFFIX(glIsQuery, EXT);
RETURN_FN_WITH_SUFFIX(glBeginQuery, EXT);
RETURN_FN_WITH_SUFFIX(glEndQuery, EXT);
RETURN_FN_WITH_SUFFIX(glQueryCounter, EXT);
RETURN_FN_WITH_SUFFIX(glGetQueryiv, EXT);
RETURN_FN_WITH_SUFFIX(glGetQueryObjectiv, EXT);
RETURN_FN_WITH_SUFFIX(glGetQueryObjectuiv, EXT);
RETURN_FN_WITH_SUFFIX(glGetQueryObjecti64v, EXT);
RETURN_FN_WITH_SUFFIX(glGetQueryObjectui64v, EXT);

// WebGL 1 , Extensions
RETURN_FN_WITH_SUFFIX(glBindVertexArray, OES);
RETURN_FN_WITH_SUFFIX(glDeleteVertexArrays, OES);
RETURN_FN_WITH_SUFFIX(glGenVertexArrays, OES);
RETURN_FN_WITH_SUFFIX(glIsVertexArray, OES);
RETURN_FN_WITH_SUFFIX(glDrawBuffers, WEBGL);
RETURN_FN_WITH_SUFFIX(glDrawArraysInstanced, ANGLE);
RETURN_FN_WITH_SUFFIX(glDrawElementsInstanced, ANGLE);
RETURN_FN_WITH_SUFFIX(glVertexAttribDivisor, ANGLE);
RETURN_FN_WITH_SUFFIX(glGenQueries, EXT);
RETURN_FN_WITH_SUFFIX(glDeleteQueries, EXT);
RETURN_FN_WITH_SUFFIX(glIsQuery, EXT);
RETURN_FN_WITH_SUFFIX(glBeginQuery, EXT);
RETURN_FN_WITH_SUFFIX(glEndQuery, EXT);
RETURN_FN_WITH_SUFFIX(glQueryCounter, EXT);
RETURN_FN_WITH_SUFFIX(glGetQueryiv, EXT);
RETURN_FN_WITH_SUFFIX(glGetQueryObjectiv, EXT);
RETURN_FN_WITH_SUFFIX(glGetQueryObjectuiv, EXT);
RETURN_FN_WITH_SUFFIX(glGetQueryObjecti64v, EXT);
RETURN_FN_WITH_SUFFIX(glGetQueryObjectui64v, EXT);

return 0;
}

void *emscripten_webgl1_get_proc_address(const char *name)
{
RETURN_FN(glActiveTexture);
Expand Down
2 changes: 0 additions & 2 deletions system/lib/gl/webgl1.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,11 @@ extern pthread_key_t currentThreadOwnsItsWebGLContext;

// When building with multithreading, return pointers to C functions that can perform proxying.
#define RETURN_FN(functionName) if (!strcmp(name, #functionName)) return functionName;
#define RETURN_FN_WITH_SUFFIX(functionName, suffix) if (!strcmp(name, #functionName)) return functionName##suffix;

#else

// When building with singlethreading, return pointers to JS library layer so that C code (Regal library)
// can override them.
#define RETURN_FN(functionName) if (!strcmp(name, #functionName)) return emscripten_##functionName;
#define RETURN_FN_WITH_SUFFIX(functionName, suffix) if (!strcmp(name, #functionName)) return emscripten_##functionName##suffix;

#endif
22 changes: 0 additions & 22 deletions system/lib/gl/webgl2.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,28 +147,6 @@ GL_APICALL GLboolean GL_APIENTRY glIsVertexArrayOES(GLuint array) { return glIsV
GL_APICALL void GL_APIENTRY glDrawBuffersEXT(GLsizei n, const GLenum *bufs) { glDrawBuffers(n, bufs); }
GL_APICALL void GL_APIENTRY glDrawBuffersWEBGL(GLsizei n, const GLenum *bufs) { glDrawBuffers(n, bufs); }

void *emscripten_webgl2_ext_get_proc_address(const char *name)
{
RETURN_FN_WITH_SUFFIX(glVertexAttribDivisor, EXT);
RETURN_FN_WITH_SUFFIX(glVertexAttribDivisor, ARB);
RETURN_FN_WITH_SUFFIX(glVertexAttribDivisor, ANGLE);
RETURN_FN_WITH_SUFFIX(glDrawArraysInstanced, EXT);
RETURN_FN_WITH_SUFFIX(glDrawArraysInstanced, ARB);
RETURN_FN_WITH_SUFFIX(glDrawArraysInstanced, ANGLE);
RETURN_FN_WITH_SUFFIX(glDrawElementsInstanced, NV);
RETURN_FN_WITH_SUFFIX(glDrawElementsInstanced, EXT);
RETURN_FN_WITH_SUFFIX(glDrawElementsInstanced, ARB);
RETURN_FN_WITH_SUFFIX(glDrawElementsInstanced, ANGLE);
RETURN_FN_WITH_SUFFIX(glBindVertexArray, OES);
RETURN_FN_WITH_SUFFIX(glDeleteVertexArrays, OES);
RETURN_FN_WITH_SUFFIX(glGenVertexArrays, OES);
RETURN_FN_WITH_SUFFIX(glIsVertexArray, OES);
RETURN_FN_WITH_SUFFIX(glDrawBuffers, EXT);
RETURN_FN_WITH_SUFFIX(glDrawBuffers, WEBGL);

return 0;
}

void *emscripten_webgl2_get_proc_address(const char *name)
{
RETURN_FN(glReadBuffer);
Expand Down

0 comments on commit 4fc42ed

Please sign in to comment.