Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "- eliminate an unexpected slow path in the fragment shader."
This reverts commit cd5aa65. This does not work as expected, needs more investigation.
- Loading branch information
39513cf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shaders have to run in constant time, so every code path is executed, and the results are discarded if the conditions are not met. It's best to avoid "if"s as much as possible when writing shaders.
39513cf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's absolutely not correct with modern hardware anymore. If a condition is uniformly true or false the conditional path will be skipped entirely. The majority of 'if's in this shader is based on uniforms (i.e. constant per primitive and often even per scene) And this are provably faster than switching shaders depending on what path is needed.
With this one there seem to be some weird things going on. I reverted this because there's places in the code where this was causing render glitches. It also seems to be a bit random when the shader starts to hit a slow path. This is not consistent but seems to mainly depend on the lighting stuff.