[Mesa-users] GLSL: brw_eu.h assertion setting uniform variable
jason at sonos.org
Mon May 23 15:09:32 PDT 2011
Hi, Brian, :)
On Fri, 13 May 2011, Brian Paul wrote:
> On 05/11/2011 04:48 PM, Jason Tiller wrote:
>> When trying to use a uniform value in a simple GLSL vertex shader, I
>> am getting the following abort:
>> brw_eu.h:177: brw_reg: Assertion `nr < 128' failed.
>> I've tried this using raw GLUT (glGetUniformLocation/getUniform1i) as
>> well as implementing this in Qt 4.7 (setUniformValue). The shader
>> does dead simple Gouraud shading. I link it along with a super-simple
>> passthrough fragment shader. I'm using the uniform variable to pass
>> in the number of lights in the scene. I declare the variable at the
>> top of my shader:
>> uniform int numlights;
>> If I turn the variable into a const:
>> const int numlights = 2;
>> then it works perfectly. Of course, I need to pass uniforms into my
>> Any ideas? I'm running:
>> Kubuntu 11.04 (turned off all effects in KWin)
>> KDE 4.6.3
>> Qt 4.7.2
>> Intel i5 430M w/i915 embedded graphics
>> OpenGL 2.1, Mesa 7.10.2
>> Xorg 1.10.1-1ubuntu1
>> I'm desperate! This makes no sense at all to me, and I have no idea
>> where to go from here.
>> Thank you!
>> P.S. - I've tried fiddling with MESA_GLSL=... and can see my shaders
>> getting compiled, the program being used, and the uniform variable
>> being set... but still the abort. HELP!
> You should file a bug for this. Or, try the latest Mesa code from
I've determined the problem - I was attempting to use a feature in my
shader that isn't supported by my graphics chipset. Specifically, I
was using non-constant conditions in my for loop, which isn't
implemented in any of these extensions:
I should have realized that was the problem, but I'm *really* new to
shaders, and I didn't understand how wildly varied all the chipsets
are in what they support.
However, I really wish that Mesa had given me a better error
diagnostic. "brw_eu.h:177: brw_reg: Assertion `nr < 128' failed" was
I ended up switching over to using Cg, which worked fine. There were
three things that sold me on using Cg for my class project:
1. The Cg compiler told me *immediately* what my problem was:
"error C5013: profile does not support 'for' statements and 'for'
could not be unrolled."
In other words, the loop has to have a constant test for it to be
2. The Cg runtime comes with an *excellent* set of example shaders
and runtime examples that run with GLUT (lowest common
denominator). All but two of the examples ran out of the box for
3. The Cg Tutorial. There's nothing like this book for GLSL. The
SuperBible, Orange Book, etc.... none of these approach shading
programming in the simple and straightforward way that The Cg
So, while the actual failure was pilot error in this case, Mesa
certainly didn't help me narrow down the possibilities.
Thanks for the suggestion, Brian! I'm still interested in trying
GLSL, but I think I may wait until I have a laptop with a *real* GPU.
For now, Cg/Qt is enough for my feeble investigations.
More information about the mesa-users