ac/nir: fix out-of-bound access when loading constants from global
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Tue, 10 Dec 2019 16:46:26 +0000 (17:46 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 12 Dec 2019 10:12:56 +0000 (10:12 +0000)
commita0f1a5fa051786c16de6f0062771051f8565daec
treef2423b03ceb0fe84a2c927ac43183b713038d415
parent2c5eb1df681e28c23e24219eab803b6d4da5aa38
ac/nir: fix out-of-bound access when loading constants from global

Global load/store instructions can't know if the offset is
out-of-bound because they don't use descriptors (no range).

Fix this by clamping the offset for arrays that are indexed
with a non-constant offset that's greater or equal to the array
size.

This fixes VM faults and GPU hangs with Dead Rising 4.

Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/2148
Fixes: 71a67942003 ("ac/nir: Enable nir_opt_large_constants")
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/llvm/ac_nir_to_llvm.c