[Mesa-dev] [PATCH 2/4] glsl: Emit function signatures at toplevel, even for built-ins.
Paul Berry
stereotype441 at gmail.com
Fri Aug 5 15:32:51 PDT 2011
On 2 August 2011 18:02, Ian Romanick <idr at freedesktop.org> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 08/02/2011 12:18 PM, Paul Berry wrote:
>> The case this patch is designed to fix is when a built-in function is
>> called from inside the constant integer expression that specifies the
>> length of an array, e.g.:
>>
>> #version 120
>> float x[cos(3.14159/2.0) < 0.5 ? 1 : 2];
>>
>> This case fails before the patch, because when processing an array
>> length, we are emitting IR into a dummy exec_list (see
>> process_array_type() in ast_to_hir.cpp). process_array_type() later
>> checks (via an assertion) that no instructions were emitted to the
>> dummy exec_list, based on the reasonable assumption that we shouldn't
>> need to emit instructions to calculate the value of a constant. This
>
> This is the bit of text that should be in the commit message. :) Now it
> makes sense. The bit about the dummy exec_list is the important part...
> that people familiar with the code may have forgotten.
Ok, I've updated the commit message to read as follows:
glsl: Emit function signatures at toplevel, even for built-ins.
The ast-to-hir conversion needs to emit function signatures in two
circumstances: when a function declaration (or definition) is
encountered, and when a built-in function is encountered.
To avoid emitting a function signature in an illegal place (such as
inside a function), emit_function() checked whether we were inside a
function definition, and if so, emitted the signature before the
function definition.
However, this didn't cover the case of emitting function signatures
for built-in functions when those built-in functions are called from
inside the constant integer expression that specifies the length of a
global array. This failed because when processing an array length, we
are emitting IR into a dummy exec_list (see process_array_type() in
ast_to_hir.cpp). process_array_type() later checks (via an assertion)
that no instructions were emitted to the dummy exec_list, based on the
reasonable assumption that we shouldn't need to emit instructions to
calculate the value of a constant.
This patch changes emit_function() so that it emits function
signatures at toplevel in all cases.
This partially fixes bug 38625
(https://bugs.freedesktop.org/show_bug.cgi?id=38625). The remainder
of the fix is in the patch that follows.
More information about the mesa-dev
mailing list