st/mesa: Limit GL_MAX_[NATIVE_]PROGRAM_PARAMETERS_ARB to 2048

Piglit's vp-max-array test creates a vertex program containing a uniform
array sized to the value of GL_MAX_NATIVE_PROGRAM_PARAMETERS_ARB.  Mesa
will then add additional state-var parameters for things like the MVP
matrix.

radeonsi currently exposes a value of 4096, derived from constant buffer
upload size.  This means the array will have 4096 elements, and the
extra MVP state-vars would get a prog_src_register::Index of over 4096.

Unfortunately, prog_src_register::Index is a signed 13-bit integer, so
values beyond 4096 end up turning into negative numbers.  Negative
source indexes are only valid for relative addressing, so this ends up
generating illegal IR.

In prog_to_nir, this would cause an out of bounds array access.
st_mesa_to_tgsi checks for a negative value, assumes it's bogus,
and remaps it to parameter 0 in order to get something in-range.
This isn't right - instead of reading the MVP matrix, it would read
the first element of the vertex program's large array.  But the test
only checks that the program compiles, so we never noticed that it
was broken.

This patch limits the size of the program limits, with the understanding
that we may need to generate additional state-vars internally.  i965 has
exposed 1024 for this limit for years, so I don't expect lowering it to
2048 will cause any practical problems for radeonsi or other drivers.

Fixes vp-max-array with prog_to_nir.c.

Cc: "19.0" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
25 jobs for st-params-limit
Status Job ID Name Coverage
  Containers Build
canceled #109915
containers:ubuntu

 
  Build+Test
canceled #109930
build:make-gallium-drivers-other

canceled #109929
build:make-gallium-drivers-radeonsi

canceled #109928
build:make-gallium-drivers-swr

canceled #109931
build:make-gallium-st-clover-llvm-39

canceled #109932
build:make-gallium-st-clover-llvm-4

canceled #109933
build:make-gallium-st-clover-llvm-5

canceled #109934
build:make-gallium-st-clover-llvm-6

canceled #109935
build:make-gallium-st-clover-llvm-7

canceled #109936
build:make-gallium-st-other

canceled #109927
build:make-loader-classic-dri

canceled #109926
build:make-vulkan

canceled #109922
build:meson-gallium-clover-llvm5

canceled #109923
build:meson-gallium-clover-llvm6

canceled #109924
build:meson-gallium-clover-llvm7

canceled #109921
build:meson-gallium-drivers-other

canceled #109920
build:meson-gallium-radeonsi

canceled #109925
build:meson-gallium-st-other

canceled #109919
build:meson-gallium-swr

canceled #109918
build:meson-glvnd

canceled #109917
build:meson-loader-classic-dri

canceled #109916
build:meson-vulkan

canceled #109938
build:scons-llvm

canceled #109937
build:scons-nollvm

canceled #109939
build:scons-swr