Mesa could optimize repeated multiplication of a varying by a constant factor in the fragment shader
Submitted by Samuel Rødal
Assigned to Ian Romanick
Description
When the fragment shader contains code like this:
varying vec4 pos;
void main(void){ const float factor=0.1;
vec3 nf1=texture2D( tex2, pos.xyfactor).xyz; vec3 nf2=texture2D( tex2, pos.xzfactor).xyz; vec3 nf3=texture2D( tex2, pos.zy*factor).xyz;
... }
and this is the only use of pos in the fragment shader, it's more optimal to multiply the pos varying by 0.1 in the vertex shader. This gives a noticeable performance improvement at least on r600.
Is this something that could be automatically done by the GLSL compiler / optimizer?
Version: 8.0