Files
libretroadmin 895b8ccaf8 renderer/cm: the bump allocators keep their allocations aligned
R_FrameAlloc rounds every request to 16 but handed out memory from a
block whose payload began at offset 20 on 64-bit: the header's pad was
sized for 32-bit pointers, and the block itself came from Mem_Alloc,
which promises 8. Every view, draw surface, render command and vertex
array of a frame was therefore 4 bytes off its alignment, which UBSan
reported on nearly a thousand accesses per run and which costs unaligned
loads on every one of them. The header is now padded to a multiple of
16 on either pointer width and the blocks come from Mem_Alloc16, and
the struct moves to renderer/frame_block.h so the layout can be checked
on its own.

The collision model polygons sit end to end in one block at their
exact byte size, and edges[] is 4 bytes an entry, so an odd edge count
left the next polygon's pointer and bounds on a 4 byte boundary. One
measure, CM_PolygonSize, rounds the stride to 8 for the allocator, the
free accounting and the block size the .cm writer records; a .cm sized
by the old measure runs its block out a few polygons early and those
take the allocator's existing fallback.

tools/alignment checks the frame block layout at the 64-bit and, where
the toolchain has -m32, the 32-bit layout, and the polygon stride; both
fail on the old code, and the Linux workflow runs them.
2026-10-17 16:19:10 +02:00
..