Is the 12/3 just going between the switches and the lights? 12/2 from the breaker panel to the switches?
If this is the case, you should be fine. I don't know what the electric code says, but it will work. Just realize that the neutral in the 12/3 line will be carrying the amperage of the two hot legs combined. As long as the circuit is supplied through a 20A breaker, you won't be able to exceed the ratings of the neutral.
If you ran 12/3 from the panel, being fed from 2 different 20A breakers on the same 120V leg, then you could have 40A running in the neutral which would be a problem. In most places, code actually allows you to do this with different 120V legs, because in that case the neutral carries the difference in current between the two hot wires, not the sum.