• Advertisement
Sign in to follow this  

Unrestricted while loop?

This topic is 899 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 suspect the answer to this is going to be 'no', but I'll ask anyway. Is it possible to have a while loop in HLSL which continues indefinitely? I'm making an iterative path tracer which, for each initial ray, bounces it around the scene until it either hits a light or until its colour becomes close enough to black that I can just ignore it. At the moment, I am having to impose a maximum number of bounces because the shader refuses to compile unless I do. Has anyone done a similar project where they can share a solution?

 

Thanks a lot!

Share this post


Link to post
Share on other sites
Advertisement

Most GPU's are non-preemptive, meaning that once your shader is running... it will run to completion no matter what, without letting other stuff like, say, rendering your desktop, run in parallel. In other words your screen will freeze and if you have a driver watchdog it will reset the driver after some number of seconds.

 

To do what you want you should just get each invocation of the shader to do N passes on each pixel, and accumulate the results, where N is a reasonable number (large enough that you're not invoking a shader run for every pass, but not too large that your shader takes too long to run). If you are using a dedicated second graphics card not connected to a monitor then N can be as large as you want.

 

That way you can see the results of the iterative passes, N passes at a time. You'll know if N is too large if your desktop feels choppy to use.

Share this post


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

  • Advertisement