nir: Add a pass for combining ray queries
We can combine ray queries that are not used 'simultaneously', meaning query b's first use is after a's last use. This can save some scratch and it allows us to use lds stacks with more ray queries.
fossil-db Quake II RTX (Navy Flounder):
Totals from 5 (10.20% of 49) affected shaders:
CodeSize: 139436 -> 139572 (+0.10%); split: -0.03%, +0.13%
Scratch: 214016 -> 116736 (-45.45%)
Instrs: 26248 -> 26260 (+0.05%); split: -0.05%, +0.10%
Latency: 384384 -> 384508 (+0.03%); split: -0.06%, +0.09%
InvThroughput: 85383 -> 85406 (+0.03%); split: -0.06%, +0.09%
Copies: 3545 -> 3535 (-0.28%); split: -0.51%, +0.23%
Branches: 1263 -> 1264 (+0.08%)
PreVGPRs: 444 -> 439 (-1.13%)
/cc @llandwerlin
Edited by Konstantin Seurer