@@ -239,11 +239,10 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
239239 return true ;
240240 }
241241
242- std::string sourceIdentifier;
243-
244242 private:
245243 friend class SCompilerArgs ;
246244 friend class SEntry ;
245+ friend class CCache ;
247246 friend void to_json (nlohmann::json&, const SPreprocessorArgs&);
248247 friend void from_json (const nlohmann::json&, SPreprocessorArgs&);
249248
@@ -264,9 +263,10 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
264263 // Sort them so equality and hashing are well defined
265264 std::sort (extraDefines.begin (), extraDefines.end (), [](const SMacroDefinition& lhs, const SMacroDefinition& rhs) {return lhs.identifier < rhs.identifier ; });
266265 };
266+ std::string sourceIdentifier;
267267 std::vector<SMacroDefinition> extraDefines;
268268 };
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
270270 struct SCompilerArgs final
271271 {
272272 public:
@@ -283,11 +283,9 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
283283 return retVal;
284284 }
285285
286- IShader::E_SHADER_STAGE stage;
287- SPreprocessorArgs preprocessorArgs;
288-
289286 private:
290287 friend class SEntry ;
288+ friend class CCache ;
291289 friend void to_json (nlohmann::json&, const SCompilerArgs&);
292290 friend void from_json (const nlohmann::json&, SCompilerArgs&);
293291
@@ -310,9 +308,11 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
310308 }
311309 }
312310
311+ IShader::E_SHADER_STAGE stage;
313312 E_SPIRV_VERSION targetSpirvVersion;
314313 std::vector<ISPIRVOptimizer::E_OPTIMIZER_PASS> optimizerPasses;
315314 core::bitflag<E_DEBUG_INFO_FLAGS> debugInfoFlags;
315+ SPreprocessorArgs preprocessorArgs;
316316 };
317317
318318 // 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
354354 lookupHash = std::hash<core::blake3_hash_t >{}(hash);
355355 }
356356
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+
357364 // Needed to get the vector deserialization automatically
358365 inline SEntry () {}
359366
360367 // 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) {}
364372
365373 inline SEntry& operator =(SEntry& other) = delete ;
366374 inline SEntry (SEntry&& other) = default;
367375 // Used for late initialization while looking up a cache, so as not to always initialize an entry even if caching was not requested
368376 inline SEntry& operator =(SEntry&& other) = default ;
369377
370- core::smart_refctd_ptr<ICPUShader> decodeShader () const ;
378+ core::smart_refctd_ptr<ICPUShader> decompressShader () const ;
371379
372380 // TODO: make some of these private
373381 std::string mainFileContents;
@@ -376,6 +384,7 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
376384 size_t lookupHash;
377385 dependency_container_t dependencies;
378386 core::smart_refctd_ptr<asset::ICPUBuffer> spirv;
387+ core::blake3_hash_t uncompressedContentHash;
379388 size_t uncompressedSize;
380389 };
381390
0 commit comments