Merge glyph-cache resource updates once per prepare, not per draw
QCDistanceFieldGlyphCache::commitResourceUpdates() was called from
populateFont()/populateFontFromShapedText(), i.e. once per
fillText()/fillShapedText() call, even though all it does is merge
each per-font cache's pending update batch into the shared
QRhiResourceUpdateBatch - a QHash<FontKey,FontKeyData> iteration paid
on every single draw for work that only needs to happen once per
prepare/submit cycle.
Moved the general call to endPrepare(), right after the batch is
obtained and guarded by the same rhiCtx->callsCount > 0 check
populateFont() could only have run under anyway; also added a
per-font overload, commitResourceUpdates(batch, FontKeyData*), called
right after generate()/generateFromShapedText() for the font just
touched, since leaving its pending batch
(QCRhiDistanceFieldGlyphCache::m_batch) open for the whole frame
instead of releasing it per draw risks exhausting QRhi's
resource-update-batch pool once a frame uses more distinct fonts than
it holds. Safe because getCurrentTextures()/getOldTextures() only read
state generate()/generateFromShapedText() already set up directly, and
commitResourceUpdates() itself only merges pending upload commands
into the batch, never touching texture objects.
Confirmed via callgrind on a text-heavy fillShapedText() workload:
commitResourceUpdates() call count drops from 300,000 (once per draw)
to 29 (once per frame) over a 30-frame run, and its cost drops out of
the profile entirely.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Pick-to: 6.12
Change-Id: Ice9ba0dbb5be466e14bff06edd88fb22318489a9
Reviewed-by: Kaj Grönholm <kaj.gronholm@qt.io>