From f017beb29ce6e3469da33caff2c9a493799faca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Pi=C3=B1eiro?= Date: Fri, 7 Jun 2024 13:50:27 +0200 Subject: [PATCH] v3dv/pipeline: ensure vk_graphics_pipeline_all_state alive when still needed Right now we have a statically allocated vk_graphics_pipeline_state, that we declare at pipeline_init, and fill at pipeline_init_dynamic_state. This one can be static as right now it is only needed during pipeline_init lifetime. But to fill it, we need a vk_graphics_pipeline_all_state structure, that right now we declare at pipeline_init_dynamic_state. But that one become part of that vk_graphics_pipeline_state, so still needed at pipeline_init. This was detected when trying to refactor the code to use the pipeline_state later on, but it raises an "invalid read" error using valgrind with the current code. It is surprising that didn't cause any problem. Fixes: f2236065b70 ("v3dv: port dynamic state tracking to use Mesa Vulkan") Cc: mesa-stable Reviewed-by: Juan A. Suarez Romero Reviewed-by: Jose Maria Casanova Crespo Part-of: --- src/broadcom/vulkan/v3dv_pipeline.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/broadcom/vulkan/v3dv_pipeline.c b/src/broadcom/vulkan/v3dv_pipeline.c index 5fca36f0d01..289232b5f3d 100644 --- a/src/broadcom/vulkan/v3dv_pipeline.c +++ b/src/broadcom/vulkan/v3dv_pipeline.c @@ -2825,14 +2825,14 @@ pipeline_setup_rendering_info(struct v3dv_device *device, static VkResult pipeline_init_dynamic_state(struct v3dv_device *device, struct v3dv_pipeline *pipeline, + struct vk_graphics_pipeline_all_state *pipeline_all_state, struct vk_graphics_pipeline_state *pipeline_state, const VkGraphicsPipelineCreateInfo *pCreateInfo) { VkResult result = VK_SUCCESS; - struct vk_graphics_pipeline_all_state all; result = vk_graphics_pipeline_state_fill(&pipeline->device->vk, pipeline_state, pCreateInfo, &pipeline->rendering_info, 0, - &all, NULL, 0, NULL); + pipeline_all_state, NULL, 0, NULL); if (result != VK_SUCCESS) return result; @@ -2902,8 +2902,9 @@ pipeline_init(struct v3dv_pipeline *pipeline, pCreateInfo->pInputAssemblyState; pipeline->topology = vk_to_mesa_prim[ia_info->topology]; + struct vk_graphics_pipeline_all_state all; struct vk_graphics_pipeline_state pipeline_state = { }; - result = pipeline_init_dynamic_state(device, pipeline, &pipeline_state, + result = pipeline_init_dynamic_state(device, pipeline, &all, &pipeline_state, pCreateInfo); if (result != VK_SUCCESS) {