summaryrefslogtreecommitdiffstats
path: root/tools/gfx
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 /tools/gfx
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 'tools/gfx')
-rw-r--r--tools/gfx/persistent-shader-cache.cpp10
-rw-r--r--tools/gfx/persistent-shader-cache.h6
-rw-r--r--tools/gfx/renderer-shared.cpp6
3 files changed, 11 insertions, 11 deletions
diff --git a/tools/gfx/persistent-shader-cache.cpp b/tools/gfx/persistent-shader-cache.cpp
index fdf91fbe8..c0fd3b44a 100644
--- a/tools/gfx/persistent-shader-cache.cpp
+++ b/tools/gfx/persistent-shader-cache.cpp
@@ -63,9 +63,9 @@ void PersistentShaderCache::loadCacheFromFile()
if (digests.getCount() != 2)
continue;
auto dependencyDigest = DigestUtil::fromString(digests[0]);
- auto astDigest = DigestUtil::fromString(digests[1]);
+ auto contentsDigest = DigestUtil::fromString(digests[1]);
- ShaderCacheEntry entry = { dependencyDigest, astDigest };
+ ShaderCacheEntry entry = { dependencyDigest, contentsDigest };
auto entryNode = entries.AddLast(entry);
keyToEntry.Add(dependencyDigest, entryNode);
@@ -133,7 +133,7 @@ void PersistentShaderCache::addEntry(const slang::Digest& dependencyDigest, cons
void PersistentShaderCache::updateEntry(
LinkedNode<ShaderCacheEntry>* entryNode,
const slang::Digest& dependencyDigest,
- const slang::Digest& astDigest,
+ const slang::Digest& contentsDigest,
ISlangBlob* updatedCode)
{
if (!mutableShaderCacheFileSystem)
@@ -143,7 +143,7 @@ void PersistentShaderCache::updateEntry(
return;
}
- entryNode->Value.astBasedDigest = astDigest;
+ entryNode->Value.contentsBasedDigest = contentsDigest;
mutableShaderCacheFileSystem->saveFileBlob(DigestUtil::toString(dependencyDigest).getBuffer(), updatedCode);
saveCacheToFile();
@@ -162,7 +162,7 @@ void PersistentShaderCache::saveCacheToFile()
{
indexSb << entry.dependencyBasedDigest;
indexSb << " ";
- indexSb << entry.astBasedDigest;
+ indexSb << entry.contentsBasedDigest;
indexSb << "\n";
}
diff --git a/tools/gfx/persistent-shader-cache.h b/tools/gfx/persistent-shader-cache.h
index 49a4a53dd..8d4ded4b9 100644
--- a/tools/gfx/persistent-shader-cache.h
+++ b/tools/gfx/persistent-shader-cache.h
@@ -16,7 +16,7 @@ namespace gfx
struct ShaderCacheEntry
{
slang::Digest dependencyBasedDigest;
- slang::Digest astBasedDigest;
+ slang::Digest contentsBasedDigest;
};
class PersistentShaderCache : public RefObject
@@ -32,14 +32,14 @@ public:
// Add an entry to the cache with the provided key and contents hashes. If
// adding an entry causes the cache to exceed size limitations, this will also
// delete the least recently used entry.
- void addEntry(const slang::Digest& dependencyDigest, const slang::Digest& astDigest, ISlangBlob* compiledCode);
+ void addEntry(const slang::Digest& dependencyDigest, const slang::Digest& contentsDigest, ISlangBlob* compiledCode);
// Update the contents hash for the specified entry in the cache and update the
// corresponding file on disk.
void updateEntry(
LinkedNode<ShaderCacheEntry>* entryNode,
const slang::Digest& dependencyDigest,
- const slang::Digest& astDigest,
+ const slang::Digest& contentsDigest,
ISlangBlob* updatedCode);
private:
diff --git a/tools/gfx/renderer-shared.cpp b/tools/gfx/renderer-shared.cpp
index c7d7933a3..65c625d5d 100644
--- a/tools/gfx/renderer-shared.cpp
+++ b/tools/gfx/renderer-shared.cpp
@@ -368,13 +368,13 @@ Result RendererBase::getEntryPointCodeFromShaderCache(
// Produce a hash using the AST for this program - This is needed to check whether a cache entry is effectively dirty,
// or to save along with the compiled code into an entry so the entry can be checked if fetched later on.
slang::Digest contentsHash;
- program->computeASTBasedHash(&contentsHash);
+ program->computeContentsBasedHash(&contentsHash);
ComPtr<ISlangBlob> codeBlob;
- // Query the shader cache index for an entry with shaderKey as its key.
+ // Query the shader cache index for an entry with shaderKey as its key.
auto entry = persistentShaderCache->findEntry(shaderKey, codeBlob.writeRef());
- if (entry && contentsHash == entry->Value.astBasedDigest)
+ if (entry && contentsHash == entry->Value.contentsBasedDigest)
{
// We found the entry in the cache, and the entry's contents are up-to-date. Nothing else needs to be done.
shaderCacheHitCount++;