nir_to_tgsi: Extract const components of atomic counter offsets into Index.
authorEmma Anholt <emma@anholt.net>
Tue, 5 Apr 2022 16:45:36 +0000 (09:45 -0700)
committerMarge Bot <emma+marge@anholt.net>
Fri, 8 Apr 2022 21:01:42 +0000 (21:01 +0000)
commit664f69a4d5601a46031ebd003ecc917aa7e48773
tree69e59f5e6bf2de1bc317c98ad5e0b45762a6f958
parent8dcf7646ceed42c2b28094667aa24b236baf79c1
nir_to_tgsi: Extract const components of atomic counter offsets into Index.

virglrenderer maps atomic accesses to atomic counter declarations using
the .Index field.  We were previously emitting a .Index of 0 for array
accesses, so virglrenderer would emit
atomicIncrement(first_counter[counter_offset+array_index]).  This would
mostly work because hardware doesn't care about the bounds of counter
declarations, but if the first counter was a non-array, then the [] GLSL
emit gets dropped (can't array access a scalar!) and you'd access the
non-array first_counter instead.

Acked-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15824>
src/gallium/auxiliary/nir/nir_to_tgsi.c