v3dv: ref pipeline layout earlier during pipeline init

If we fail to init the pipeline the callee will then destroy it
and if we had assigned the layout to the pipeline it will try to
unref it, so make sure we ref it right after assigning it.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7206
Fixes: dEQP-VK.api.object_management.alloc_callback_fail_multiple.graphics_pipeline
Fixes: 14dab6b10c ('v3dv: ref/unref pipeline layout objects')
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18426>
This commit is contained in:
Iago Toral Quiroga 2022-09-06 07:55:22 +02:00 committed by Marge Bot
parent 699e3452d0
commit 92b3ae6ed9

View file

@ -2928,6 +2928,7 @@ pipeline_init(struct v3dv_pipeline *pipeline,
V3DV_FROM_HANDLE(v3dv_pipeline_layout, layout, pCreateInfo->layout);
pipeline->layout = layout;
v3dv_pipeline_layout_ref(pipeline->layout);
V3DV_FROM_HANDLE(v3dv_render_pass, render_pass, pCreateInfo->renderPass);
assert(pCreateInfo->subpass < render_pass->subpass_count);
@ -3026,8 +3027,6 @@ pipeline_init(struct v3dv_pipeline *pipeline,
/* This must be done after the pipeline has been compiled */
pipeline_set_ez_state(pipeline, ds_info);
v3dv_pipeline_layout_ref(pipeline->layout);
return result;
}
@ -3267,13 +3266,12 @@ compute_pipeline_init(struct v3dv_pipeline *pipeline,
pipeline->device = device;
pipeline->layout = layout;
v3dv_pipeline_layout_ref(pipeline->layout);
VkResult result = pipeline_compile_compute(pipeline, cache, info, alloc);
if (result != VK_SUCCESS)
return result;
v3dv_pipeline_layout_ref(pipeline->layout);
return result;
}