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: 5ef2b8f1f2 ("nir: Add a pass for lowering IO back to vector when possible")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32193>
This commit is contained in:
Matt Turner
2024-11-17 22:07:53 -05:00
committed by Marge Bot
parent cf36fc134e
commit ba5c65f10b

View File

@@ -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++;