I've decided to actually get around to seeing what I can do about this.
Some more research seems to confirm that GL_EXT_gpu_shader4 is not supported at all in Mesa, which means that most Linux users will not be able to get the shaders working to any great extent. I figure I'll try to replace any of the unsupported calls with non-ext calls (my naive understanding is that it shouldn't be too difficult).
I'll post here with any progress.
Edit: Given the lack of responses to my last post, I assume not many people are interested, so I'll just edit this post as I go.
First, looking at the code again with a fresh eye, I realize that there is no actual use of the gpu_shader4 extension, which is why the code works even though mesa doesn't support it
The problem with the game hanging for a few seconds with certain shaders seems to be due to compilation. Looking at the IR (intermediate representation) for one of the offending shader programs reveals that it is something like 11,000 lines longs
Shader programs that don't have a problem are more reasonably sized (like 50 lines or so).
I think the problem *may* be because Mesa inlines all subroutines and it gets it horribly wrong sometimes. Looking at the resultant IR seems to support this theory (the same thing over and over and over again). Armed with this knowledge, I'm going to try to rewrite some of the shaders to see if it helps.
Note: if anyone wants to get to the point I did, setting the environment variable MESA_GLSL=dump,nopt dumps the unoptomized shaders to stdout when they are compiled.
Edit 2: The mainline for shockwave2.frag results in the creation of 3000 temporary variables
I have yet to figure out exactly what is triggering it.
Edit 3: Found the problem. It's the repeated application of snoise. Not entirely sure what to do about it, but at least I know where to start. I'll have another look tomorrow.
Last edit tonight: (I promise) I'm 99% sure that the issue is when generating code like
permute(permute(permute blah, blah)))
In Fireball.frag it also has
Uberblend(blah, Uberblend(blah, ))
So basically, it seems like Mesa freaks out if you call the same function in its parameters (which I can understand). Should be very easy to fix. Like, I said, I will try tomorrow...