nir: fix several crashes in `nir_lower_tex`
authorantonino <antonino.maniscalco@collabora.com>
Mon, 9 Oct 2023 14:51:11 +0000 (16:51 +0200)
committerMarge Bot <emma+marge@anholt.net>
Mon, 9 Oct 2023 17:31:34 +0000 (17:31 +0000)
commita2e96a86e1c3fa1dd28e480733cd0a8085208de6
tree52d4c3e9860ed6ab5e446a40ff9112e1d2688554
parente9e6a6760055e17699b8bcf14b94e7e5196f2a2d
nir: fix several crashes in `nir_lower_tex`

This patch fixes the following issues that lead to crashes in some cases:

* an instruction is inserted to get texture lod that depends on a
  texture instruction that hasn't been inserted yet.
* this code tries to read channel 1 of the lod, but lod is scalar
* the code assumed there would only be 2 srcs, this isn't the case when
  bindless is used.

Fixes: b154a4154b4 ("nir/lower_tex: rewrite tex/txb -> txd/txl before saturating srcs")
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25621>
src/compiler/nir/nir_lower_tex.c