panfrost: do not write outside num_wg_sysval

This array has 3 components, because it's meant to hold the X, Y and Z
components of the work-group size sysval. However, mir_pick_ubo assumes
vec4 for the push-uniforms, which ends up promoting this to 4
components.

So let's make sure we don't write that last component. It's not going to
do anything good.

In practice, this leads to the viewport descriptor being smashed, which
doesn't actually do any real-world harm, because this only happens in
compute batches where that descriptor is unused. However, writing
outside of arrays is undefined behavior, so we should fix it regardless.

Fixes: 5006167061 ("panfrost: Hook-up indirect dispatch support")
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28856>
(cherry picked from commit 186f7fa915)
This commit is contained in:
Boris Brezillon 2024-04-26 09:29:10 +00:00 committed by Eric Engestrom
parent a983e8dcbf
commit c2dc7eff44
2 changed files with 3 additions and 2 deletions

View file

@ -1304,7 +1304,7 @@
"description": "panfrost: do not write outside num_wg_sysval",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "500616706148d2e340bbdfecad45204b515ae9b5",
"notes": null

View file

@ -1380,7 +1380,8 @@ panfrost_emit_const_buf(struct panfrost_batch *batch,
PAN_SYSVAL_TYPE(ss->sysvals.sysvals[sysval_idx]);
mali_ptr ptr = push_transfer.gpu + (4 * i);
if (sysval_type == PAN_SYSVAL_NUM_WORK_GROUPS)
if (sysval_type == PAN_SYSVAL_NUM_WORK_GROUPS &&
sysval_comp < ARRAY_SIZE(batch->num_wg_sysval))
batch->num_wg_sysval[sysval_comp] = ptr;
}
/* Map the UBO, this should be cheap. For some buffers this may