mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-20 20:49:12 +12:00
[PICA] Switch to xxh3 by default
This commit is contained in:
parent
f82b27ddba
commit
f0f7327b90
4 changed files with 60 additions and 23 deletions
|
@ -0,0 +1,42 @@
|
|||
#include "PICA/pica_hash.hpp"
|
||||
#include "PICA/shader.hpp"
|
||||
|
||||
#ifdef PANDA3DS_PICA_CITYHASH
|
||||
#include "cityhash.hpp"
|
||||
#elif defined(PANDA3DS_PICA_XXHASH3)
|
||||
#include "xxhash/xxhash.h"
|
||||
#else
|
||||
#error No hashing algorithm defined for the PICA (See pica_hash.hpp for details)
|
||||
#endif
|
||||
|
||||
PICAHash::HashType PICAHash::computeHash(const char* buf, std::size_t len) {
|
||||
#ifdef PANDA3DS_PICA_CITYHASH
|
||||
return CityHash::CityHash64(buf, len);
|
||||
#elif defined(PANDA3DS_PICA_XXHASH3)
|
||||
return XXH3_64bits(buf, len);
|
||||
#else
|
||||
#error No hashing algorithm defined for PICAHash::computeHash
|
||||
#endif
|
||||
}
|
||||
|
||||
PICAShader::Hash PICAShader::getCodeHash() {
|
||||
// Hash the code again if the code changed
|
||||
if (codeHashDirty) {
|
||||
codeHashDirty = false;
|
||||
lastCodeHash = PICAHash::computeHash((const char*)&loadedShader[0], loadedShader.size() * sizeof(loadedShader[0]));
|
||||
}
|
||||
|
||||
// Return the code hash
|
||||
return lastCodeHash;
|
||||
}
|
||||
|
||||
PICAShader::Hash PICAShader::getOpdescHash() {
|
||||
// Hash the code again if the operand descriptors changed
|
||||
if (opdescHashDirty) {
|
||||
opdescHashDirty = false;
|
||||
lastOpdescHash = PICAHash::computeHash((const char*)&operandDescriptors[0], operandDescriptors.size() * sizeof(operandDescriptors[0]));
|
||||
}
|
||||
|
||||
// Return the code hash
|
||||
return lastOpdescHash;
|
||||
}
|
|
@ -34,26 +34,4 @@ void PICAShader::reset() {
|
|||
|
||||
codeHashDirty = true;
|
||||
opdescHashDirty = true;
|
||||
}
|
||||
|
||||
PICAShader::Hash PICAShader::getCodeHash() {
|
||||
// Hash the code again if the code changed
|
||||
if (codeHashDirty) {
|
||||
codeHashDirty = false;
|
||||
lastCodeHash = CityHash::CityHash64((const char*)&loadedShader[0], loadedShader.size() * sizeof(loadedShader[0]));
|
||||
}
|
||||
|
||||
// Return the code hash
|
||||
return lastCodeHash;
|
||||
}
|
||||
|
||||
PICAShader::Hash PICAShader::getOpdescHash() {
|
||||
// Hash the code again if the operand descriptors changed
|
||||
if (opdescHashDirty) {
|
||||
opdescHashDirty = false;
|
||||
lastOpdescHash = CityHash::CityHash64((const char*)&operandDescriptors[0], operandDescriptors.size() * sizeof(operandDescriptors[0]));
|
||||
}
|
||||
|
||||
// Return the code hash
|
||||
return lastOpdescHash;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue