diff options
| author | lucy96chen <47800040+lucy96chen@users.noreply.github.com> | 2022-10-29 12:08:41 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-29 12:08:41 -0700 |
| commit | 883d9f7cccf1080739213282602c0dbae5fa7fe6 (patch) | |
| tree | 88f908095811a6e76bb9c089cd3bf3387b4473b2 /source/slang/slang.cpp | |
| parent | 5a510ab28381ae93d1011f0bb6c9db4cbf589578 (diff) | |
Shader cache bugfixes and test additions (#2467)
* Preliminary graphics shader test
* Added test checking that a graphics shader is correctly split into two different entries
* Removed testing only addition
* Changed RequirementDictionary to an OrderedDictionary and added SerialTypeInfo for OrderedDictionary; Added entry point mangled name to the dependency hash
* Added test covering failure case discovered as part of Falcor integration
* Changed DifferentiableTypeSemanticContext::m_mapTypeToIDifferentiableWitness to an OrderedDictionary
* Added serializedAST field to Module in order to save serialized ASTs to avoid reserialization as much as possible; Added classes field to Session in order to save the output of SerialClassesUtil::create to avoid recreating as much as possible
* Changed AST hashing to hash the contents of a Module's file dependencies; Renamed all references to AST hashing to contents hashing
* Further cleanup
* Moved contents hash computation up to Linkage::loadModule and added field to Module to save the computed contents digest
* Changed PreprocessorHandler::handleFileDependency to optionally take an ISlangBlob* containing file contents and changed FrontEndPreprocessorHandler::handleFileDependency to add the source code for an included file to the module's contents digest
* Removed extraneous addToDigest call
* Fixed accidental removal of source code hash for module being loaded
Diffstat (limited to 'source/slang/slang.cpp')
| -rw-r--r-- | source/slang/slang.cpp | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index c7351d6a8..361f1b193 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -1898,9 +1898,13 @@ protected: // by applications to decide when they need to "hot reload" // their shader code. // - void handleFileDependency(String const& path) SLANG_OVERRIDE + void handleFileDependency(String const& path, ISlangBlob* sourceBlob) SLANG_OVERRIDE { m_module->addFilePathDependency(path); + if (sourceBlob) + { + m_module->getContentsDigestBuilder().addToDigest(sourceBlob); + } } // The second task that this handler deals with is detecting @@ -3042,6 +3046,10 @@ RefPtr<Module> Linkage::loadModule( return nullptr; } + auto builder = module->getContentsDigestBuilder(); + builder.addToDigest(sourceBlob); + module->setContentsDigest(builder.finalize()); + return module; } @@ -3259,10 +3267,9 @@ void Module::updateDependencyBasedHash( SLANG_UNUSED(entryPointIndex); } -void Module::updateASTBasedHash(DigestBuilder& builder) +void Module::updateContentsBasedHash(DigestBuilder& builder) { - auto serializedAST = ASTSerialUtil::serializeAST(getModuleDecl()); - builder.addToDigest(serializedAST); + builder.addToDigest(getContentsDigest()); } void Module::addModuleDependency(Module* module) @@ -3491,16 +3498,18 @@ SLANG_NO_THROW void SLANG_MCALL ComponentType::computeDependencyBasedHash( // to the hash. auto entryPointName = getEntryPoint(entryPointIndex)->getName()->text; builder.addToDigest(entryPointName); + auto entryPointMangledName = getEntryPointMangledName(entryPointIndex); + builder.addToDigest(entryPointMangledName); auto entryPointNameOverride = getEntryPointNameOverride(entryPointIndex); builder.addToDigest(entryPointNameOverride); *outHash = builder.finalize(); } -SLANG_NO_THROW void SLANG_MCALL ComponentType::computeASTBasedHash(slang::Digest* outHash) +SLANG_NO_THROW void SLANG_MCALL ComponentType::computeContentsBasedHash(slang::Digest* outHash) { DigestBuilder builder; - updateASTBasedHash(builder); + updateContentsBasedHash(builder); *outHash = builder.finalize(); } @@ -3848,13 +3857,13 @@ void CompositeComponentType::updateDependencyBasedHash( } } -void CompositeComponentType::updateASTBasedHash(DigestBuilder& builder) +void CompositeComponentType::updateContentsBasedHash(DigestBuilder& builder) { auto componentCount = getChildComponentCount(); for (Index i = 0; i < componentCount; ++i) { - getChildComponent(i)->updateASTBasedHash(builder); + getChildComponent(i)->updateContentsBasedHash(builder); } } |
