Skip to content

Update xxHash to 0.8.3 + Use faster algorithm#1879

Merged
flyinghead merged 1 commit intoflyinghead:devfrom
Xphalnos:master
Mar 22, 2025
Merged

Update xxHash to 0.8.3 + Use faster algorithm#1879
flyinghead merged 1 commit intoflyinghead:devfrom
Xphalnos:master

Conversation

@Xphalnos
Copy link
Contributor

Rework of #1872 for the dev branch

{
u32 hash = XXH32(ram, 0x10000, 0);
u32 hash = XXH3_64bits(ram, 0x10000);
LOGJVS("JVS Firmware hash %08x\n", hash);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous hash values must be preserved here. See the following lines.

// with existing custom texture packs.
int oldSize = width * height / 8;
old_vqtexture_hash = XXH32(&vram[mmStartAddress - VQ_CODEBOOK_SIZE], oldSize, 7);
old_vqtexture_hash = XXH3_64bits(&vram[mmStartAddress - VQ_CODEBOOK_SIZE], oldSize);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the hash value will invalidate all existing texture packs. Obviously we don't want that.

pal_hash_16[i] = XXH3_64bits(&PALETTE_RAM[i << 4], 16 * 4);
for (std::size_t i = 0; i < std::size(pal_hash_256); i++)
pal_hash_256[i] = XXH32(&PALETTE_RAM[i << 8], 256 * 4, 7);
pal_hash_256[i] = XXH3_64bits(&PALETTE_RAM[i << 8], 256 * 4);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The palette hash is used in the calculation of texture hashes, so we don't want it to change either.

@Xphalnos
Copy link
Contributor Author

@flyinghead Done.

XXH32_state_t *state = XXH32_createState();
XXH32_reset(state, 7);
XXH3_state_t *state = XXH3_createState();
XXH3_64bits_reset(state);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the changes in this file must be reverted to preserve existing texture hash values.

@Xphalnos
Copy link
Contributor Author

It should be good now.

@flyinghead flyinghead merged commit ea6d5f8 into flyinghead:dev Mar 22, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants