Nvidia drivers seem to compile the switch with fallthrough as a 19 level nested if, and inlines the code from the fallthrough cases into each. The hd devs have identified this as a potential source of the artifacting that happens on some cards due to the number of nested branches. Replace the switch with a simple loop, which also is about 7% of the generated code size of the switch.