Metal: correctly clamp stencil reference values According to GL spec: - If stencil ref value is larger than max value the stencil buffer can represent, clamp it to max value (2^bits - 1) - The stencil clear value & mask will be truncated to stencil buffer's bits instead of clamping. Metal API is very vague on how it handles the stencil ref value larger than the stencil bits can represent, so we need to handle it manually. In fact, the Metal API seems to have bugs when dealing with large stencil ref value, i.e. > 0xff for example. Bug: angleproject:2634 Change-Id: I86f61f0bfd19dfc0fa459c84d98785a1af857a6b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1966185 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jonah Ryan-Davis <jonahr@google.com>