panfrost: initialize all UBO and vertex buffer descriptors

When tracing the command stream with PAN_MESA_DEBUG=trace, all
descriptors are read and decoded. Trying to read an invalid or old
descriptor might cause confusion or (more importantly) a crash.

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31768>
This commit is contained in:
Louis-Francis Ratté-Boulianne 2024-10-11 16:37:12 -04:00 committed by Marge Bot
parent 834b919f6a
commit 7af000a6ec

View File

@ -856,6 +856,8 @@ panfrost_emit_vertex_buffers(struct panfrost_batch *batch)
pan_pool_alloc_desc_array(&batch->pool.base, buffer_count, BUFFER);
struct mali_buffer_packed *buffers = T.cpu;
memset(buffers, 0, sizeof(*buffers) * buffer_count);
u_foreach_bit(i, ctx->vb_mask) {
struct pipe_vertex_buffer vb = ctx->vertex_buffers[i];
struct pipe_resource *prsrc = vb.buffer.resource;
@ -1404,14 +1406,18 @@ panfrost_emit_const_buf(struct panfrost_batch *batch,
struct panfrost_compiled_shader *shader = ctx->prog[stage];
unsigned ubo_count = shader->info.ubo_count - (sys_size ? 1 : 0);
unsigned sysval_ubo = sys_size ? ubo_count : ~0;
unsigned desc_size;
struct panfrost_ptr ubos = {0};
#if PAN_ARCH >= 9
desc_size = sizeof(struct mali_buffer_packed);
ubos = pan_pool_alloc_desc_array(&batch->pool.base, ubo_count + 1, BUFFER);
#else
desc_size = sizeof(struct mali_uniform_buffer_packed);
ubos = pan_pool_alloc_desc_array(&batch->pool.base, ubo_count + 1,
UNIFORM_BUFFER);
#endif
memset(ubos.cpu, 0, desc_size * (ubo_count + 1));
if (buffer_count)
*buffer_count = ubo_count + (sys_size ? 1 : 0);