From 883d9f7cccf1080739213282602c0dbae5fa7fe6 Mon Sep 17 00:00:00 2001 From: lucy96chen <47800040+lucy96chen@users.noreply.github.com> Date: Sat, 29 Oct 2022 12:08:41 -0700 Subject: 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 --- slang.h | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'slang.h') diff --git a/slang.h b/slang.h index 8a0813f7b..9c85a2f74 100644 --- a/slang.h +++ b/slang.h @@ -4457,20 +4457,18 @@ namespace slang SlangInt targetIndex, Digest* outHash) = 0; - /** Compute the hash code of this component type's AST. This hash effectively represents - the contents of the code covered by this component type, making its use ideal when we need - to confirm whether shader code changes have occurred. For example, a shader cache needs to be - able to check when a cache entry contains out-of-date code, which can be easily detected by - comparing the AST-based hashes since any change to the shader's code will be reflected in the - AST, and subsequently, the AST-based hash. - - Not all component types will store an AST, and consequently, not all component types will have a - meaningful implementation for this function. + /** Compute the hash code of this component type's contents as indicated by the file dependencies. + This hash is ideal when we need to confirm whether shader code changes have occurred. For example, + a shader cache needs to be able to check when a cache entry contains out-of-date code, which can be + easily detected by comparing the contents-based hashes since they will directly reflect any change + to the shader's code. This function should only have a meaningful implementation in ComponentType. All other types derived - from ComponentType that also inherit from IComponentType should do nothing. + from ComponentType that also inherit from IComponentType should do nothing. However, the only component + type that should ever be hashing its contents is Module as it represents all the code in a given + translation unit. */ - virtual SLANG_NO_THROW void SLANG_MCALL computeASTBasedHash(Digest* outHash) = 0; + virtual SLANG_NO_THROW void SLANG_MCALL computeContentsBasedHash(Digest* outHash) = 0; /** Specialize the component by binding its specialization parameters to concrete arguments. -- cgit v1.2.3