Skip to content

Draft: r300: move the NIR optimization passes from ntt to the driver

Pavel Ondračka requested to merge ondracka/mesa:r300_nir into main

I stated to write a NIR pass for #6661 and than I got stuck because the pass needs to be called just before we do the translation but after we go out of the ssa and do vec to movs. Currently we can only can run custom passes before we call ntt. I considered adding it to ntt and hide it behind some option, however this example pass (last patch here, but mostly just for illustration at this moment) is very hardware specific, so probably not suitable for a common code.

The idea in this patchset is that we move the optimization logic to the driver, so we can customize the optimization passes run before the translation happens and only call ntt_emit_impl manually to do the final NIR to TGSI conversion.

Whether this is the right way how to do it is currently unclear. I had to expose some internal ntt functions in the headers. I put them into nir_to_tgsi.h for now, but since it now includes also nir.h and some tgsi header as well, that is maybe not such a good idea. I can put them also into separate header? This is now in very early state and I did not put too much time into cleaning it yet (for example I think the pass sequence could be quite simplified now that it is just for the r300 driver), but ATM I'm looking for some general feedback whether this is a way to go, or what would be the alternatives. CCing NIR gurus @anholt @jekstrand

The plan is to evolve this into a NIR->r300 compiler pass in the long run, however currently I have neither the time nor the skills to do that, so this could be something like a stepping stone, allowing me to add custom r300 NIR passes and get some NIR experience before ditching the remaining ntt pieces completely and writing a direct NIR to r300 compiler translation.

I have more plans to build on top of this patches. For example currently we call bool and int lowering quite late, so we can't really lower some opcodes that come out of it like TRUNC or CMP, so doing it earlier or alternatively adding some opts after it could also help a bit.

Merge request reports

Loading