glsl: add has_implicit_uint_to_int_conversion()-helper
authorErik Faye-Lund <erik.faye-lund@collabora.com>
Thu, 25 Oct 2018 14:01:00 +0000 (16:01 +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 reduces repetition,
especially 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 6d4b2c6aa5dd01c5385105af72bfde3e714a5f26..7f30a7088551883b7be9aa1295ac50b00704aaa7 100644 (file)
@@ -250,8 +250,7 @@ get_implicit_conversion_operation(const glsl_type *to, const glsl_type *from,
       }
 
    case GLSL_TYPE_UINT:
-      if (!state->is_version(400, 0) && !state->ARB_gpu_shader5_enable
-          && !state->MESA_shader_integer_functions_enable)
+      if (!state->has_implicit_uint_to_int_conversion())
          return (ir_expression_operation)0;
       switch (from->base_type) {
          case GLSL_TYPE_INT: return ir_unop_i2u;
index edd41601c3563bb4ce03887b8e007ec6c5f4452a..e1144a19c15493219a75a64824d2828370f59589 100644 (file)
@@ -349,6 +349,13 @@ struct _mesa_glsl_parse_state {
       return is_version(120, 0);
    }
 
+   bool has_implicit_uint_to_int_conversion() const
+   {
+      return ARB_gpu_shader5_enable ||
+             MESA_shader_integer_functions_enable ||
+             is_version(400, 0);
+   }
+
    void process_version_directive(YYLTYPE *locp, int version,
                                   const char *ident);
 
index bcc36e50d7fee01ee0f7ba368b31d0dfa437fbcd..e6262371bd0c7a6f3a54dbcab07c3d189f0cba0a 100644 (file)
@@ -1446,8 +1446,7 @@ glsl_type::can_implicitly_convert_to(const glsl_type *desired,
     * state-dependent checks have already happened though, so allow anything
     * that's allowed in any shader version.
     */
-   if ((!state || state->is_version(400, 0) || state->ARB_gpu_shader5_enable ||
-        state->MESA_shader_integer_functions_enable) &&
+   if ((!state || state->has_implicit_uint_to_int_conversion()) &&
          desired->base_type == GLSL_TYPE_UINT && this->base_type == GLSL_TYPE_INT)
       return true;