From ba5c65f10b453ec71264027119e390e11e7aae21 Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Sun, 17 Nov 2024 22:07:53 -0500 Subject: [PATCH] nir: Get correct number of components The code wants the number of components used by the variable in the current attribute slot, not the total number of components. For e.g. a 4x3 matrix, glsl_get_components() returns 12, leading to the following error reported by AddressSanitizer: ``` Test case 'dEQP-VK.tessellation.shader_input_output.cross_invocation_per_patch_mat4x3'.. ../src/compiler/nir/nir_lower_io_to_vector.c:265:16: runtime error: index 4 out of bounds for type 'nir_variable *[4]' ``` Fixes: 5ef2b8f1f2e ("nir: Add a pass for lowering IO back to vector when possible") Part-of: --- src/compiler/nir/nir_lower_io_to_vector.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/nir/nir_lower_io_to_vector.c b/src/compiler/nir/nir_lower_io_to_vector.c index 3c7eb5a94e7..ef54b3c5268 100644 --- a/src/compiler/nir/nir_lower_io_to_vector.c +++ b/src/compiler/nir/nir_lower_io_to_vector.c @@ -253,7 +253,7 @@ create_new_io_vars(nir_shader *shader, nir_variable_mode mode, } const unsigned num_components = - glsl_get_components(glsl_without_array(var->type)); + glsl_get_vector_elements(glsl_without_array(var->type)); if (!num_components) { assert(frac == 0); frac++;