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:
@@ -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++;
|
||||
|
Reference in New Issue
Block a user