glsl: add has_implicit_conversions()-helper
authorErik Faye-Lund <erik.faye-lund@collabora.com>
Thu, 25 Oct 2018 14:00:14 +0000 (16:00 +0200)
committerErik Faye-Lund <erik.faye-lund@collabora.com>
Fri, 2 Nov 2018 10:10:36 +0000 (11:10 +0100)
This makes the code a bit easier to read, as well as will reduce
repetition when we add support for EXT_shader_implicit_conversions.

Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
src/compiler/glsl/ast_to_hir.cpp
src/compiler/glsl/glsl_parser_extras.h
src/compiler/glsl_types.cpp

index 084b7021a9f22af83a0f1eb2af9ea4e09955d290..6d4b2c6aa5dd01c5385105af72bfde3e714a5f26 100644 (file)
@@ -315,7 +315,7 @@ apply_implicit_conversion(const glsl_type *to, ir_rvalue * &from,
       return true;
 
    /* Prior to GLSL 1.20, there are no implicit conversions */
-   if (!state->is_version(120, 0))
+   if (!state->has_implicit_conversions())
       return false;
 
    /* From page 27 (page 33 of the PDF) of the GLSL 1.50 spec:
index 966d848509cf111055240d29ac78b6b95dc21290..edd41601c3563bb4ce03887b8e007ec6c5f4452a 100644 (file)
@@ -344,6 +344,11 @@ struct _mesa_glsl_parse_state {
       return ARB_bindless_texture_enable;
    }
 
+   bool has_implicit_conversions() const
+   {
+      return is_version(120, 0);
+   }
+
    void process_version_directive(YYLTYPE *locp, int version,
                                   const char *ident);
 
index 70bce6ace8e9304308e95ed00635ef78f6fa061c..bcc36e50d7fee01ee0f7ba368b31d0dfa437fbcd 100644 (file)
@@ -1425,7 +1425,7 @@ glsl_type::can_implicitly_convert_to(const glsl_type *desired,
     * state, we're doing intra-stage function linking where these checks have
     * already been done.
     */
-   if (state && !state->is_version(120, 0))
+   if (state && !state->has_implicit_conversions())
       return false;
 
    /* There is no conversion among matrix types. */