Mesa (staging/19.1): glsl/nir: Avoid overflow when setting max_uniform_location

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Sep 12 08:29:51 UTC 2019


Module: Mesa
Branch: staging/19.1
Commit: 83dadcfdc6f085999cdeab969fa33786042c5811
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=83dadcfdc6f085999cdeab969fa33786042c5811

Author: Caio Marcelo de Oliveira Filho <caio.oliveira at intel.com>
Date:   Wed Aug 21 10:04:56 2019 -0700

glsl/nir: Avoid overflow when setting max_uniform_location

Don't use the UNMAPPED_UNIFORM_LOC (-1) to set the unsigned
max_uniform_location.  Those unmapped uniforms don't have to be
accounted at this point.

Fixes: 7a9e5cdfbb9 ("nir/linker: Add gl_nir_link_uniforms()")
Reviewed-by: Alejandro Piñeiro <apinheiro at igalia.com>
(cherry picked from commit 4f33f96c4517f86f6f720f745cd49f8a0754393b)

---

 src/compiler/glsl/gl_nir_link_uniforms.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/compiler/glsl/gl_nir_link_uniforms.c b/src/compiler/glsl/gl_nir_link_uniforms.c
index e4924df0d03..bc506bc3751 100644
--- a/src/compiler/glsl/gl_nir_link_uniforms.c
+++ b/src/compiler/glsl/gl_nir_link_uniforms.c
@@ -443,7 +443,8 @@ nir_link_uniform(struct gl_context *ctx,
       state->num_shader_uniform_components += values;
       state->num_values += values;
 
-      if (state->max_uniform_location < uniform->remap_location + entries)
+      if (uniform->remap_location != UNMAPPED_UNIFORM_LOC &&
+          state->max_uniform_location < uniform->remap_location + entries)
          state->max_uniform_location = uniform->remap_location + entries;
 
       return MAX2(uniform->array_elements, 1);




More information about the mesa-commit mailing list