Files
libretroadmin 8f1d15fe28 GS/HW: index a paletted texture once it comes with a second palette
The hash cache expands a paletted texture to 32 bits, once for each
palette it is drawn with: four times the indices for an 8-bit texture,
sixteen for a 4-bit one, every time. Ridge Racer V's intro has 27
textures, 7 MB of indices, as 370 MB of expansions. Sources keep them,
so they cannot be purged, and at 1x and 2x they filled the Vulkan heap:
textures were refused and drawn without, a building gone and a face
with only its hair.

The second palette a texture is seen with now makes it an index texture,
shared by every palette and read through them on the GPU, as GPU
palette conversion does for every texture already. A texture drawn with
only one palette stays expanded, as before. Which palette each was
first seen with is kept in a GSFlatMap of 1024 entries, reserved when
the cache is made (gs_flat_map_reserve, new), so nothing is allocated
mid-game; full, it is forgotten at once. Devices that need point samplers
for index textures get them for these too.

Ridge Racer V's intro at 1x and 2x: no texture refused (thousands
before); over 400 frames the pictures are the expanded ones' but for a
few hundred pixels of bilinear rounding, as close to the software
renderer's.

LRPS2_TEST_NO_AUTO_INDEX expands every palette, as before. tests/swdraw's
t4_many_palettes draws a 1024x512 4-bit texture through 48 palettes in a
frame; tests/gsautoindex holds its picture against every palette
expanded, and with a 300 MB heap it refuses nothing and draws the same,
where with every palette expanded it refuses 301 textures (as before
this change) and draws sprites without them. tests/gsflatmap checks the
reserve.
2026-11-02 18:19:29 +01:00
..