[Mesa-dev] [PATCH v2] glsl: handle unsigned int wraparound in link_shaders()
Lars Hamre
chemecse at gmail.com
Fri Apr 8 14:06:23 UTC 2016
NOTE: someone with access will need to commit this afer the
review process
v2: change check_explicit_uniform_locations() to return an
unsigned 0 (Timothy Arceri)
We were storing the int result of check_explicit_uniform_locations()
in num_explicit_uniform_locs as an unsigned int which caused it to
be 4294967295 when a -1 was returned.
This in turn would cause the following error during linking:
error: count of uniform locations > MAX_UNIFORM_LOCATIONS(4294967295 > 98304)
Here are the results from running piglit tests/all with this patch:
changes: 178
fixes: 176
regressions: 2
The two regressions are for the following tests:
glean at glsl1-matrix column check (1)
glean at glsl1-matrix column check (2)
which regress from FAIL to CRASH.
I am okay with these regressions because the tests are currently
failing due to the aforementioned linker error.
Signed-off-by: Lars Hamre <chemecse at gmail.com>
---
src/compiler/glsl/linker.cpp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index cd35464..cc74574 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -3164,12 +3164,12 @@ reserve_subroutine_explicit_locations(struct gl_shader_program *prog,
* any optimizations happen to handle also inactive uniforms and
* inactive array elements that may get trimmed away.
*/
-static int
+static unsigned
check_explicit_uniform_locations(struct gl_context *ctx,
struct gl_shader_program *prog)
{
if (!ctx->Extensions.ARB_explicit_uniform_location)
- return -1;
+ return 0;
/* This map is used to detect if overlapping explicit locations
* occur with the same uniform (from different stage) or a different one.
@@ -3178,7 +3178,7 @@ check_explicit_uniform_locations(struct gl_context *ctx,
if (!uniform_map) {
linker_error(prog, "Out of memory during linking.\n");
- return -1;
+ return 0;
}
unsigned entries_total = 0;
@@ -3207,7 +3207,7 @@ check_explicit_uniform_locations(struct gl_context *ctx,
}
if (!ret) {
delete uniform_map;
- return -1;
+ return 0;
}
}
}
--
2.5.5
More information about the mesa-dev
mailing list