summaryrefslogtreecommitdiffstats
path: root/tools/gfx/renderer-shared.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2022-09-15 20:37:45 -0700
committerGitHub <noreply@github.com>2022-09-15 20:37:45 -0700
commita5d3bec25d70f23da1e79cd7773981ff34593611 (patch)
tree92c8cb983c57bbee141d4e6f3f91f265e04d6a08 /tools/gfx/renderer-shared.cpp
parenta6032446c6bf7f64d1e201bf438a4c7605a3dbb4 (diff)
Run simple compute kernel in gfx-smoke test. (#2400)
Diffstat (limited to 'tools/gfx/renderer-shared.cpp')
-rw-r--r--tools/gfx/renderer-shared.cpp31
1 files changed, 24 insertions, 7 deletions
diff --git a/tools/gfx/renderer-shared.cpp b/tools/gfx/renderer-shared.cpp
index 2e5454851..69046d216 100644
--- a/tools/gfx/renderer-shared.cpp
+++ b/tools/gfx/renderer-shared.cpp
@@ -472,14 +472,31 @@ Result RendererBase::createProgram2(
ISlangBlob** outDiagnostic)
{
auto slangSession = slangContext.session.get();
-
- SLANG_RELEASE_ASSERT(desc.sourceType == ShaderModuleSourceType::SlangSourceFile);
-
- auto fileName = (char*)desc.sourceData;
+ slang::IModule* module = nullptr;
ComPtr<slang::IBlob> diagnosticsBlob;
- slang::IModule* module = slangSession->loadModule(fileName, diagnosticsBlob.writeRef());
- if (!module)
- return SLANG_FAIL;
+ switch (desc.sourceType)
+ {
+ case ShaderModuleSourceType::SlangSourceFile:
+ {
+ auto fileName = (char*)desc.sourceData;
+ module = slangSession->loadModule(fileName, diagnosticsBlob.writeRef());
+ if (!module)
+ return SLANG_FAIL;
+ break;
+ }
+ case ShaderModuleSourceType::SlangSource:
+ {
+ auto hash = getStableHashCode32((char*)desc.sourceData, desc.sourceDataSize);
+ auto hashStr = String(hash);
+ auto srcBlob = UnownedRawBlob::create(desc.sourceData, desc.sourceDataSize);
+ module = slangSession->loadModuleFromSource(hashStr.getBuffer(), hashStr.getBuffer(), srcBlob, diagnosticsBlob.writeRef());
+ if (!module)
+ return SLANG_FAIL;
+ break;
+ }
+ default:
+ SLANG_RELEASE_ASSERT(false);
+ }
Slang::List<ComPtr<slang::IComponentType>> componentTypes;
componentTypes.add(ComPtr<slang::IComponentType>(module));