Mesa (main): nir/lower_tex: don't calculate texture_mask for texture_index>=32
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Nov 24 17:28:42 UTC 2021
Module: Mesa
Branch: main
Commit: 811a7a2d31ec3f510f2aafa390a0ae148da3e039
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=811a7a2d31ec3f510f2aafa390a0ae148da3e039
Author: Rhys Perry <pendingchaos02 at gmail.com>
Date: Thu Sep 16 17:24:46 2021 +0100
nir/lower_tex: don't calculate texture_mask for texture_index>=32
With Vulkan, texture_index can be 32 or larger, which creates a shift
exponent larger than 31 (undefined behaviour). Since we don't use
texture_mask with Vulkan, just initialize it to 0.
Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Gitlab: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5365
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12901>
---
src/compiler/nir/nir_lower_tex.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/compiler/nir/nir_lower_tex.c b/src/compiler/nir/nir_lower_tex.c
index 30aa1e75249..f94d5e08a88 100644
--- a/src/compiler/nir/nir_lower_tex.c
+++ b/src/compiler/nir/nir_lower_tex.c
@@ -1311,7 +1311,7 @@ nir_lower_tex_block(nir_block *block, nir_builder *b,
nir_deref_instr *deref = nir_src_as_deref(tex->src[tex_index].src);
nir_variable *var = nir_deref_instr_get_variable(deref);
texture_index = var ? var->data.binding : 0;
- texture_mask = var ? (1u << texture_index) : 0u;
+ texture_mask = var && texture_index < 32 ? (1u << texture_index) : 0u;
}
if (texture_mask & options->lower_y_uv_external) {
More information about the mesa-commit
mailing list