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;
}


>From the code, it seems that ir_variable_refcount only tracks references to
"whole variables" (in this case, whole struct), and not to individual
members. Any quick ideas / pitfalls how that can be extended, before I try
to figure it out myself?


-- 
Aras Pranckevičius
work: http://unity3d.com
home: http://aras-p.info
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to