@@ -33,7 +33,7 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
3333 {
3434 system::path absolutePath = {};
3535 std::string contents = {};
36- std::array<uint64_t , 4 > hash = {}; // TODO: we're not yet using IFile::getPrecomputedHash(), so for builtins we can maybe use that in the future
36+ std::array<uint8_t , 32 > hash = {}; // TODO: we're not yet using IFile::getPrecomputedHash(), so for builtins we can maybe use that in the future
3737 // Could be used in the future for early rejection of cache hit
3838 // nbl::system::IFileBase::time_point_t lastWriteTime = {};
3939
@@ -185,7 +185,7 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
185185 // Used to check compatibility of Caches before reading
186186 constexpr static inline std::string_view VERSION = " 1.0.0" ;
187187
188- using hash_t = std::array<uint64_t , 4 >;
188+ using hash_t = std::array<uint8_t , 32 >;
189189 static auto const SHADER_BUFFER_SIZE_BYTES = sizeof (uint64_t ) / sizeof (uint8_t ); // It's obviously 8
190190
191191 struct SEntry
@@ -196,11 +196,9 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
196196 {
197197 public:
198198 // Perf note: hashing while preprocessor lexing is likely to be slower than just hashing the whole array like this
199- inline SPreprocessingDependency (const system::path& _requestingSourceDir, const std::string_view& _identifier, const std::string_view& _contents, bool _standardInclude, std::array<uint64_t , 4 > _hash) :
200- requestingSourceDir(_requestingSourceDir), identifier(_identifier), contents(_contents), standardInclude(_standardInclude), hash(_hash)
201- {
202- assert (!_contents.empty ());
203- }
199+ inline SPreprocessingDependency (const system::path& _requestingSourceDir, const std::string_view& _identifier, bool _standardInclude, std::array<uint8_t , 32 > _hash) :
200+ requestingSourceDir(_requestingSourceDir), identifier(_identifier), standardInclude(_standardInclude), hash(_hash)
201+ {}
204202
205203 inline SPreprocessingDependency (SPreprocessingDependency&) = default;
206204 inline SPreprocessingDependency& operator =(SPreprocessingDependency&) = delete ;
@@ -218,11 +216,8 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
218216 // path or identifier
219217 system::path requestingSourceDir = " " ;
220218 std::string identifier = " " ;
221- // file contents
222- // TODO: change to `core::vector<uint8_t>` a compressed blob of LZMA, and store all contents together in the `SEntry`
223- std::string contents = " " ;
224219 // hash of the contents - used to check against a found_t
225- std::array<uint64_t , 4 > hash = {};
220+ std::array<uint8_t , 32 > hash = {};
226221 // If true, then `getIncludeStandard` was used to find, otherwise `getIncludeRelative`
227222 bool standardInclude = false ;
228223 };
@@ -351,9 +346,13 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
351346
352347 // Now add the mainFileContents and produce both lookup and early equality rejection hashes
353348 hashable.insert (hashable.end (), mainFileContents.begin (), mainFileContents.end ());
354- hash = nbl::core::XXHash_256 (hashable.data (), hashable.size ());
355- lookupHash = hash[0 ];
356- for (auto i = 1u ; i < 4 ; i++) {
349+
350+ core::blake3_hasher hasher;
351+ hasher.update (hashable.data (), hashable.size ());
352+ hash = { *static_cast <core::blake3_hash_t >(hasher).data };
353+ // ALI:TODO
354+ lookupHash = std::bit_cast<uint64_t , uint8_t [8 ]>({hash[0 ], hash[1 ], hash[2 ], hash[3 ], hash[4 ], hash[5 ], hash[6 ], hash[7 ]});
355+ for (auto i = 8u ; i < 32 ; i++) {
357356 core::hash_combine<uint64_t >(lookupHash, hash[i]);
358357 }
359358 }
@@ -374,7 +373,7 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
374373 // TODO: make some of these private
375374 std::string mainFileContents;
376375 SCompilerArgs compilerArgs;
377- std::array<uint64_t , 4 > hash;
376+ std::array<uint8_t , 32 > hash;
378377 size_t lookupHash;
379378 dependency_container_t dependencies;
380379 core::smart_refctd_ptr<asset::ICPUShader> cpuShader;
@@ -429,7 +428,7 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
429428
430429 };
431430
432- using EntrySet = core::unordered_multiset <SEntry, Hash, KeyEqual>;
431+ using EntrySet = core::unordered_set <SEntry, Hash, KeyEqual>;
433432 EntrySet m_container;
434433
435434 NBL_API2 EntrySet::const_iterator find_impl (const SEntry& mainFile, const CIncludeFinder* finder) const ;
0 commit comments