This is already done in QRhiCommandBuffer (because recording draw calls has higher frequency than e.g. pipeline (re)creation), perhaps expand to the whole api (to reduce allocations).
As found out during
QTBUG-78792, there are further potential pitfalls with the following approach:
Especially in QRhiShaderResourceBinding, where one may create a QRhiShaderResourceBinding set just to look up an srb in a cache (e.g. a QHash). This is very heavy as it stands since one has to create a QVector of d-pointered class. This is extremely wasteful when there is a cache hit since we did all those allocs for nothing basically.
Note that this does not cover the freely copyable "description" structs like QRhiVertexInputLayout. Those should be looked at separately, if moving away from QVector is sensible and if it would bring any visible improvements in practice.