nir/lower_clip: Only emit 1 discard
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Fri, 3 Feb 2023 14:59:04 +0000 (09:59 -0500)
committerMarge Bot <emma+marge@anholt.net>
Mon, 6 Feb 2023 02:50:20 +0000 (02:50 +0000)
commit6b97f396e6e268601fac699569c3b249b5cf0970
tree443a7fb6fd7ed1ba1db47616d16a94fb8d40c264
parentb481e3ae57b1bdd841e95b0dd4a49ac873616998
nir/lower_clip: Only emit 1 discard

If we have multiple clip planes, rather than emit multiple discards we can just
OR together the discard criteria. Then a nir_opt_algebraic rule kicks in to
optimize out the flt/.../flt/ior/.../ior into fmin/.../fmin/flt, generating
much less code at the end.

Written while debugging an unrelated issue with the clip lowering.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21103>
src/compiler/nir/nir_lower_clip.c