@@ -33,7 +33,7 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
33
33
{
34
34
system::path absolutePath = {};
35
35
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
37
37
// Could be used in the future for early rejection of cache hit
38
38
// nbl::system::IFileBase::time_point_t lastWriteTime = {};
39
39
@@ -185,7 +185,7 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
185
185
// Used to check compatibility of Caches before reading
186
186
constexpr static inline std::string_view VERSION = " 1.0.0" ;
187
187
188
- using hash_t = std::array<uint64_t , 4 >;
188
+ using hash_t = std::array<uint8_t , 32 >;
189
189
static auto const SHADER_BUFFER_SIZE_BYTES = sizeof (uint64_t ) / sizeof (uint8_t ); // It's obviously 8
190
190
191
191
struct SEntry
@@ -196,11 +196,9 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
196
196
{
197
197
public:
198
198
// 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
+ {}
204
202
205
203
inline SPreprocessingDependency (SPreprocessingDependency&) = default;
206
204
inline SPreprocessingDependency& operator =(SPreprocessingDependency&) = delete ;
@@ -218,11 +216,8 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
218
216
// path or identifier
219
217
system::path requestingSourceDir = " " ;
220
218
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 = " " ;
224
219
// 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 = {};
226
221
// If true, then `getIncludeStandard` was used to find, otherwise `getIncludeRelative`
227
222
bool standardInclude = false ;
228
223
};
@@ -351,9 +346,13 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
351
346
352
347
// Now add the mainFileContents and produce both lookup and early equality rejection hashes
353
348
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++) {
357
356
core::hash_combine<uint64_t >(lookupHash, hash[i]);
358
357
}
359
358
}
@@ -374,7 +373,7 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
374
373
// TODO: make some of these private
375
374
std::string mainFileContents;
376
375
SCompilerArgs compilerArgs;
377
- std::array<uint64_t , 4 > hash;
376
+ std::array<uint8_t , 32 > hash;
378
377
size_t lookupHash;
379
378
dependency_container_t dependencies;
380
379
core::smart_refctd_ptr<asset::ICPUShader> cpuShader;
@@ -429,7 +428,7 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
429
428
430
429
};
431
430
432
- using EntrySet = core::unordered_multiset <SEntry, Hash, KeyEqual>;
431
+ using EntrySet = core::unordered_set <SEntry, Hash, KeyEqual>;
433
432
EntrySet m_container;
434
433
435
434
NBL_API2 EntrySet::const_iterator find_impl (const SEntry& mainFile, const CIncludeFinder* finder) const ;
0 commit comments