Many of the optimization/lowering passes in NIR require different bits of metadata that are provided by different analysis passes. Currently, this metadata includes:
and it’s expected that there will be more in the future. The metadata itself is currently directly embedded inside the IR datastructures (for example, each basic block contains information about its parent and children in the dominance tree), but we still need a way to calculate the metadata only when actually required. In order to do this, there’s a simple API made of two functions:
Unfortunately, there’s no way to guarantee that you actually call nir_metadata_preserve() if you change the shader, so if you don’t... shame on you.