[Mesa-dev] [PATCH 8/9] glsl: In later GLSL versions, sequence operator is cannot be a constant expression

Ian Romanick idr at freedesktop.org
Mon Oct 12 09:47:24 PDT 2015


On 10/09/2015 07:14 PM, Matt Turner wrote:
> On Fri, Oct 9, 2015 at 6:53 PM, Ian Romanick <idr at freedesktop.org> wrote:
>> From: Ian Romanick <ian.d.romanick at intel.com>
>>
>> Fixes:
>>     ES3-CTS.shaders.negative.constant_sequence
>>
>>     spec/glsl-es-3.00/compiler/global-initializer/from-sequence.vert
>>     spec/glsl-es-3.00/compiler/global-initializer/from-sequence.frag
>>
>> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
>> Cc: "10.6 11.0" <mesa-stable at lists.freedesktop.org>
>> ---
>>  src/glsl/ast_to_hir.cpp | 43 ++++++++++++++++++++++++++++++++++++++++++-
>>  1 file changed, 42 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
>> index 6af0f80..f34cbe0 100644
>> --- a/src/glsl/ast_to_hir.cpp
>> +++ b/src/glsl/ast_to_hir.cpp
>> @@ -3311,8 +3311,49 @@ process_initializer(ir_variable *var, ast_declaration *decl,
>>        if (new_rhs != NULL) {
>>           rhs = new_rhs;
>>
>> +         /* Section 4.3.3 (Constant Expressions) of the GLSL ES 3.00.4 spec
>> +          * says:
>> +          *
>> +          *     "A constant expression is one of
>> +          *
>> +          *        ...
>> +          *
>> +          *        - an expression formed by an operator on operands that are
>> +          *          all constant expressions, including getting an element of
>> +          *          a constant array, or a field of a constant structure, or
>> +          *          components of a constant vector.  However, the sequence
>> +          *          operator ( , ) and the assignment operators ( =, +=, ...)
>> +          *          are not included in the operators that can create a
>> +          *          constant expression."
>> +          *
>> +          * Section 12.43 (Sequence operator and constant expressions) says:
>> +          *
>> +          *     "Should the following construct be allowed?
>> +          *
>> +          *         float a[2,3];
>> +          *
>> +          *     The expression within the brackets uses the sequence operator
>> +          *     (',') and returns the integer 3 so the construct is decl aring
> 
> There's a space in the middle of "declaring"
> 
>> +          *     a single-dimensional array of size 3.  In some languages, the
>> +          *     construct declares a two-dimensional array.  It would be
>> +          *     preferable to make this construct illegal to avoid confusion.
>> +          *
>> +          *     One possibility is to change the definition of the sequence
>> +          *     operator so that it does not return a constant- expression and
> 
> Presumably the space after the - comes from a line break and isn't intentional.

Both of those are from copy-and-pasting from the PDF of the spec... and
not fixing it afterwards.  I'll fix them both.



More information about the mesa-dev mailing list