Jump to content
  • Advertisement
Sign in to follow this  
gbook2

GLSL fragment shader hangs on ATI

This topic is 3968 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been trying to find a workaround for what seems like a bug in ATI's GLSL implementation. The following fragment shader code causes my program to hang on an ATI X850: uniform int numIts; void main() { int i; /* loop for ray traversal */ for (i=0; i<numIts; i++) { /* some large number */ /* yada yada yada */ } gl_FragColor = vec4(1.0,0.0,0.0,1.0); } But! the same shader works fine on an ATI X1300. Has anyone seen this bug before or know of a workaround?

Share this post


Link to post
Share on other sites
Advertisement
AFAIK, GLSL implementation has some flaw when it comes to loops involving variable number of iterations (as in your case). The best (?) possible way to get out of this trouble is by unrolling the loop or use constant iterations. I really do not have any idea about how important the variable 'numIts' is.

Regards,
KumGame

Share this post


Link to post
Share on other sites
I've seen workarounds like

int i;
for(i=0;i<maxnumits;i++){
if(i>=numits)
break;
/* yada yada yada*/
}




that worked, but I don't know if it would work in your case.
For this solution you have to know what's the maximum value of numits.

Share this post


Link to post
Share on other sites
Loop count registers are generally limited. If you're exceeding that, expect undefined behaviour. On some drivers, I've seen the loop count being capped at the maximum limit on others, the whole shader failed to run, resulting in white pixels.

In either cases, your program should NOT hang because of that.
It is possible that the shader is not loaded and maybe you're trying to upload uniform data to a shader which simply isn't there. This gave me a few headaches in the past, maybe it's worth checking it.

Share this post


Link to post
Share on other sites
Quote:
Original post by Ingrater
I've seen workarounds like
*** Source Snippet Removed ***
that worked, but I don't know if it would work in your case.
For this solution you have to know what's the maximum value of numits.


Ooh, that looks useful.

I've had similar hangs / plain wrong compilation errors in the past with my NVidia card, depending on the driver. I guess loops are still not very well supported generally.

Share this post


Link to post
Share on other sites
Ingrater: I tried that workaround, but no luck. Even replacing the loop ending variable with 50 directly doesn't change the result.

I should also say that it does not cause my program to crash, but only to hang for about 30 seconds, and then it eventually comes back. But if every frame takes 30s to draw, its a bad thing. I also noticed that CPU usage is at 100% during that 30s. The shader info log reports "Fragment shader was successfully compiled to run on hardware."

I guess even though the drivers are the same (catalyst 8.1) on the X850 and X1300, the cards are different enough so my code works on the X1300 but not the X850.

Does anyone know which cards are best for supporting GLSL? Nvidia or ATI, doesn't matter which. I may be in the market for a new card, since the X850 is getting 'old' anyhow.

Share this post


Link to post
Share on other sites
I forgot to mention that the maxnumits hast do be constant


const int maxnumits = 50;
int i;
for(i=0;i<maxnumits;i++){
if(i>=numits)
break;
/* yada yada yada*/
}





The shader is then compiled as an shader model 2.0 shader without dynamic branching. The loop is unrolled. If maxnumits is to large it would not compile because there are to many instructions for SM 2.0.

[Edited by - Ingrater on February 3, 2008 7:47:41 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by gbook2
Does anyone know which cards are best for supporting GLSL? Nvidia or ATI, doesn't matter which. I may be in the market for a new card, since the X850 is getting 'old' anyhow.
Are you joking? :P
Although a few months have gone this article points out a few notes on ATi.
Having a few for testing is a necessary evil but I really don't want those on my primary machine.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!