dzn, nir: Enable mediump
I've been told that handling RelaxedPrecision
SPIR-V annotations (aka mediump) can be a significant perf win, and we should respect it. The best way to respect it would be to map it to the equivalent in DXIL, which is the concept of min-precision, so the D3D driver can then make the right call on what bit-size to use for the data. There's one mismatch though, which is that RelaxedPrecision
is specified per-operation, while min-precision is specified for the entire shader.
Oh well. The approach this MR takes is:
- Allow the backend to differentiate between mediump conversions vs required 16-bit conversions. E.g.
(i2imp, i2i32)
pairs can be removed, while(i2i16, i2i32)
pairs cannot, and must actually result in a different value for out-of-range data. - When the DXIL backend sees the only producers of 16-bit data is mediump conversions and ALU ops, it annotates the shader with the min-precision tag. Once there's a concrete conversion or a load/store to externally-visible memory, all 16-bit types now become native 16-bit.
- Dozen enables mediump for vtn, and only sets the lower-16-bit option when native 16-bit stuff could be getting to the backend. Ideally we'd have a per-shader way of setting this, but there's no feedback from vtn right now on which extensions a shader used, AFAICT, so we just base it on whether the device set it. I think this is actually a no-op right now, since we only claim 16-bit support on drivers were native 16-bit is available, but I wouldn't be surprised if we need a driconf entry to change that in the future...