Skip to content

asahi: Implement color masks with masked stores

Alyssa Rosenzweig requested to merge alyssa/mesa:agx/cmask into main

Blend states can require masking colour. Currently, this is handled by nir_lower_blend, which lowers masks to a read-modify-write operation as required on Mali hardware. However, our "tilebuffer store" instruction supports a write mask, allowing us to write only a subset of channels to the tilebuffer. It's more efficient to use that than to emit pointless tilebuffer loads.

Note that even without tilebuffer loads, non-opaque masks don't work with opaque pass types. Here, we handle this with a translucent pass type, which gets HSR to do the right thing and is consistent with the pass type used previously. However, it's a bit heavy handed -- Apple manages to use an opaque pass type with masking but with some unknown HSR fields twiddled. IMO reverse-engineering those details shouldn't block this because this gets us closer to optimal (just not all the way there) and is strictly better than what we had before.

Merge request reports