From c2dc1a86ed2f5e160749fe9f99b70db6c3e4d7a6 Mon Sep 17 00:00:00 2001 From: skallweitNV <64953474+skallweitNV@users.noreply.github.com> Date: Mon, 12 Dec 2022 19:25:48 +0100 Subject: Refactor shader cache (#2558) * Fix a bug in Path::find * Fix code formatting * Fix LockFile and add LockFileGuard * Add PersistentCache and unit test * Replace file path dependency list with source file dependency list * Add note on ordering in Module/FileDependencyList * Remove old shader cache code * Refactor shader cache implementation * Temporarily skip unit tests reading/writing files * Fix warning * Reenable lock file test * Rename shader cache tests and disable crashing test * Testing * Stop using Path::getCanonical * Fix persistent cache lock and test * Fix threading issues * Move adding file dependency hashes to getEntryPointHash() * Fix handling of #include files * Allow specifying additional search paths for gfx testing device * Work on shader cache tests * Update project files * Revive shader cache graphics tests * Split graphics pipeline test * Fix compilation --- slang.h | 36 +++++++++--------------------------- 1 file changed, 9 insertions(+), 27 deletions(-) (limited to 'slang.h') diff --git a/slang.h b/slang.h index 784a3e763..4aa30b049 100644 --- a/slang.h +++ b/slang.h @@ -4425,34 +4425,16 @@ namespace slang IBlob** outCode, IBlob** outDiagnostics = nullptr) = 0; - /** Compute the hash code of all dependencies for this component type. This generally means file path - dependencies but can also include the component's name or sub-components. The dependency-based - hash effectively represents all the files that may be included/imported by a component type along with - any non-code-specific that helps define a component. This can be useful to simply check for a component - type without needing to inspect the code. For example, a shader cache might key its entries using the - dependency-based hash in order to determine at a glance if a particular shader is present, with no - regard for the shader's contents. - - This function should only have a meaningful implementation in ComponentType. All other types derived from - ComponentType that also inherit from IComponentType should do nothing. - */ - virtual SLANG_NO_THROW void SLANG_MCALL computeDependencyBasedHash( - SlangInt entryPointIndex, - SlangInt targetIndex, - IBlob** outHash) = 0; - - /** 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. 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. + /** Compute a hash for the entry point at `entryPointIndex` for the chosen `targetIndex`. + + This computes a hash based on all the dependencies for this component type as well as the + target settings affecting the compiler backend. The computed hash is used as a key for caching + the output of the compiler backend to implement shader caching. */ - virtual SLANG_NO_THROW void SLANG_MCALL computeContentsBasedHash(IBlob** outHash) = 0; + virtual SLANG_NO_THROW void SLANG_MCALL getEntryPointHash( + SlangInt entryPointIndex, + SlangInt targetIndex, + IBlob** outHash) = 0; /** Specialize the component by binding its specialization parameters to concrete arguments. -- cgit v1.2.3