@@ -239,11 +239,10 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
239
239
return true ;
240
240
}
241
241
242
- std::string sourceIdentifier;
243
-
244
242
private:
245
243
friend class SCompilerArgs ;
246
244
friend class SEntry ;
245
+ friend class CCache ;
247
246
friend void to_json (nlohmann::json&, const SPreprocessorArgs&);
248
247
friend void from_json (const nlohmann::json&, SPreprocessorArgs&);
249
248
@@ -264,9 +263,10 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
264
263
// Sort them so equality and hashing are well defined
265
264
std::sort (extraDefines.begin (), extraDefines.end (), [](const SMacroDefinition& lhs, const SMacroDefinition& rhs) {return lhs.identifier < rhs.identifier ; });
266
265
};
266
+ std::string sourceIdentifier;
267
267
std::vector<SMacroDefinition> extraDefines;
268
268
};
269
- // TODO: SPreprocessorArgs could just be folded into `SCompilerArgs` to have less classes and operators
269
+ // TODO: SPreprocessorArgs could just be folded into `SCompilerArgs` to have less classes and decompressShader
270
270
struct SCompilerArgs final
271
271
{
272
272
public:
@@ -283,11 +283,9 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
283
283
return retVal;
284
284
}
285
285
286
- IShader::E_SHADER_STAGE stage;
287
- SPreprocessorArgs preprocessorArgs;
288
-
289
286
private:
290
287
friend class SEntry ;
288
+ friend class CCache ;
291
289
friend void to_json (nlohmann::json&, const SCompilerArgs&);
292
290
friend void from_json (const nlohmann::json&, SCompilerArgs&);
293
291
@@ -310,9 +308,11 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
310
308
}
311
309
}
312
310
311
+ IShader::E_SHADER_STAGE stage;
313
312
E_SPIRV_VERSION targetSpirvVersion;
314
313
std::vector<ISPIRVOptimizer::E_OPTIMIZER_PASS> optimizerPasses;
315
314
core::bitflag<E_DEBUG_INFO_FLAGS> debugInfoFlags;
315
+ SPreprocessorArgs preprocessorArgs;
316
316
};
317
317
318
318
// The ordering is important here, the dependencies MUST be added to the array IN THE ORDER THE PREPROCESSOR INCLUDED THEM!
@@ -354,20 +354,28 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
354
354
lookupHash = std::hash<core::blake3_hash_t >{}(hash);
355
355
}
356
356
357
+ // Making an entry to insert into write cache
358
+ inline SEntry (const SEntry& other, dependency_container_t dependencies, core::smart_refctd_ptr<asset::ICPUBuffer> spirv,
359
+ core::blake3_hash_t uncompressedContentHash, size_t uncompressedSize)
360
+ : mainFileContents(other.mainFileContents), compilerArgs(other.compilerArgs), hash(other.hash),
361
+ lookupHash(other.lookupHash), dependencies(dependencies), spirv(spirv),
362
+ uncompressedContentHash(uncompressedContentHash), uncompressedSize(uncompressedSize) {}
363
+
357
364
// Needed to get the vector deserialization automatically
358
365
inline SEntry () {}
359
366
360
367
// Making the copy constructor deep-copy everything but the shader
361
- inline SEntry (const SEntry& other)
362
- : mainFileContents(other.mainFileContents), compilerArgs(other.compilerArgs), hash(other.hash), lookupHash(other.lookupHash),
363
- dependencies(other.dependencies), spirv(other.spirv), uncompressedSize(other.uncompressedSize) {}
368
+ inline SEntry (const SEntry& other)
369
+ : mainFileContents(other.mainFileContents), compilerArgs(other.compilerArgs), hash(other.hash),
370
+ lookupHash(other.lookupHash), dependencies(other.dependencies), spirv(other.spirv),
371
+ uncompressedContentHash(other.uncompressedContentHash), uncompressedSize(other.uncompressedSize) {}
364
372
365
373
inline SEntry& operator =(SEntry& other) = delete ;
366
374
inline SEntry (SEntry&& other) = default;
367
375
// Used for late initialization while looking up a cache, so as not to always initialize an entry even if caching was not requested
368
376
inline SEntry& operator =(SEntry&& other) = default ;
369
377
370
- core::smart_refctd_ptr<ICPUShader> decodeShader () const ;
378
+ core::smart_refctd_ptr<ICPUShader> decompressShader () const ;
371
379
372
380
// TODO: make some of these private
373
381
std::string mainFileContents;
@@ -376,6 +384,7 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
376
384
size_t lookupHash;
377
385
dependency_container_t dependencies;
378
386
core::smart_refctd_ptr<asset::ICPUBuffer> spirv;
387
+ core::blake3_hash_t uncompressedContentHash;
379
388
size_t uncompressedSize;
380
389
};
381
390
0 commit comments