FNV-1a over a byte span — a cheap, stable content hash for embedded-texture cache keys (dedups identical embedded images and survives GL-context recreation).
| 54 | // FNV-1a over a byte span — a cheap, stable content hash for embedded-texture |
| 55 | // cache keys (dedups identical embedded images and survives GL-context recreation). |
| 56 | std::string contentHashKey(const std::uint8_t* data, std::size_t size) { |
| 57 | std::uint64_t h = 1469598103934665603ULL; // FNV offset basis |
| 58 | for (std::size_t i = 0; i < size; ++i) { |
| 59 | h ^= data[i]; |
| 60 | h *= 1099511628211ULL; // FNV prime |
| 61 | } |
| 62 | std::array<char, 17> buf{}; |
| 63 | std::snprintf(buf.data(), buf.size(), "%016llx", static_cast<unsigned long long>(h)); |
| 64 | return std::string("emb:") + buf.data(); |
| 65 | } |
| 66 | |
| 67 | // Resolve one texture map of a material into a TextureSource. Embedded glTF/GLB |
| 68 | // images (assimp ref "*N") become inline bytes keyed by content hash; external |
no test coverage detected