glsl: Perform implicit type conversions on function call out parameters.
authorPaul Berry <stereotype441@gmail.com>
Tue, 2 Aug 2011 21:34:17 +0000 (14:34 -0700)
committerPaul Berry <stereotype441@gmail.com>
Tue, 16 Aug 2011 00:23:01 +0000 (17:23 -0700)
commit67b5a3267d639c31d3ac4073be877ffb0f5637d3
treedc5f17260302ad8e3678975bb67bbe78a8a52f83
parentc548192cafdf7dfab4cf7e0a0734417ee16f1c94
glsl: Perform implicit type conversions on function call out parameters.

When an out parameter undergoes an implicit type conversion, we need
to store it in a temporary, and then after the call completes, convert
the resulting value.  In other words, we convert code like the
following:

void f(out int x);
float value;
f(value);

Into IR that's equivalent to this:

void f(out int x);
float value;
int out_parameter_conversion;
f(out_parameter_conversion);
value = float(out_parameter_conversion);

This transformation needs to happen during ast-to-IR convertion (as
opposed to, say, a lowering pass), because it is invalid IR for formal
and actual parameters to have types that don't match.

Fixes piglit tests
spec/glsl-1.20/compiler/qualifiers/out-conversion-int-to-float.vert and
spec/glsl-1.20/execution/qualifiers/vs-out-conversion-*.shader_test,
and bug 39651.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=39651

Reviewed-by: Chad Versace <chad@chad-versace.us>
src/glsl/ast_function.cpp