New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TexturePacker: use std::hash to check for dupes #23296
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Lukas Rusak <lorusak@gmail.com>
Some questions: Why not use a proper upstream hash implementation? Is it cause of speed constraints? A simple crc32 is fast as hell. |
I've made some formatting changes to meet the current code style. The diffs are available in the following links: For more information please see our current code style guidelines. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall nice reduction in code size, just one suggestion to think about.
for (auto x : frame.rgbaImage.pixels) | ||
{ | ||
x = ((x >> 16) ^ x) * 0x45d9f3b; | ||
x = ((x >> 16) ^ x) * 0x45d9f3b; | ||
x = (x >> 16) ^ x; | ||
seed ^= x + 0x9e3779b9 + (seed << 6) + (seed >> 2); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (auto x : frame.rgbaImage.pixels) | |
{ | |
x = ((x >> 16) ^ x) * 0x45d9f3b; | |
x = ((x >> 16) ^ x) * 0x45d9f3b; | |
x = (x >> 16) ^ x; | |
seed ^= x + 0x9e3779b9 + (seed << 6) + (seed >> 2); | |
} | |
auto frameHash = std::hash<std::string_view>()( | |
std::string_view(reinterpret_cast<const char*>(frame.rgbaImage.pixels.data()), | |
frame.rgbaImage.pixels.size())); | |
seed ^= frameHash + 0x9e3779b9 + (seed << 6) + (seed >> 2); |
Not an expert on hash functions, but it looks to me as this one is intended for integers? My suggestion is to use the std::string_view hasher, I assume it will give good results.
@lrusak this needs a rebase |
This changes TexturePacker to use
std::hash
instead of the included md5 implementation. This seems to still provide the same Textures.xbt file.I'm not sure if my implemented
std::hash
method is really as good as the md5 implementation.How has this been tested?
produces the same sha256 for Textures.xbt
What is the effect on users?
none