[Mesa-dev] glsl2: optimizing unused struct assignments
Aras Pranckevicius
aras at unity3d.com
Tue Aug 3 03:30:38 PDT 2010
Hi,
Currently GLSL2 optimizer can't remove assignments to struct members that
are never used. After inlining, the struct is often not passed to any other
functions as a whole; and some assignments to the members might be useless.
For example, in this fragment shader assignment to s.unused could be
optimized away. I guess then whole structure (of which only s.used is left)
could be replaced with just a float temporary:
struct foo {
float used;
float unused;
};
void main() {
float f = 1.0;
foo s;
s.used = f;
s.unused = f;
gl_FragColor = vec4(s.used);
}
Right now GLSL2 optimizer optimizes the above into this (GLSL output):
struct foo {
float used;
float unused;
};
void main ()
{
foo s;
s .used = 1.000000;
s .unused = 1.000000;
gl_FragColor = s .used .xxxx;
}
More information about the mesa-dev
mailing list