From 7af000a6eca46ab17b2252ff20451dc33f654749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Francis=20Ratt=C3=A9-Boulianne?= Date: Fri, 11 Oct 2024 16:37:12 -0400 Subject: [PATCH] panfrost: initialize all UBO and vertex buffer descriptors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Boris Brezillon Part-of: --- src/gallium/drivers/panfrost/pan_cmdstream.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index 7b94711ca88..bf0995bd45b 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -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);