summaryrefslogtreecommitdiffstats
path: root/tools/gfx/renderer-shared.cpp
diff options
context:
space:
mode:
authorlucy96chen <47800040+lucy96chen@users.noreply.github.com>2022-11-29 12:35:54 -0800
committerGitHub <noreply@github.com>2022-11-29 12:35:54 -0800
commitd85c7b809d02e6dc0844aab07e66a6bac2462017 (patch)
tree5b0c094e705df8b1c0a98de26e3d28514b014d80 /tools/gfx/renderer-shared.cpp
parentd60c925229cf911b0363bf9d5e25a6f73c6d5737 (diff)
FileStream-based implementation for updating cache index file (#2485)
* Draft FileStream-based implementation for updating cache file * File streams fully integrated into shader cache code paths; Tests will not run unless file system is on disk as file streams do not play nicely with in-memory * Brought old code back as fallback path, but tests need to ensure previous is freed first * Testing structure updated, beginning cleanup work * All tests working * Cleanup changes * Removed an extra tab at the end of a line * Cleanup change * Undo externals change * Removed redundant logic for OS vs memory file system handling of the shader cache; Removed extra helper function left over from old cache implementation * Reverted performance change to generate contents hashes when modules are being loaded as this code path is not always followed; Contents hashing now uses a combination of hashing and checking the last modified time for all file dependencies, only reading in and hashing the contents of all files if the last modified hash does not match * Added handling to Module::updateContentsBasedHash for file dependencies which are not from a physical source file on disk; Added test for above Co-authored-by: Lucy Chen <lucchen@nvidia.com> Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'tools/gfx/renderer-shared.cpp')
-rw-r--r--tools/gfx/renderer-shared.cpp17
1 files changed, 2 insertions, 15 deletions
diff --git a/tools/gfx/renderer-shared.cpp b/tools/gfx/renderer-shared.cpp
index 65c625d5d..3dcdb324c 100644
--- a/tools/gfx/renderer-shared.cpp
+++ b/tools/gfx/renderer-shared.cpp
@@ -331,19 +331,6 @@ void PipelineStateBase::initializeBase(const PipelineStateDesc& inDesc)
}
}
-void updateCacheEntry(ISlangMutableFileSystem* fileSystem, slang::IBlob* compiledCode, String shaderFilename, slang::Digest ASTHash)
-{
- auto hashSize = sizeof(slang::Digest);
-
- auto bufferSize = hashSize + compiledCode->getBufferSize();
- List<uint8_t> contents;
- contents.setCount(bufferSize);
- uint8_t* buffer = contents.begin();
- memcpy(buffer, &ASTHash, hashSize);
- memcpy(buffer + hashSize, (void*)compiledCode->getBufferPointer(), compiledCode->getBufferSize());
- fileSystem->saveFile(shaderFilename.getBuffer(), buffer, bufferSize);
-}
-
Result RendererBase::getEntryPointCodeFromShaderCache(
slang::IComponentType* program,
SlangInt entryPointIndex,
@@ -374,7 +361,7 @@ Result RendererBase::getEntryPointCodeFromShaderCache(
// 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.contentsBasedDigest)
+ if (entry && contentsHash == entry->contentsBasedDigest)
{
// We found the entry in the cache, and the entry's contents are up-to-date. Nothing else needs to be done.
shaderCacheHitCount++;
@@ -394,7 +381,7 @@ Result RendererBase::getEntryPointCodeFromShaderCache(
}
else
{
- persistentShaderCache->updateEntry(entry, shaderKey, contentsHash, codeBlob);
+ persistentShaderCache->updateEntry(shaderKey, contentsHash, codeBlob);
shaderCacheEntryDirtyCount++;
}
}