Fix out-of-bounds access when culling depth sorted LOD instances


The depth sorted call site passed a byte count where cullLodInstances()
expects a number of QSSGRenderInstanceTableEntry, so the loop ran 80
times too many iterations, reading past the end of the source buffer and
writing past the end of the destination. Plain QML is enough to trigger
it, and the corruption is severe enough to crash.

Convert both helpers to take spans of entries, so the byte count to
entry count conversion happens in one place and the call sites cannot
disagree about which of the two they pass. The conversion clamps to what
the buffer can hold, which also covers sortInstances(), where nothing
guaranteed that the advertised instance count fit in the table data. The
two LOD call sites are now identical and merged, and the stride
assertion moves to prepareInstancing() so it covers culling as well.

The new autotest renders instances at three known distances with various
thresholds and verifies that exactly the ones within them are drawn.
Without this fix the depth sorted rows abort the test.

The test is blacklisted on Android, where the emulator's GLES translator
refuses the instanced vertex attribute arrays of the LOD culled draws
and keeps its previous attribute state instead, putting the instances
somewhere other than where the thresholds asked for. The rows without
culling render correctly there, so the culling itself is fine.

Fixes: QTBUG-148789
Pick-to: 6.12 6.11 6.8
Change-Id: I5bfebbac32ac5f6b0c79c5f1035cbd54d3f4ed86
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
commit62116be041a3f744ec7fb951599c392d45cbdf82
parentc9acf91973b86c1f956dfabd20ccaa09a24c23bc
authorAndy Nichols <andy.nichols@qt.io>
committerAndy Nichols <andy.nichols@qt.io>
commit timeFri, 7 Aug 2026 09:10:11 +0000