No subject


Tue Aug 3 03:16:47 PDT 2010


"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?


--=20
Aras Pranckevi=C4=8Dius
work: http://unity3d.com
home: http://aras-p.info

--00235452eebcedb7b4048ce8ce5e
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Hi,<div><br></div><div>Currently GLSL2 optimizer can&#39;t remove assignmen=
ts to struct members that are never used. After inlining, the struct is oft=
en not passed to any other functions as a whole; and some assignments to th=
e members might be useless. For example, in this fragment shader assignment=
 to s.unused could be optimized away. I guess then whole structure (of whic=
h only s.used is left) could be replaced with just a float temporary:</div>
<div><br></div><div><div>struct foo {</div><div>=C2=A0=C2=A0 =C2=A0float us=
ed;</div><div>=C2=A0=C2=A0 =C2=A0float unused;</div><div>};</div><div>void =
main() {</div><div>=C2=A0=C2=A0 =C2=A0float f =3D 1.0;</div><div>=C2=A0=C2=
=A0 =C2=A0foo s;</div><div>=C2=A0=C2=A0 =C2=A0s.used =3D f;</div><div>=C2=
=A0=C2=A0 =C2=A0s.unused =3D f;</div>
<div>=C2=A0=C2=A0 =C2=A0gl_FragColor =3D vec4(s.used);</div><div>}</div><di=
v><br></div><div>Right now GLSL2 optimizer optimizes the above into this (G=
LSL output):</div><div><br></div><div><div>struct foo {</div><div>=C2=A0=C2=
=A0float used;</div><div>
=C2=A0=C2=A0float unused;</div><div>};</div><div>void main ()</div><div>{</=
div><div>=C2=A0=C2=A0foo s;</div><div>=C2=A0=C2=A0s .used =C2=A0=3D 1.00000=
0;=C2=A0</div><div>=C2=A0=C2=A0s .unused =C2=A0=3D 1.000000;=C2=A0</div><di=
v>=C2=A0=C2=A0gl_FragColor =C2=A0=3D s .used .xxxx;=C2=A0</div><div>}</div>=
<div><br>
</div></div><div><br></div><div>From the code, it seems that ir_variable_re=
fcount only tracks references to &quot;whole variables&quot; (in this case,=
 whole struct), and not to individual members. Any quick ideas / pitfalls h=
ow that can be extended, before I try to figure it out myself?</div>
<div><br></div><br>-- <br>Aras Pranckevi=C4=8Dius<br>work: <a href=3D"http:=
//unity3d.com">http://unity3d.com</a><br>home: <a href=3D"http://aras-p.inf=
o">http://aras-p.info</a><br>
</div><div><br></div>

--00235452eebcedb7b4048ce8ce5e--


More information about the mesa-dev mailing list