ir_constant: Return zero on out-of-bounds vector accesses
authorDanylo Piliaiev <danylo.piliaiev@globallogic.com>
Mon, 17 Aug 2020 15:13:24 +0000 (18:13 +0300)
committerMarge Bot <eric+marge@anholt.net>
Fri, 21 Aug 2020 15:00:51 +0000 (15:00 +0000)
commite93979ba599355c42df01a89073362b970489a3a
treecf86e58ede170a4e337bc9e80340ee5592a808f5
parentb243a74768ed86410b27617f81880b24a84eda89
ir_constant: Return zero on out-of-bounds vector accesses

Several optimization paths, including constant folding, can lead to
accessing an ir_constant vector with an out of bounds index.

Return 0 since GL_ARB_robustness and GL_KHR_robustness encourage
us to do so.

Fixes piglit tests:
spec@glsl-1.20@execution@vector-out-of-bounds-access@fs-vec4-out-of-bounds-2
spec@glsl-1.20@execution@vector-out-of-bounds-access@fs-vec4-out-of-bounds-4
spec@glsl-1.20@execution@vector-out-of-bounds-access@fs-vec4-out-of-bounds-5

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2604
CC: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Danylo Piliaiev <danylo.piliaiev@globallogic.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Marcin Ĺšlusarz <marcin.slusarz@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6363>
.gitlab-ci/piglit/quick_shader.txt
src/compiler/glsl/ir.cpp