summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChris Forbes <[email protected]>2014-05-04 20:23:58 +1200
committerChris Forbes <[email protected]>2014-06-04 19:35:59 +1200
commit6ae787584dbca92dfa499bbb628256245c345023 (patch)
tree2d67d7838f5f7afa94ecd61f402406e10d8ef2e9 /src
parentf17428a276a0b76c3e940d341cced32931297d85 (diff)
glsl: Allow int -> uint implicit conversions on function parameters
V2: Fix crashes during linking, where the parse state is NULL. In this case, all required checks have already been done, so we assume the extension is enabled. Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/glsl/glsl_types.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp
index eb03a663290..e77146cdf0a 100644
--- a/src/glsl/glsl_types.cpp
+++ b/src/glsl/glsl_types.cpp
@@ -688,10 +688,23 @@ glsl_type::can_implicitly_convert_to(const glsl_type *desired,
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