From 708bf5de36608796e1046a58ada92f796156ac54 Mon Sep 17 00:00:00 2001 From: Jinhyung Jo Date: Thu, 7 Dec 2017 16:46:56 +0900 Subject: YaGL: hot fix web app broken issue on macOS. A bug in emulator-yagl causes a shader compile error on macOS. I make an emergency patch for this specific situation. Note: If we can build a new platform(emulator-yagl with patch), this commit can be reverted. Change-Id: I706c4067af4d6721b8aa6c69832bce7580252ca3 Signed-off-by: Jinhyung Jo --- hw/yagl/yagl_apis/gles/yagl_host_gles_calls.c | 66 +++++++++++++++++++++++++++ hw/yagl/yagl_drivers/gles_ogl/yagl_gles_ogl.c | 1 + hw/yagl/yagl_gles_driver.h | 1 + 3 files changed, 68 insertions(+) diff --git a/hw/yagl/yagl_apis/gles/yagl_host_gles_calls.c b/hw/yagl/yagl_apis/gles/yagl_host_gles_calls.c index af3efbd11d..66bd7a451f 100644 --- a/hw/yagl/yagl_apis/gles/yagl_host_gles_calls.c +++ b/hw/yagl/yagl_apis/gles/yagl_host_gles_calls.c @@ -1724,7 +1724,73 @@ void yagl_host_glDetachShader(GLuint program, void yagl_host_glCompileShader(GLuint shader) { +#ifndef CONFIG_DARWIN gles_api_ts->driver->CompileShader(yagl_gles_object_get(shader)); +#else + GLint tmp = 0; + + YAGL_LOG_FUNC_SET(glCompileShader); + + gles_api_ts->driver->CompileShader(yagl_gles_object_get(shader)); + + gles_api_ts->driver->GetShaderiv(yagl_gles_object_get(shader), GL_COMPILE_STATUS, &tmp); + if (tmp == GL_FALSE) { + char *buff; + char *substring; + const char textue2d_err[] = "undeclared identifier 'texture2D'"; + const char texture_lookup_define[] = "#define TextureLookup texture2D"; + + tmp = 0; + gles_api_ts->driver->GetShaderiv(yagl_gles_object_get(shader), GL_INFO_LOG_LENGTH, &tmp); + buff = g_malloc0(tmp); + gles_api_ts->driver->GetShaderInfoLog(yagl_gles_object_get(shader), tmp, NULL, buff); + if (gles_api_ts->driver->gl_version < yagl_gl_3_2 || + strstr(buff, textue2d_err) == NULL) { + YAGL_LOG_ERROR("Unable to compile shader %s", buff); + g_free(buff); + return; + } + YAGL_LOG_DEBUG("Unable to compile shader %s", buff); + g_free(buff); + + tmp = 0; + gles_api_ts->driver->GetShaderiv(yagl_gles_object_get(shader), GL_SHADER_SOURCE_LENGTH, &tmp); + buff = g_malloc0(tmp); + gles_api_ts->driver->GetShaderSource(yagl_gles_object_get(shader), tmp, NULL, buff); + YAGL_LOG_DEBUG("Shader Source: \n%s", buff); + + substring = strstr(buff, texture_lookup_define); + if (substring) { + const GLchar *strings[1]; + GLint lenghts[1]; + + /* texture2D -> texture\n\n */ + substring[strlen(texture_lookup_define) - 1] = '\n'; + substring[strlen(texture_lookup_define) - 2] = '\n'; + + strings[0] = buff; + lenghts[0] = tmp - 1; + + gles_api_ts->driver->ShaderSource(yagl_gles_object_get(shader), + 1, + strings, + lenghts); + gles_api_ts->driver->CompileShader(yagl_gles_object_get(shader)); + gles_api_ts->driver->GetShaderiv(yagl_gles_object_get(shader), GL_COMPILE_STATUS, &tmp); + if (!tmp) { + YAGL_LOG_ERROR("Unable to compile the patched shader source: \n%s", buff); + g_free(buff); + + tmp = 0; + gles_api_ts->driver->GetShaderiv(yagl_gles_object_get(shader), GL_INFO_LOG_LENGTH, &tmp); + buff = g_malloc0(tmp); + gles_api_ts->driver->GetShaderInfoLog(yagl_gles_object_get(shader), tmp, NULL, buff); + YAGL_LOG_ERROR("Cause of compilation failure: %s", buff); + } + } + g_free(buff); + } +#endif } void yagl_host_glBindAttribLocation(GLuint program, diff --git a/hw/yagl/yagl_drivers/gles_ogl/yagl_gles_ogl.c b/hw/yagl/yagl_drivers/gles_ogl/yagl_gles_ogl.c index 15cff43eac..70e255834a 100644 --- a/hw/yagl/yagl_drivers/gles_ogl/yagl_gles_ogl.c +++ b/hw/yagl/yagl_drivers/gles_ogl/yagl_gles_ogl.c @@ -117,6 +117,7 @@ struct yagl_gles_driver *yagl_gles_ogl_create(struct yagl_dyn_lib *dyn_lib, YAGL_GLES_OGL_GET_PROC(driver, GetProgramInfoLog, glGetProgramInfoLog); YAGL_GLES_OGL_GET_PROC(driver, GetShaderiv, glGetShaderiv); YAGL_GLES_OGL_GET_PROC(driver, GetShaderInfoLog, glGetShaderInfoLog); + YAGL_GLES_OGL_GET_PROC(driver, GetShaderSource, glGetShaderSource); YAGL_GLES_OGL_GET_PROC(driver, GetUniformfv, glGetUniformfv); YAGL_GLES_OGL_GET_PROC(driver, GetUniformiv, glGetUniformiv); YAGL_GLES_OGL_GET_PROC(driver, GetUniformLocation, glGetUniformLocation); diff --git a/hw/yagl/yagl_gles_driver.h b/hw/yagl/yagl_gles_driver.h index 22eafbd62c..6e64f7a441 100644 --- a/hw/yagl/yagl_gles_driver.h +++ b/hw/yagl/yagl_gles_driver.h @@ -183,6 +183,7 @@ struct yagl_gles_driver YAGL_GLES_DRIVER_FUNC4(GetProgramInfoLog, GLuint, GLsizei, GLsizei*, GLchar*, program, bufsize, length, infolog) YAGL_GLES_DRIVER_FUNC3(GetShaderiv, GLuint, GLenum, GLint*, shader, pname, params) YAGL_GLES_DRIVER_FUNC4(GetShaderInfoLog, GLuint, GLsizei, GLsizei*, GLchar*, shader, bufsize, length, infolog) + YAGL_GLES_DRIVER_FUNC4(GetShaderSource, GLuint, GLsizei, GLsizei*, GLchar*, shader, bufsize, length, source) YAGL_GLES_DRIVER_FUNC3(GetUniformfv, GLuint, GLint, GLfloat*, program, location, params) YAGL_GLES_DRIVER_FUNC3(GetUniformiv, GLuint, GLint, GLint*, program, location, params) YAGL_GLES_DRIVER_FUNC_RET2(int, GetUniformLocation, GLuint, const GLchar*, program, name) -- cgit v1.2.3 From a3abe35c05262394e388edecc1045d3c2ebbabbe Mon Sep 17 00:00:00 2001 From: Jinhyung Jo Date: Fri, 8 Dec 2017 16:48:51 +0900 Subject: package: update version (2.8.0.17) Change-Id: I00e5df3cba7985aaa762399aa82320315d050a45 Signed-off-by: Jinhyung Jo --- package/changelog | 3 +++ package/pkginfo.manifest | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/package/changelog b/package/changelog index 28ef6d8107..2e65d65032 100644 --- a/package/changelog +++ b/package/changelog @@ -1,3 +1,6 @@ +* 2.8.0.17 +- YaGL: hot fix web app broken issue on macOS. +== Jinhyung Jo 2017-12-08 * 2.8.0.16 - VIGS: Add support of hardware YUV420 conversion == Jinhyung Jo 2017-11-28 diff --git a/package/pkginfo.manifest b/package/pkginfo.manifest index 16c445188f..5701a75b49 100644 --- a/package/pkginfo.manifest +++ b/package/pkginfo.manifest @@ -1,4 +1,4 @@ -Version: 2.8.0.16 +Version: 2.8.0.17 Maintainer: SeokYeon Hwang Source: emulator -- cgit v1.2.3