diff options
Diffstat (limited to 'mesalib/src/glsl/glsl_types.cpp')
-rw-r--r-- | mesalib/src/glsl/glsl_types.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/mesalib/src/glsl/glsl_types.cpp b/mesalib/src/glsl/glsl_types.cpp index 849a79af4..e77146cdf 100644 --- a/mesalib/src/glsl/glsl_types.cpp +++ b/mesalib/src/glsl/glsl_types.cpp @@ -678,7 +678,8 @@ glsl_type::component_slots() const } bool -glsl_type::can_implicitly_convert_to(const glsl_type *desired) const +glsl_type::can_implicitly_convert_to(const glsl_type *desired, + _mesa_glsl_parse_state *state) const { if (this == desired) return true; @@ -687,10 +688,23 @@ glsl_type::can_implicitly_convert_to(const glsl_type *desired) const if (this->matrix_columns > 1 || desired->matrix_columns > 1) return false; + /* Vector size must match. */ + if (this->vector_elements != desired->vector_elements) + return false; + /* int and uint can be converted to float. */ - return desired->is_float() - && this->is_integer() - && this->vector_elements == desired->vector_elements; + if (desired->is_float() && this->is_integer()) + return true; + + /* With GLSL 4.0 / ARB_gpu_shader5, int can be converted to uint. + * Note that state may be NULL here, when resolving function calls in the + * linker. By this time, all the 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) && + desired->base_type == GLSL_TYPE_UINT && this->base_type == GLSL_TYPE_INT) + return true; + + return false; } unsigned |