Release draw call data when a material is destroyed
Draw call data (the uniform buffer and the cached shader resource
bindings) is keyed on the material, but was only released when the
model was destroyed. A material whose only scene manager reference
comes from a model's materials list, for example one provided by a
QML singleton, has its backend node destroyed on every removal and
recreated on every re-assignment. Each recreation allocated a new
set of entries in the draw call data and srb caches, while the
entries keyed on the destroyed material were left behind until the
model itself was destroyed. Repeatedly swapping between two such
materials would therefore continuously leak its data.
Release the draw call data keyed on a material when the material is
destroyed, the same way it is already done for models. For the
cleanup to find all entries, the key must contain the material/resource
pointer in addition to the map entry it's used with. Previously this was
all conflated into the entry pointer.
Pick-to: 6.12 6.11 6.8
Fixes: QTBUG-149579
Change-Id: Ie7c6b17ee12e79dc23a7ca1335a11e8d4b6917c7
Reviewed-by: Andy Nichols <andy.nichols@qt.io>