Bug 82921

Summary: layout(location=0) emits error >= MAX_UNIFORM_LOCATIONS due to integer underflow
Product: Mesa Reporter: Micael Dias <kam1kaz3>
Component: glsl-compilerAssignee: Tapani Pälli <lemody>
Status: RESOLVED FIXED QA Contact: Intel 3D Bugs Mailing List <intel-3d-bugs>
Severity: normal    
Priority: medium CC: huax.lu
Version: git   
Hardware: Other   
OS: All   
i915 platform: i915 features:

Description Micael Dias 2014-08-21 20:49:04 UTC
I have a

layout(location=0) uniform sampler2D diffuseTex;

in my shader, and it fails to compile with error:
"location(s) consumed by uniform diffuseTex >= MAX_UNIFORM_LOCATIONS (65536)".

I think this is because of this line in ast_to_hir.cpp:
> unsigned max_loc = qual->location + var->type->uniform_locations() - 1;

If "var->type->uniform_locations()" returns zero and qual->location is zero, we have an integer underflow, and therefore the following checks will fail.
Comment 1 Tapani Pälli 2014-08-22 04:44:42 UTC
will take a look
Comment 2 Tapani Pälli 2014-08-22 04:45:36 UTC
Micael, would be cool to have your shader as a test case.
Comment 3 Tapani Pälli 2014-08-22 05:08:34 UTC
a new piglit test case and fix for the bug has been sent for review ..
Comment 4 Micael Dias 2014-08-22 14:09:00 UTC
(In reply to comment #2)
> Micael, would be cool to have your shader as a test case.

As you created the piglit test, am I right to believe this is no longer needed?

The shader is a very simple one basically calling texture() on the uniform sampler2D.
Comment 5 Tapani Pälli 2014-08-27 11:16:14 UTC
Yep no additional tests needed. I sent another fix to the list, all explicit uniform Piglit tests are passing with this.
Comment 6 Tapani Pälli 2014-09-17 08:32:20 UTC
fix has been on the list for some time now ..

Comment 7 Tapani Pälli 2014-09-17 08:32:35 UTC
*** Bug 83124 has been marked as a duplicate of this bug. ***
Comment 8 Tapani Pälli 2014-09-26 05:32:38 UTC
fixed in master

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.