summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorJinhyung Jo <jinhyung.jo@samsung.com>2017-12-07 16:46:56 +0900
committerJinhyung Jo <jinhyung.jo@samsung.com>2017-12-08 12:08:04 +0900
commit708bf5de36608796e1046a58ada92f796156ac54 (patch)
tree2867903c4baeb65e74323c2bef1d952e1accac08 /hw
parent83992787addf9fb40fa97c0074fc7eb114e35865 (diff)
downloadqemu-708bf5de36608796e1046a58ada92f796156ac54.tar.gz
qemu-708bf5de36608796e1046a58ada92f796156ac54.tar.bz2
qemu-708bf5de36608796e1046a58ada92f796156ac54.zip
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 <jinhyung.jo@samsung.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/yagl/yagl_apis/gles/yagl_host_gles_calls.c66
-rw-r--r--hw/yagl/yagl_drivers/gles_ogl/yagl_gles_ogl.c1
-rw-r--r--hw/yagl/yagl_gles_driver.h1
3 files changed, 68 insertions, 0 deletions
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)