aras-p / glsl-optimizer

GLSL optimizer based on Mesa's GLSL compiler. Used to be used in Unity for mobile shader optimization.
Other
1.72k stars 419 forks source link

Fragment shader optimimization error #36

Open matsic opened 10 years ago

matsic commented 10 years ago

During fragment shader optimization it can be incorrent function call inserted such as "vector_insert_TODO".

aras-p commented 10 years ago

Do you have a shader that reproduces the bug?

march1896 commented 10 years ago

I got the same problem, here is the sample code that cause vector_insert_TODO generated NOTE: change phi[0] to phi.x will fix it.

mediump vec3 computeWeights(mediump float x){ mediump float x2=x_x; mediump float x3=x2_x; mediump vec4 phi; phi[0]=((((-x3)+(3.0_x2))-(3.0_x))+1.0); phi[1]=(((3.0_x3)-(6.0_x2))+4.0); phi[2]=((((float(-3)_x3)+(3.0_x2))+(3.0_x))+1.0); phi[3]=x3; phi=((phi_1.0)/6.0); mediump vec3 w; w[1]=((1.0+x)-((phi[1])/((phi[0])+(phi[1])))); w[0]=((1.0-x)+((phi[3])/((phi[2])+(phi[3])))); w[2]=((phi[2])+(phi[3])); return w; }