summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rwxr-xr-xsource/slang/slang-compiler.h4
-rw-r--r--source/slang/slang.cpp74
2 files changed, 54 insertions, 24 deletions
diff --git a/source/slang/slang-compiler.h b/source/slang/slang-compiler.h
index 4876026a0..0dd0012ad 100755
--- a/source/slang/slang-compiler.h
+++ b/source/slang/slang-compiler.h
@@ -1835,7 +1835,7 @@ namespace Slang
// Updates the supplied builder with linkage-related information, which includes preprocessor
// defines, the compiler version, and other compiler options. This is then merged with the hash
// produced for the program to produce a key that can be used with the shader cache.
- void buildHash(DigestBuilder<SHA1>& builder, SlangInt targetIndex);
+ void buildHash(DigestBuilder<SHA1>& builder, SlangInt targetIndex = -1);
void addTarget(
slang::TargetDesc const& desc);
@@ -3003,6 +3003,8 @@ namespace Slang
SLANG_NO_THROW SlangResult SLANG_MCALL parseCommandLineArguments(
int argc, const char* const* argv, slang::SessionDesc* outSessionDesc, ISlangUnknown** outAllocation) override;
+ SLANG_NO_THROW SlangResult SLANG_MCALL getSessionDescDigest(slang::SessionDesc* sessionDesc, ISlangBlob** outBlob) override;
+
/// Get the downstream compiler for a transition
IDownstreamCompiler* getDownstreamCompiler(CodeGenTarget source, CodeGenTarget target);
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp
index 4b11a5216..1aa014a4b 100644
--- a/source/slang/slang.cpp
+++ b/source/slang/slang.cpp
@@ -878,6 +878,18 @@ SLANG_NO_THROW SlangResult SLANG_MCALL Session::parseCommandLineArguments(
return SLANG_OK;
}
+SLANG_NO_THROW SlangResult SLANG_MCALL Session::getSessionDescDigest(slang::SessionDesc* sessionDesc, ISlangBlob** outBlob)
+{
+ ComPtr<slang::ISession> tempSession;
+ createSession(*sessionDesc, tempSession.writeRef());
+ auto linkage = static_cast<Linkage*>(tempSession.get());
+ DigestBuilder<SHA1> digestBuilder;
+ linkage->buildHash(digestBuilder, -1);
+ auto blob = digestBuilder.finalize().toBlob();
+ *outBlob = blob.detach();
+ return SLANG_OK;
+}
+
Profile getEffectiveProfile(EntryPoint* entryPoint, TargetRequest* target)
{
auto entryPointProfile = entryPoint->getProfile();
@@ -1488,37 +1500,53 @@ void Linkage::buildHash(DigestBuilder<SHA1>& builder, SlangInt targetIndex)
// Add compiler options, including search path, preprocessor includes, etc.
m_optionSet.buildHash(builder);
- // Add the target specified by targetIndex
- auto targetReq = targets[targetIndex];
- targetReq->getOptionSet().buildHash(builder);
+ auto addTargetDigest = [&](TargetRequest* targetReq)
+ {
+ targetReq->getOptionSet().buildHash(builder);
- const PassThroughMode passThroughMode = getDownstreamCompilerRequiredForTarget(targetReq->getTarget());
- const SourceLanguage sourceLanguage = getDefaultSourceLanguageForDownstreamCompiler(passThroughMode);
+ const PassThroughMode passThroughMode = getDownstreamCompilerRequiredForTarget(targetReq->getTarget());
+ const SourceLanguage sourceLanguage = getDefaultSourceLanguageForDownstreamCompiler(passThroughMode);
- // Add prelude for the given downstream compiler.
- ComPtr<ISlangBlob> prelude;
- getGlobalSession()->getLanguagePrelude((SlangSourceLanguage)sourceLanguage, prelude.writeRef());
- if (prelude)
- {
- builder.append(prelude);
- }
+ // Add prelude for the given downstream compiler.
+ ComPtr<ISlangBlob> prelude;
+ getGlobalSession()->getLanguagePrelude((SlangSourceLanguage)sourceLanguage, prelude.writeRef());
+ if (prelude)
+ {
+ builder.append(prelude);
+ }
- // TODO: Downstream compilers (specifically dxc) can currently #include additional dependencies.
- // This is currently the case for NVAPI headers included in the prelude.
- // These dependencies are currently not picked up by the shader cache which is a significant issue.
- // This can only be fixed by running the preprocessor in the slang compiler so dxc (or any other
- // downstream compiler for that matter) isn't resolving any includes implicitly.
+ // TODO: Downstream compilers (specifically dxc) can currently #include additional dependencies.
+ // This is currently the case for NVAPI headers included in the prelude.
+ // These dependencies are currently not picked up by the shader cache which is a significant issue.
+ // This can only be fixed by running the preprocessor in the slang compiler so dxc (or any other
+ // downstream compiler for that matter) isn't resolving any includes implicitly.
- // Add the downstream compiler version (if it exists) to the hash
- auto downstreamCompiler = getSessionImpl()->getOrLoadDownstreamCompiler(passThroughMode, nullptr);
- if (downstreamCompiler)
+ // Add the downstream compiler version (if it exists) to the hash
+ auto downstreamCompiler = getSessionImpl()->getOrLoadDownstreamCompiler(passThroughMode, nullptr);
+ if (downstreamCompiler)
+ {
+ ComPtr<ISlangBlob> versionString;
+ if (SLANG_SUCCEEDED(downstreamCompiler->getVersionString(versionString.writeRef())))
+ {
+ builder.append(versionString);
+ }
+ }
+ };
+
+ // Add the target specified by targetIndex
+ if (targetIndex == -1)
{
- ComPtr<ISlangBlob> versionString;
- if (SLANG_SUCCEEDED(downstreamCompiler->getVersionString(versionString.writeRef())))
+ // -1 means all targets.
+ for (auto targetReq : targets)
{
- builder.append(versionString);
+ addTargetDigest(targetReq);
}
}
+ else
+ {
+ auto targetReq = targets[targetIndex];
+ addTargetDigest(targetReq);
+ }
}
SlangResult Linkage::addSearchPath(