Sign in to follow this  
include4eto

Strange GLSL bug

Recommended Posts

Hodgman    51234
[quote name='include4eto' timestamp='1310553245' post='4834762']Can't be that, the COMPILER crashes, it never even executes it.[/quote]Does it crash, or fail to link the shader, causing your program to crash? If the driver crashes, how do you get the error from it? [edit]Oh, does OpenTK throw an exception when you try to compile the shader? Does the exception contain any information from the driver's compiler about why it failed?

The compiler may be attempting to determine an upper-bound on the loop, and when it can't, it may return failure, which maybe OpenTK is translating into an exception for you.

Also, is this OpenGL or GLES, and which version of GLSL are you using?

Share this post


Link to post
Share on other sites
Danny02    279
either this is not the real error(somehting what happens before, or it is a driver error(did u upgrade your video drivers latly?)

to find out, test your code on another machiene and if it fails their also try to simplify your hole programm until u know what causes the bug.

Share this post


Link to post
Share on other sites
Danny02    279
can u rewrite your shader a little bit, so it will do the same thing but perhaps with other kind of loops or so?

If I remember correct there was a case that a compiler wouldn't comple a for loop if it had to many possible iterations, perhaps with your video card/driver the same is happining, could u post your hole shader code?

Share this post


Link to post
Share on other sites
johnchapman    601
The problem is definately in that while() loop; I gave this a quick go (compiling on my Nvidia card) and the linker failed. I realize that the code you've given here is a simplified version, but I can't understand the fragment shader at all; as Hodgman said the while() loop could be infinite, and perhaps that's what's troubling the compiler.

Also (although this won't be what's causing the problem), 'varying' and 'ftransform' are deprecated, you need to specify that you're using the compatibillity profile or that your shaders are adhering to an older GLSL spec. Maybe you're doing this and just haven't included it in the example code.

Anyway, I'd second Danny02 and say that you should factor out that while() loop.

Share this post


Link to post
Share on other sites
Fiddler    860
I've seen similar errors on Nvidia cards before:

1. Try updating your drivers.
2. Make sure your shader is only using characters that can be represented by ASCII. This is a GLSL limitation and shaders *will* fail mysteriously if you use other character sets, either in comments or in actual code.

Share this post


Link to post
Share on other sites
Rene Z    605
I've only skimmed the fragment shader, but could you try changing the while loop to a for loop like:

[code]
for(int safetyHack = 0; lastIntersection.z >= 0.0 && safetyHack < 100; ++safetyHack)
[/code]

You'll also need to find a way to discard the fragment if the safetyHack fails, if you want the behaviour to be the same as it is now. The reason why the compiler may be failing is that discard doesn't guarantee the shader execution stops, it's allowed to continue and discard the fragment after the shader finished.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this