Skip to content

intel: Add an MI command builder

Faith Ekstrand requested to merge gfxstrand/mesa:review/mi-builder into master

This is inspired by nir_builder and the work I've been doing on the new ibc_builder. The idea is to make it easier to produce MI commands, especially MI_MATH. Eventually, I would also like to extend this to looping and indirect loads if we decide we want to try to implement MultiDrawIndirect with them. (I'd be way more comfortable with self-modifying batches in the context of a carefully controlled builder than hand-rolled.) It's technically more lines of code the the hand-rolling we're doing today but, IMO, it's a lot more readable. The biggest advantage to the builder is that it reference-counts the ALU GPRs so we can do piles of ALU math back-to-back without moving registers around constantly or having to carefully hand-allocate to ensure we never stomp anything.

There are two things I'm not super happy about right now but neither are all that important:

  1. I does a pretty good job of avoiding unneeded moves but there is a case in ANV conditional rendering handling where we want the result of some ALU math to be stored in a specific register and right now, due to the way all math functions return values, we end up with an extra copy.

  2. A lot of the time we only really want 32-bit math but right now we always return 64-bit values from math operations and, if we need to make a copy of a value into a GPR, fill the top bits with zero. There are a number of math operations such as add and multiply that can safely be done on just a 32-bit value and throw away the other bits. This would let us do a bit less register zeroing.

Neither of these are a big deal. It's a few more MI_REG commands but nothing which touches memory (that would get expensive).

Merge request reports