Shader code discarded by system?

I’m just wondering, if I have an extremely complicated shader,will system discard some of the code during rendering?

What I think is, even if the shader is very complicated, but as long as it compiles and links, it should be execued at a slower rate, right?

Now I have a very complicated Geometry Shader,I suspect that some code might have been discarded, is it possible?

I am not an expert on programming shaders but I have experienced code being discarded from them.

It is very common that shader compilers discard the code that does NOT contribute to any output or varying variables.

If your shader is very complicated, perhaps it is difficult to see that some of the code is not necessary and can be stripped, the compiler would catch that and discard it. Maybe you can split up the shader into more manageable parts and test them separately?

kind regards,
Nicolai Brøgger

It is very difficult to find out which code does NOT contribute to the result and thus discard it. It is highly unlikely, that code is regarded as “not contributing to the result” and thus discarded, although it has impact on the result.

Of course driver-errors can happen, and are, unfortunately, not as rare as we liked them to be.

All you can do, is test further, and maybe show us your code and tell us the results, so that we can help you figure out, what is going wrong.

If you can pinpoint an obvious driver-error, write a mail, including a simple test-application, to nVidia (i assume it is NV, since you use geometry shaders…).


Thanks guys, I’ve figure out my error, the code is not discarded, it my error

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.