v3dv: don't leak NIR code in pipelines
authorIago Toral Quiroga <itoral@igalia.com>
Thu, 23 Apr 2020 07:59:05 +0000 (09:59 +0200)
committerMarge Bot <eric+marge@anholt.net>
Tue, 13 Oct 2020 21:21:29 +0000 (21:21 +0000)
commit77bccfd828af6f4503b2351c0c9f27958b1d478f
tree34b4779085a4c204e7379da44adcd97374e4a1cb
parentc414a241d0d6da83998cfabe4560f3b515609a4c
v3dv: don't leak NIR code in pipelines

The pipeline stages have a reference to the NIR code produced from
the SPIR-V shader modules, but they never destroy it.

It should also be noted that our coordinate shader stage was sharing
the NIR with the vertex shader stage, which is kind of tricky to handle
and probably very error prone. Just make sure each pipeline stage has
owns it NIR shader and that we always free it when the stage is
destroyed.

Also, for the case of NIR modules created by the driver internally,
we always need to clone them, since the driver will destroy the NIR
as soon as it is done creating pipelines with it. We could also not
clone it and let the pipeline stage take ownership of the NIR code for
NIR modules, but that would be inconsistent with how ownership works for
SPIR-V modules.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
src/broadcom/vulkan/v3dv_pipeline.c