nir: ViewID/LayerID & input attachment cleanups, improvements for turnip
On qualcomm hardware, gl_Layer
and gl_ViewIndex
are both inputs in the FS stage, and both are completely independent of each other. There is a special multiview mode, and when enabled, there's a separate field where we tell the hardware which input to overwrite with gl_ViewIndex
and the normal gl_Layer
field doesn't work. However gl_ViewIndex
in the VS works like other VS sysvals (gl_VertexID
, gl_PrimitiveID
, etc.)
In order to avoid driver-specific workarounds, I've made a few changes to core NIR:
- Add an option to make
gl_ViewIndex
an input, for fragment shaders on turnip. - When lowering input attachments, and we need the layer id to pass as the array index to
txf
, add the option to usegl_Layer
as an input orgl_ViewIndex
as an input. radv also wantsgl_Layer
as an input, so I've switched it over.
As a bonus, this cleans up radv a bit and fixes input attachments with layered rendering on turnip.