OSDN Git Service

glsl: struct constructors/initializers only allow implicit conversions
authorAndres Gomez <agomez@igalia.com>
Sat, 30 Jul 2016 14:57:54 +0000 (17:57 +0300)
committerAndres Gomez <agomez@igalia.com>
Fri, 5 Aug 2016 11:27:03 +0000 (14:27 +0300)
commit1443c10d74b04ea9b377a304c4b577b85929d776
tree53ce946c5d2c67481502dc65a42290a53a3dcf05
parentde60d549b9acd5f2f9337aec8c283150bc950c99
glsl: struct constructors/initializers only allow implicit conversions

When an argument for a structure constructor or initializer doesn't
match the expected type, only Section 4.1.10 “Implicit Conversions”
are allowed to try to match that expected type.

From page 32 (page 38 of the PDF) of the GLSL 1.20 spec:

  " The arguments to the constructor will be used to set the structure's
    fields, in order, using one argument per field. Each argument must
    be the same type as the field it sets, or be a type that can be
    converted to the field's type according to Section 4.1.10 “Implicit
    Conversions.”"

From page 35 (page 41 of the PDF) of the GLSL 4.20 spec:

  " In all cases, the innermost initializer (i.e., not a list of
    initializers enclosed in curly braces) applied to an object must
    have the same type as the object being initialized or be a type that
    can be converted to the object's type according to section 4.1.10
    "Implicit Conversions". In the latter case, an implicit conversion
    will be done on the initializer before the assignment is done."

v2: Remove also the now redundant constant conversion, the
    constant_record_constructor helper and the replacement code
    (Timothy).

Fixes GL44-CTS.shading_language_420pack.initializer_list_negative

Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
Signed-off-by: Andres Gomez <agomez@igalia.com>
src/compiler/glsl/ast_function.cpp