summaryrefslogtreecommitdiff
path: root/source/slang/slang-compiler.h
diff options
context:
space:
mode:
authorlucy96chen <47800040+lucy96chen@users.noreply.github.com>2022-10-29 12:08:41 -0700
committerGitHub <noreply@github.com>2022-10-29 12:08:41 -0700
commit883d9f7cccf1080739213282602c0dbae5fa7fe6 (patch)
tree88f908095811a6e76bb9c089cd3bf3387b4473b2 /source/slang/slang-compiler.h
parent5a510ab28381ae93d1011f0bb6c9db4cbf589578 (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-compiler.h')
-rwxr-xr-xsource/slang/slang-compiler.h45
1 files changed, 28 insertions, 17 deletions
diff --git a/source/slang/slang-compiler.h b/source/slang/slang-compiler.h
index bd7cd4a18..eb6d6c1a5 100755
--- a/source/slang/slang-compiler.h
+++ b/source/slang/slang-compiler.h
@@ -298,7 +298,7 @@ namespace Slang
SlangInt entryPointIndex,
SlangInt targetIndex,
slang::Digest* outHash) SLANG_OVERRIDE;
- SLANG_NO_THROW void SLANG_MCALL computeASTBasedHash(slang::Digest* outHash) SLANG_OVERRIDE;
+ SLANG_NO_THROW void SLANG_MCALL computeContentsBasedHash(slang::Digest* outHash) SLANG_OVERRIDE;
/// Get the linkage (aka "session" in the public API) for this component type.
Linkage* getLinkage() { return m_linkage; }
@@ -313,10 +313,10 @@ namespace Slang
DigestBuilder& hashBuilder,
SlangInt entryPointIndex) = 0;
- /// Update the hash builder with the AST contents for this component type.
- /// The AST is associated with a Module component, so most derived ComponentType classes
- /// will simply do nothing with this.
- virtual void updateASTBasedHash(DigestBuilder& hashBuilder) = 0;
+ /// Update the hash builder with the source contents for this component type.
+ /// Module should be the only derived ComponentType class which has a meaningful
+ /// implementation; all others should do nothing.
+ virtual void updateContentsBasedHash(DigestBuilder& hashBuilder) = 0;
/// Get the number of entry points linked into this component type.
virtual Index getEntryPointCount() = 0;
@@ -519,7 +519,7 @@ namespace Slang
DigestBuilder& hashBuilder,
SlangInt entryPointIndex) override;
- virtual void updateASTBasedHash(DigestBuilder& hashBuilder) override;
+ virtual void updateContentsBasedHash(DigestBuilder& hashBuilder) override;
List<RefPtr<ComponentType>> const& getChildComponents() { return m_childComponents; };
Index getChildComponentCount() { return m_childComponents.getCount(); }
@@ -601,7 +601,7 @@ namespace Slang
DigestBuilder& hashBuilder,
SlangInt entryPointIndex) override;
- virtual void updateASTBasedHash(DigestBuilder& hashBuilder) override
+ virtual void updateContentsBasedHash(DigestBuilder& hashBuilder) override
{
SLANG_UNUSED(hashBuilder);
}
@@ -794,7 +794,7 @@ namespace Slang
DigestBuilder& hashBuilder,
SlangInt entryPointIndex) override;
- virtual void updateASTBasedHash(DigestBuilder& hashBuilder) override
+ virtual void updateContentsBasedHash(DigestBuilder& hashBuilder) override
{
SLANG_UNUSED(hashBuilder);
}
@@ -899,16 +899,16 @@ namespace Slang
return Super::computeDependencyBasedHash(entryPointIndex, targetIndex, outHash);
}
- SLANG_NO_THROW void SLANG_MCALL computeASTBasedHash(slang::Digest* outHash) SLANG_OVERRIDE
+ SLANG_NO_THROW void SLANG_MCALL computeContentsBasedHash(slang::Digest* outHash) SLANG_OVERRIDE
{
- return Super::computeASTBasedHash(outHash);
+ return Super::computeContentsBasedHash(outHash);
}
virtual void updateDependencyBasedHash(
DigestBuilder& hashBuilder,
SlangInt entryPointIndex) override;
- virtual void updateASTBasedHash(DigestBuilder& hashBuilder) override
+ virtual void updateContentsBasedHash(DigestBuilder& hashBuilder) override
{
SLANG_UNUSED(hashBuilder);
}
@@ -1126,16 +1126,16 @@ namespace Slang
return Super::computeDependencyBasedHash(entryPointIndex, targetIndex, outHash);
}
- SLANG_NO_THROW void SLANG_MCALL computeASTBasedHash(slang::Digest* outHash) SLANG_OVERRIDE
+ SLANG_NO_THROW void SLANG_MCALL computeContentsBasedHash(slang::Digest* outHash) SLANG_OVERRIDE
{
- return Super::computeASTBasedHash(outHash);
+ return Super::computeContentsBasedHash(outHash);
}
virtual void updateDependencyBasedHash(
DigestBuilder& hashBuilder,
SlangInt entryPointIndex) override;
- virtual void updateASTBasedHash(DigestBuilder& hashBuilder) override
+ virtual void updateContentsBasedHash(DigestBuilder& hashBuilder) override
{
SLANG_UNUSED(hashBuilder);
}
@@ -1322,16 +1322,16 @@ namespace Slang
return Super::computeDependencyBasedHash(entryPointIndex, targetIndex, outHash);
}
- SLANG_NO_THROW void SLANG_MCALL computeASTBasedHash(slang::Digest* outHash) SLANG_OVERRIDE
+ SLANG_NO_THROW void SLANG_MCALL computeContentsBasedHash(slang::Digest* outHash) SLANG_OVERRIDE
{
- return Super::computeASTBasedHash(outHash);
+ return Super::computeContentsBasedHash(outHash);
}
virtual void updateDependencyBasedHash(
DigestBuilder& hashBuilder,
SlangInt entryPointIndex) override;
- virtual void updateASTBasedHash(DigestBuilder& hashBuilder) override;
+ virtual void updateContentsBasedHash(DigestBuilder& hashBuilder) override;
/// Create a module (initially empty).
Module(Linkage* linkage, ASTBuilder* astBuilder = nullptr);
@@ -1366,6 +1366,14 @@ namespace Slang
///
void setIRModule(IRModule* irModule) { m_irModule = irModule; }
+ DigestBuilder& getContentsDigestBuilder() { return contentsBuilder; }
+
+ /// Set the contents digest for this module.
+ void setContentsDigest(slang::Digest digest) { contentsDigest = digest; }
+
+ /// Get the contents digest for this module.
+ slang::Digest getContentsDigest() { return contentsDigest; }
+
Index getEntryPointCount() SLANG_OVERRIDE { return 0; }
RefPtr<EntryPoint> getEntryPoint(Index index) SLANG_OVERRIDE { SLANG_UNUSED(index); return nullptr; }
String getEntryPointMangledName(Index index) SLANG_OVERRIDE { SLANG_UNUSED(index); return String(); }
@@ -1474,6 +1482,9 @@ namespace Slang
// and m_mangledExportSymbols holds the NodeBase* values for each index.
StringSlicePool m_mangledExportPool;
List<NodeBase*> m_mangledExportSymbols;
+
+ DigestBuilder contentsBuilder;
+ slang::Digest contentsDigest;
};
typedef Module LoadedModule;