Evas GL shaders: Simplify a bit the shaders code

Following raster's change, the Program_Source struct is useless.
This is a big commit, again, but really all is auto-generated.
This commit is contained in:
Jean-Philippe Andre 2015-10-19 20:04:20 +09:00
parent a3cec656c8
commit 4a830877f0
6 changed files with 1434 additions and 5220 deletions

View File

@ -710,7 +710,7 @@ modules/evas/engines/gl_common/shader/evas_gl_shaders_bigendian.x: $(GL_SHADERS_
@echo " SHADERS $@" @echo " SHADERS $@"
@bash $(srcdir)/modules/evas/engines/gl_common/shader/gen_shaders.sh _bigendian @bash $(srcdir)/modules/evas/engines/gl_common/shader/gen_shaders.sh _bigendian
modules/evas/engines/gl_common/shader/evas_gl_enum.x: modules/evas/engines/gl_common/shader/evas_gl_shaders.x modules/evas/engines/gl_common/shader/evas_gl_enum.x: modules/evas/engines/gl_common/shader/evas_gl_shaders.x modules/evas/engines/gl_common/shader/evas_gl_shaders_bigendian.x
# NOTE: order here should be equal with modes in file Evas_Eo.h # NOTE: order here should be equal with modes in file Evas_Eo.h
GL_SHADERS_3D_GEN = \ GL_SHADERS_3D_GEN = \

View File

@ -54,7 +54,6 @@
#define SHAD_MASKSAM 8 #define SHAD_MASKSAM 8
typedef struct _Evas_GL_Program Evas_GL_Program; typedef struct _Evas_GL_Program Evas_GL_Program;
typedef struct _Evas_GL_Program_Source Evas_GL_Program_Source;
typedef struct _Evas_GL_Shared Evas_GL_Shared; typedef struct _Evas_GL_Shared Evas_GL_Shared;
typedef struct _Evas_Engine_GL_Context Evas_Engine_GL_Context; typedef struct _Evas_Engine_GL_Context Evas_Engine_GL_Context;
typedef struct _Evas_GL_Texture_Pool Evas_GL_Texture_Pool; typedef struct _Evas_GL_Texture_Pool Evas_GL_Texture_Pool;
@ -105,11 +104,6 @@ struct _Evas_GL_Program
Eina_Bool reset; Eina_Bool reset;
}; };
struct _Evas_GL_Program_Source
{
const char *src;
};
struct _Evas_GL_Shared struct _Evas_GL_Shared
{ {
Eina_List *images; Eina_List *images;

View File

@ -143,8 +143,8 @@ _evas_gl_common_shader_program_binary_save(Evas_GL_Program *p,
static int static int
_evas_gl_common_shader_program_source_init(Evas_GL_Program *p, _evas_gl_common_shader_program_source_init(Evas_GL_Program *p,
Evas_GL_Program_Source *vert, const char *vert,
Evas_GL_Program_Source *frag, const char *frag,
const char *name) const char *name)
{ {
GLint ok; GLint ok;
@ -152,26 +152,24 @@ _evas_gl_common_shader_program_source_init(Evas_GL_Program *p,
p->vert = glCreateShader(GL_VERTEX_SHADER); p->vert = glCreateShader(GL_VERTEX_SHADER);
p->frag = glCreateShader(GL_FRAGMENT_SHADER); p->frag = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(p->vert, 1, glShaderSource(p->vert, 1, &vert, NULL);
(const char **)&(vert->src), NULL);
glCompileShader(p->vert); glCompileShader(p->vert);
ok = 0; ok = 0;
glGetShaderiv(p->vert, GL_COMPILE_STATUS, &ok); glGetShaderiv(p->vert, GL_COMPILE_STATUS, &ok);
if (!ok) if (!ok)
{ {
gl_compile_link_error(p->vert, "compile vertex shader"); gl_compile_link_error(p->vert, "compile vertex shader");
ERR("Abort compile of shader vert (%s): %s", name, vert->src); ERR("Abort compile of shader vert (%s): %s", name, vert);
return 0; return 0;
} }
glShaderSource(p->frag, 1, glShaderSource(p->frag, 1, &frag, NULL);
(const char **)&(frag->src), NULL);
glCompileShader(p->frag); glCompileShader(p->frag);
ok = 0; ok = 0;
glGetShaderiv(p->frag, GL_COMPILE_STATUS, &ok); glGetShaderiv(p->frag, GL_COMPILE_STATUS, &ok);
if (!ok) if (!ok)
{ {
gl_compile_link_error(p->frag, "compile fragment shader"); gl_compile_link_error(p->frag, "compile fragment shader");
ERR("Abort compile of shader frag (%s): %s", name, frag->src); ERR("Abort compile of shader frag (%s): %s", name, frag);
return 0; return 0;
} }
@ -203,8 +201,8 @@ _evas_gl_common_shader_program_source_init(Evas_GL_Program *p,
if (!ok) if (!ok)
{ {
gl_compile_link_error(p->prog, "link fragment and vertex shaders"); gl_compile_link_error(p->prog, "link fragment and vertex shaders");
ERR("Abort compile of shader frag (%s): %s", name, frag->src); ERR("Abort compile of shader frag (%s): %s", name, frag);
ERR("Abort compile of shader vert (%s): %s", name, vert->src); ERR("Abort compile of shader vert (%s): %s", name, vert);
return 0; return 0;
} }

File diff suppressed because it is too large Load Diff

View File

@ -142,17 +142,15 @@ for (( i = 0; i < ${#SHADERS[@]} ; i++ )) ; do
OIFS=$IFS OIFS=$IFS
IFS=$'\n' IFS=$'\n'
printf "static const char ${shdname}_glsl[] =" >> ${OUTPUT} printf "static const char ${shdname}_src[] =" >> ${OUTPUT}
for line in `cat ${shd}` ; do for line in `cat ${shd}` ; do
printf "\n \"${line}\\\n\"" >> ${OUTPUT} printf "\n \"${line}\\\n\"" >> ${OUTPUT}
done done
printf ";\n" >> ${OUTPUT} printf ";\n\n" >> ${OUTPUT}
IFS=${OIFS} IFS=${OIFS}
printf "Evas_GL_Program_Source shader_${shdname}_src =\n{\n ${shdname}_glsl\n};\n\n" >> ${OUTPUT}
done done
shaders_source="${shaders_source} { SHADER_${UNAME}, &(shader_${name}_vert_src), &(shader_${name}_frag_src), \"${name}\", SHD_${TYPE}, SHD_${sam}, SHD_${masksam}, ${bgra}, ${mask}, ${nomul}, ${afill} },\n" shaders_source="${shaders_source} { SHADER_${UNAME}, ${name}_vert_src, ${name}_frag_src, \"${name}\", SHD_${TYPE}, SHD_${sam}, SHD_${masksam}, ${bgra}, ${mask}, ${nomul}, ${afill} },\n"
shaders_enum="${shaders_enum} SHADER_${UNAME},\n" shaders_enum="${shaders_enum} SHADER_${UNAME},\n"
# Bind textures to the programs. Only if there is more than 1 texture. # Bind textures to the programs. Only if there is more than 1 texture.
@ -167,8 +165,8 @@ done
printf " printf "
static const struct { static const struct {
Evas_GL_Shader id; Evas_GL_Shader id;
Evas_GL_Program_Source *vert; const char *vert;
Evas_GL_Program_Source *frag; const char *frag;
const char *name; const char *name;
Shader_Type type; Shader_Type type;
Shader_Sampling sam; Shader_Sampling sam;