Fix persistent shader cache never hitting for materials


Materials are not read from the persistent (disk-based cache) anymore,
even though something is saved, and so claims the qt.quick3d.cache
logging category too. With QT_RHI_SHADER_DEBUG=1 it shows however that
all materials are generated every time, and nothing is picked from the
cache.

This is not great, when it comes to performance and hitches when a
new material is encountered in the scene.

The key used for looking up shaders in the persistent (disk) cache got
out of sync with the key the entries were stored under: the lookup
includes the augmentation preamble and body (and, for default materials,
two ';' separators even when there is no augmentation), whereas the
stored key only contained the material key and the defines, because the
same string is also used as the shader name in a comment in the
generated source. As a result, all default material shaders were
generated and baked again on every run. The same mismatch affected the
in-memory cache lookup in generateRhiShaderPipelineImpl(), and, when
augmentation defines were present, custom materials as well.

Separate the shader name from the cache key: the callers now pass the
exact string they used for the lookup down to compileForRhi(), which
uses it for both the in-memory and persistent caches.

Amends 0afcd7759e6972716c7d0f596e57460c7d7864aa

Pick-to: 6.12 6.12.0 6.11.3
Fixes: QTBUG-150763
Change-Id: I65ab73c12f6fcf409e6d11c2238b61bdacee57ee
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
commit8396e7d2219a176931a85908c421f5f5077f07d0
parentfe0d94d15c8a50d449ed2272aa84de46990dd10e
authorLaszlo Agocs <laszlo.agocs@qt.io>
committerLaszlo Agocs <laszlo.agocs@qt.io>
commit timeFri, 25 Sep 2026 07:17:29 +0000