@@ -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< uint8_t , 32 > hash = {}; // TODO: we're not yet using IFile::getPrecomputedHash(), so for builtins we can maybe use that in the future
36
+ core:: blake3_hash_t 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,6 @@ 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<uint8_t ,32 >;
189
188
static auto const SHADER_BUFFER_SIZE_BYTES = sizeof (uint64_t ) / sizeof (uint8_t ); // It's obviously 8
190
189
191
190
struct SEntry
@@ -196,7 +195,7 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
196
195
{
197
196
public:
198
197
// 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, bool _standardInclude, std::array< uint8_t , 32 > _hash) :
198
+ inline SPreprocessingDependency (const system::path& _requestingSourceDir, const std::string_view& _identifier, bool _standardInclude, core:: blake3_hash_t _hash) :
200
199
requestingSourceDir(_requestingSourceDir), identifier(_identifier), standardInclude(_standardInclude), hash(_hash)
201
200
{}
202
201
@@ -217,7 +216,7 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
217
216
system::path requestingSourceDir = " " ;
218
217
std::string identifier = " " ;
219
218
// hash of the contents - used to check against a found_t
220
- std::array< uint8_t , 32 > hash = {};
219
+ core:: blake3_hash_t hash = {};
221
220
// If true, then `getIncludeStandard` was used to find, otherwise `getIncludeRelative`
222
221
bool standardInclude = false ;
223
222
};
@@ -349,11 +348,8 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
349
348
350
349
core::blake3_hasher hasher;
351
350
hasher.update (hashable.data (), hashable.size ());
352
- hash = { *static_cast <core::blake3_hash_t >(hasher).data };
353
- 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 ]});
354
- for (auto i = 8u ; i < 32 ; i++) {
355
- core::hash_combine<uint64_t >(lookupHash, hash[i]);
356
- }
351
+ hash = static_cast <core::blake3_hash_t >(hasher);
352
+ lookupHash = std::hash<core::blake3_hash_t >{}(hash);
357
353
}
358
354
359
355
// Needed to get the vector deserialization automatically
@@ -372,7 +368,7 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
372
368
// TODO: make some of these private
373
369
std::string mainFileContents;
374
370
SCompilerArgs compilerArgs;
375
- std::array< uint8_t , 32 > hash;
371
+ core:: blake3_hash_t hash;
376
372
size_t lookupHash;
377
373
dependency_container_t dependencies;
378
374
core::smart_refctd_ptr<asset::ICPUShader> cpuShader;
0 commit comments