From 770fb78b0669555eb1f5ed01d17a93cf7ec3c3f2 Mon Sep 17 00:00:00 2001 From: hermet Date: Wed, 13 Jul 2011 00:56:12 +0000 Subject: [PATCH] [E-devel] [Patch] evas_gl_shader patch for get_program_binary extension from gl77.lee@samsung.com Dear all, I attached a patch of evas_gl_shader. I've removed a comment which is creating dummy shader when using GL_OES_get_program_binary extension. Mr. Haegeun Park who is in charge of GPU driver fixed get_program_binary bug in the SGX driver. There's no need to create dummy shaders any longer. And I've added link status checking code to validate the binary object. Please review this patch. Thanks. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@61309 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/modules/engines/gl_common/evas_gl_shader.c | 30 ++++++++++++++++---------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/modules/engines/gl_common/evas_gl_shader.c b/src/modules/engines/gl_common/evas_gl_shader.c index 4c20611..6607712 100644 --- a/src/modules/engines/gl_common/evas_gl_shader.c +++ b/src/modules/engines/gl_common/evas_gl_shader.c @@ -756,6 +756,7 @@ _evas_gl_common_shader_program_binary_init(Evas_GL_Program *p, int res = 0, num = 0, length = 0; int *formats = NULL; void *data = NULL; + GLint ok = 0; if (!ef) return res; @@ -773,15 +774,6 @@ _evas_gl_common_shader_program_binary_init(Evas_GL_Program *p, p->prog = glCreateProgram(); -#if 0 - // TODO: invalid rendering error occurs when attempting to use a - // glProgramBinary. in order to render correctly we should create a dummy - // vertex shader. - p->vert = glCreateShader(GL_VERTEX_SHADER); - glAttachShader(p->prog, p->vert); - p->frag = glCreateShader(GL_FRAGMENT_SHADER); - glAttachShader(p->prog, p->frag); -#endif glsym_glProgramBinary(p->prog, formats[0], data, length); glBindAttribLocation(p->prog, SHAD_VERTEX, "vertex"); @@ -790,6 +782,16 @@ _evas_gl_common_shader_program_binary_init(Evas_GL_Program *p, glBindAttribLocation(p->prog, SHAD_TEXUV2, "tex_coord2"); glBindAttribLocation(p->prog, SHAD_TEXUV3, "tex_coord3"); glBindAttribLocation(p->prog, SHAD_TEXM, "tex_coordm"); + + glGetProgramiv(p->prog, GL_LINK_STATUS, &ok); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + if (!ok) + { + gl_compile_link_error(p->prog, "load a program object"); + ERR("Abort load of program (%s)", pname); + goto finish; + } + res = 1; finish: @@ -810,7 +812,7 @@ _evas_gl_common_shader_program_binary_save(Evas_GL_Program *p, { void* data = NULL; GLenum format; - int length = 0; + int length = 0, size = 0; if (!glsym_glGetProgramBinary) return 0; @@ -821,9 +823,15 @@ _evas_gl_common_shader_program_binary_save(Evas_GL_Program *p, data = malloc(length); if (!data) return 0; - glsym_glGetProgramBinary(p->prog, length, NULL, &format, data); + glsym_glGetProgramBinary(p->prog, length, &size, &format, data); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + if (length != size) + { + free(data); + return 0; + } + if (eet_write(ef, pname, data, length, 0) < 0) { if (data) free(data); -- 2.7.4