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

## Recommended Posts

I am implementing a pixel shader to ray trace a volume texture. So I loop a high number of times (say 50) to march through the cube in incremental steps. I do a test to see if the ray goes outside the cube, and I break if it is. The problem is that it is taking D3DXCreateEffectFromFile a very long time to compile. I also get the warning: volume.fx(130,45): warning X3553: Can't use gradient instructions in loops with break, forcing loop to unroll I'm not explicitly using gradient instructions, but I guess they are done by the texture loop-up? I am NOT using mipmaps--that filter is set to NONE. If I remove the break statement, it compiles fast (like normal). So I guess the loop unrolling is what is making it slow to compile. I am using VS/PS 3.0 with a Geforce 8800, so shouldn't I have dynamic branching support?

##### Share on other sites
Quote:
 Original post by QuatI'm not explicitly using gradient instructions, but I guess they are done by the texture loop-up? I am NOT using mipmaps--that filter is set to NONE.

In that case, use tex2Dlod or whatever it's called... pass an explicit texture LOD of "0". That way the compiler will know that you don't need implicit derivatives and not force the unroll.

You can also force a loop to be a "real" loop using:
[loop] for (...) {

##### Share on other sites
Quote:
 Original post by QuatThe problem is that it is taking D3DXCreateEffectFromFile a very long time to compile.

That's because your loop is entirely unrolled (i.e. the body gets repeated 50 times). Anyway, you can also compile your shaders once and work with the binary format.