Mesa (master): glsl: add has_implicit_conversions()-helper

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Nov 2 10:12:03 UTC 2018


Module: Mesa
Branch: master
Commit: 12f001f013c71ac43b67df7bf67f9cd3581c9871
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=12f001f013c71ac43b67df7bf67f9cd3581c9871

Author: Erik Faye-Lund <erik.faye-lund at collabora.com>
Date:   Thu Oct 25 16:00:14 2018 +0200

glsl: add has_implicit_conversions()-helper

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 at collabora.com>
Reviewed-by: Tapani Pälli <tapani.palli at intel.com>

---

 src/compiler/glsl/ast_to_hir.cpp       | 2 +-
 src/compiler/glsl/glsl_parser_extras.h | 5 +++++
 src/compiler/glsl_types.cpp            | 2 +-
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index 084b7021a9..6d4b2c6aa5 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -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:
diff --git a/src/compiler/glsl/glsl_parser_extras.h b/src/compiler/glsl/glsl_parser_extras.h
index 966d848509..edd41601c3 100644
--- a/src/compiler/glsl/glsl_parser_extras.h
+++ b/src/compiler/glsl/glsl_parser_extras.h
@@ -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);
 
diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp
index 70bce6ace8..bcc36e50d7 100644
--- a/src/compiler/glsl_types.cpp
+++ b/src/compiler/glsl_types.cpp
@@ -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. */




More information about the mesa-commit mailing list