shaders/custom: also save stages only needed for RPN expressions
This is a bit annoying, and arguably such shaders are broken to begin with because there's no way you can possibly rely on this logic without spamming warnings. But it represents a difference in functionality compared to mpv, so we implement this just to be on the safe side.