glsl: Find the "closest" signature when there are multiple matches.
glsl: Find the "closest" signature when there are multiple matches.

Previously, ir_function::matching_signature had a fatal bug: if a
function had more than one non-exact match, it would simply return NULL.

This occured, for example, when looking for max(uvec3, uvec3):
- max(vec3, vec3)   -> score 1 (found first)
- max(ivec3, ivec3) -> score 1 (found second...used to return NULL here)
- max(uvec3, uvec3) -> score 0 (exact match...the right answer)

This did not occur for max(ivec3, ivec3) since the second match found
was an exact match.

The new behavior is to return a match with the lowest score.  If there
is an exact match, that will be returned.  Otherwise, a match with the
least number of implicit conversions is chosen.

Fixes piglit tests max-uvec3.vert and glsl-inexact-overloads.shader_test.

NOTE: This is a candidate for the 7.10 and 7.11 branches.

Signed-off-by: Kenneth Graunke <bd2562f754ec92342f93f61c25d731e290a2ffa8@whitecape.org>
Reviewed-by: Ian Romanick <2b237cafb16dc45038e85df6c85e74e6d899eba9@intel.com>
Reviewed-by: Eric Anholt <96f164ad4d9b2b0dacf8ebee2bb1eeb3aa69adf1@anholt.net>

bkaradzic/glsl-optimizer,KTXSoftware/glsl2agal,dellis1972/glsl-optimizer,wolf96/glsl-optimizer,adobe/glsl2agal,mapbox/glsl-optimizer,zz85/glsl-optimizer,mapbox/glsl-optimizer,zeux/glsl-optimizer,jbarczak/glsl-optimizer,dellis1972/glsl-optimizer,metora/MesaGLSLCompiler,djreep81/glsl-optimizer,zz85/glsl-optimizer,jbarczak/glsl-optimizer,mcanthony/glsl-optimizer,tokyovigilante/glsl-optimizer,bkaradzic/glsl-optimizer,benaadams/glsl-optimizer,benaadams/glsl-optimizer,KTXSoftware/glsl2agal,mcanthony/glsl-optimizer,tokyovigilante/glsl-optimizer,adobe/glsl2agal,zz85/glsl-optimizer,adobe/glsl2agal,KTXSoftware/glsl2agal,metora/MesaGLSLCompiler,mcanthony/glsl-optimizer,mapbox/glsl-optimizer,benaadams/glsl-optimizer,dellis1972/glsl-optimizer,wolf96/glsl-optimizer,djreep81/glsl-optimizer,dellis1972/glsl-optimizer,bkaradzic/glsl-optimizer,metora/MesaGLSLCompiler,jbarczak/glsl-optimizer,adobe/glsl2agal,jbarczak/glsl-optimizer,zz85/glsl-optimizer,zz85/glsl-optimizer,zeux/glsl-optimizer,djreep81/glsl-optimizer,djreep81/glsl-optimizer,djreep81/glsl-optimizer,bkaradzic/glsl-optimizer,mcanthony/glsl-optimizer,mapbox/glsl-optimizer,mapbox/glsl-optimizer,zz85/glsl-optimizer,adobe/glsl2agal,KTXSoftware/glsl2agal,KTXSoftware/glsl2agal,benaadams/glsl-optimizer,bkaradzic/glsl-optimizer,benaadams/glsl-optimizer,jbarczak/glsl-optimizer,tokyovigilante/glsl-optimizer,wolf96/glsl-optimizer,tokyovigilante/glsl-optimizer,wolf96/glsl-optimizer,zeux/glsl-optimizer,zeux/glsl-optimizer,benaadams/glsl-optimizer,zeux/glsl-optimizer,mcanthony/glsl-optimizer,dellis1972/glsl-optimizer,wolf96/glsl-optimizer,tokyovigilante/glsl-optimizer