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: f2236065b7 ("v3dv: port dynamic state tracking to use Mesa Vulkan")
Cc: mesa-stable

Reviewed-by: Juan A. Suarez Romero <jasuarez@igalia.com>
Reviewed-by: Jose Maria Casanova Crespo <jmcasanova@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29603>
This commit is contained in:
Alejandro Piñeiro
2024-06-07 13:50:27 +02:00
committed by Marge Bot
parent 8cd53d95fe
commit f017beb29c

View File

@@ -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) {