panfrost: Emit the correct number of attributes
authorIcecream95 <ixn@disroot.org>
Sun, 10 Jul 2022 08:52:54 +0000 (20:52 +1200)
committerMarge Bot <emma+marge@anholt.net>
Sat, 23 Jul 2022 00:56:10 +0000 (00:56 +0000)
commit379ae6d82383e0c70797d96de4e6966c972618fc
treef03ec554a454ec85f998c1905a3562c4b006abc6
parentfe613a8de95a95a3c44bd47c80316830ab10945e
panfrost: Emit the correct number of attributes

create_vertex_elements_state is sometimes called with a too large
num_elements argument, for example with util_blitter, which causes a
buffer overflow.

There is no documentation to forbid this practice, so don't rely on
so->num_elements being correct and instead use the vertex shader
attribute count, which matches the value used to allocate the
descriptors.

Use attributes_read_count rather than attribute_count because the
latter also includes images and PAN_VERTEX_ID/PAN_INSTANCE_ID.

Fixes: 76de3e691c6 ("panfrost: Merge attribute packing routines")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17447>
src/gallium/drivers/panfrost/pan_cmdstream.c
src/panfrost/lib/pan_shader.c
src/panfrost/util/pan_ir.h