diff options
author | Erik Faye-Lund <[email protected]> | 2018-10-25 16:01:00 +0200 |
---|---|---|
committer | Erik Faye-Lund <[email protected]> | 2018-11-02 11:10:36 +0100 |
commit | e975c5b785f9e6d0c5ccec12a027b19a6073130c (patch) | |
tree | 614c5fca869f3b990956740325babc4f9f7c9781 /src/compiler | |
parent | 12f001f013c71ac43b67df7bf67f9cd3581c9871 (diff) |
glsl: add has_implicit_uint_to_int_conversion()-helper
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 <[email protected]>
Reviewed-by: Tapani Pälli <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/glsl/ast_to_hir.cpp | 3 | ||||
-rw-r--r-- | src/compiler/glsl/glsl_parser_extras.h | 7 | ||||
-rw-r--r-- | src/compiler/glsl_types.cpp | 3 |
3 files changed, 9 insertions, 4 deletions
diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp index 6d4b2c6aa5d..7f30a708855 100644 --- a/src/compiler/glsl/ast_to_hir.cpp +++ b/src/compiler/glsl/ast_to_hir.cpp @@ -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; diff --git a/src/compiler/glsl/glsl_parser_extras.h b/src/compiler/glsl/glsl_parser_extras.h index edd41601c35..e1144a19c15 100644 --- a/src/compiler/glsl/glsl_parser_extras.h +++ b/src/compiler/glsl/glsl_parser_extras.h @@ -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); diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp index bcc36e50d7f..e6262371bd0 100644 --- a/src/compiler/glsl_types.cpp +++ b/src/compiler/glsl_types.cpp @@ -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; |