glsl/nir: Avoid overflow when setting max_uniform_location
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Wed, 21 Aug 2019 17:04:56 +0000 (10:04 -0700)
committerCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Tue, 10 Sep 2019 21:36:46 +0000 (14:36 -0700)
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@igalia.com>
src/compiler/glsl/gl_nir_link_uniforms.c

index ac97334e9cdd54f48f891edba7cbf592318fe072..6323d2940db1f8dc28777397db4027f7921ca5e9 100644 (file)
@@ -603,7 +603,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);