freedreno+turnip: Upload large shader constants as a UBO.
authorEric Anholt <eric@anholt.net>
Tue, 7 Jul 2020 18:56:35 +0000 (11:56 -0700)
committerEric Anholt <eric@anholt.net>
Mon, 16 Nov 2020 21:55:41 +0000 (13:55 -0800)
commit1f44053301339e64ef070ac8ad81a0ba3f073310
treec81ca2ccbd8b92214aeb6d1f852bdd2a500951ca
parent17db969f7a39c128bf02238a7a6f1243d78476f1
freedreno+turnip: Upload large shader constants as a UBO.

Right now if the shader indirects on some large constant array, we see NIR
load_consts (usually from the const file) of its contents into general
registers, then indirection on the GPRs.  This often results in register
allocation failures, as it's easy to go beyond the ~256 dwords of
registers per invocation.

By moving the large constants to a UBO, we can load an arbitrary number of
them.  They also can be theoretically moved to the constant reg file (~2k
dwords), though you're unlikely to hit this path without an indirect load
on your large constant, and we don't yet let UBO indirect loads get moved
to constant regs.

This possibly won't work out right if we have 16-bit load_constants, but
without other MRs in flight we won't see 16-bit temps to be lowered to
this.

This allows 2 kerbal-space-program shaders to compile that previously
would fail, and fixes the new dEQP-VK and -GLES2 tests I wrote that
dynamically index a 40-element temporary array of float/vec2/vec3/vec4
with constant element initializers.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2789
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5810>
15 files changed:
.gitlab-ci/deqp-freedreno-a307-fails.txt
.gitlab-ci/deqp-freedreno-a630-fails.txt
src/freedreno/computerator/ir3_asm.c
src/freedreno/ir3/ir3.c
src/freedreno/ir3/ir3.h
src/freedreno/ir3/ir3_disk_cache.c
src/freedreno/ir3/ir3_nir.c
src/freedreno/ir3/ir3_nir.h
src/freedreno/ir3/ir3_nir_analyze_ubo_ranges.c
src/freedreno/ir3/ir3_shader.h
src/freedreno/vulkan/tu_cmd_buffer.c
src/freedreno/vulkan/tu_pipeline.c
src/gallium/drivers/freedreno/a6xx/fd6_const.c
src/gallium/drivers/freedreno/ir3/ir3_const.h
src/gallium/drivers/freedreno/ir3/ir3_gallium.c