I am running into #1178 when targeting metal:
half4 foo; foo[specialization constant] ends up foo[0] in metal shader.
- Putting specialization constant first into a temp variable works around the issue, but only if optimizations are not used.
- A silly switch case successfully works around the issue even when optimizations are used.
I will try to fill in more details later.