Mesa (master): nir: Use VARYING_SLOT_TESS_MAX to size indirect bitmasks

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Oct 25 20:49:59 UTC 2019


Module: Mesa
Branch: master
Commit: f306d079320b328199898b15601ac5633b5781bd
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f306d079320b328199898b15601ac5633b5781bd

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Fri Oct 25 11:18:52 2019 -0700

nir: Use VARYING_SLOT_TESS_MAX to size indirect bitmasks

MAX_VARYINGS_INCL_PATCH subtracts VARYING_SLOT_VAR0 giving us a size
that's too small, so BITSET_SET writes words out of bounds, corrupting
the stack and causing all kinds of chaos.  VARYING_SLOT_TESS_MAX is
the right value to use here, as it's the largest location.

Closes: 2002
Fixes: ee2050b1111 ("nir: Use BITSET for tracking varyings in lower_io_arrays")
Reviewed-by: Kristian H. Kristensen <hoegsberg at google.com>

---

 src/compiler/nir/nir_lower_io_arrays_to_elements.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/compiler/nir/nir_lower_io_arrays_to_elements.c b/src/compiler/nir/nir_lower_io_arrays_to_elements.c
index a0d0eb740db..ca9eb700f94 100644
--- a/src/compiler/nir/nir_lower_io_arrays_to_elements.c
+++ b/src/compiler/nir/nir_lower_io_arrays_to_elements.c
@@ -349,7 +349,7 @@ nir_lower_io_arrays_to_elements_no_indirects(nir_shader *shader,
    struct hash_table *split_inputs = _mesa_pointer_hash_table_create(NULL);
    struct hash_table *split_outputs = _mesa_pointer_hash_table_create(NULL);
 
-   BITSET_DECLARE(indirects, 4 * MAX_VARYINGS_INCL_PATCH) = {};
+   BITSET_DECLARE(indirects, 4 * VARYING_SLOT_TESS_MAX) = {};
 
    lower_io_arrays_to_elements(shader, nir_var_shader_out,
                                indirects, split_outputs, true);
@@ -387,7 +387,7 @@ nir_lower_io_arrays_to_elements(nir_shader *producer, nir_shader *consumer)
    struct hash_table *split_inputs = _mesa_pointer_hash_table_create(NULL);
    struct hash_table *split_outputs = _mesa_pointer_hash_table_create(NULL);
 
-   BITSET_DECLARE(indirects, 4 * MAX_VARYINGS_INCL_PATCH) = {};
+   BITSET_DECLARE(indirects, 4 * VARYING_SLOT_TESS_MAX) = {};
 
    create_indirects_mask(producer, indirects, nir_var_shader_out);
    create_indirects_mask(consumer, indirects, nir_var_shader_in);




More information about the mesa-commit mailing list