[Mesa-dev] [PATCH] glsl: Allow ir_if in the linker's move_non_declarations function.

Eric Anholt eric at anholt.net
Thu Oct 25 10:57:37 PDT 2012


Kenneth Graunke <kenneth at whitecape.org> writes:

> Global initializers using the ?: operator with at least one non-constant
> operand generate ir_if statements.  For example,
>
>    float foo = some_boolean ? 0.0 : 1.0;
>
> becomes:
>
>    (declare (temporary) float conditional_tmp)
>    (if (var_ref some_boolean)
>        ((assign (x) (var_ref conditional_tmp) (constant float (0.0))))
>        ((assign (x) (var_ref conditional_tmp) (constant float (1.0)))))
>
> This pattern is necessary because the second or third arguments could be
> function calls, which create statements (not expressions).
>
> The linker moves these global initializers into the main() function.
> However, it incorrectly had an assertion that global initializer
> statements were only assignments, calls, or temporary variable
> declarations.  As demonstrated above, they can be if statements too.
>
> Other than the assertion, everything works fine.  So remove it.
>
> Fixes new Piglit test condition-08.vert, as well as an upcoming
> game that will be released on Steam.

Reviewed-by: Eric Anholt <eric at anholt.net>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20121025/727d1119/attachment.pgp>


More information about the mesa-dev mailing list