Skip to content

Commit

Permalink
Add 'findAndCheckEntryPoint' to wasm binding (#5337)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaizhangNV authored Oct 17, 2024
1 parent fa3287f commit 11e1eca
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions source/slang-wasm/slang-wasm-bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ EMSCRIPTEN_BINDINGS(slang)
.function(
"findEntryPointByName",
&slang::wgsl::Module::findEntryPointByName,
return_value_policy::take_ownership())
.function(
"findAndCheckEntryPoint",
&slang::wgsl::Module::findAndCheckEntryPoint,
return_value_policy::take_ownership());

value_object<slang::wgsl::Error>("Error")
Expand Down
25 changes: 25 additions & 0 deletions source/slang-wasm/slang-wasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,31 @@ EntryPoint* Module::findEntryPointByName(const std::string& name)
return new EntryPoint(entryPoint);
}


EntryPoint* Module::findAndCheckEntryPoint(const std::string& name, int stage)
{
Slang::ComPtr<IEntryPoint> entryPoint;
{
Slang::ComPtr<slang::IBlob> diagnosticsBlob;
SlangResult result = moduleInterface()->findAndCheckEntryPoint(
name.c_str(), (SlangStage)stage, entryPoint.writeRef(), diagnosticsBlob.writeRef());
if (!SLANG_SUCCEEDED(result))
{
g_error.type = std::string("USER");
g_error.result = result;

if (diagnosticsBlob->getBufferSize())
{
char* diagnostics = (char*)diagnosticsBlob->getBufferPointer();
g_error.message = std::string(diagnostics);
}
return nullptr;
}
}

return new EntryPoint(entryPoint);
}

ComponentType* Session::createCompositeComponentType(
const std::vector<ComponentType*>& components)
{
Expand Down
1 change: 1 addition & 0 deletions source/slang-wasm/slang-wasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class Module : public ComponentType
Module(slang::IModule* interface) : ComponentType(interface) {}

EntryPoint* findEntryPointByName(const std::string& name);
EntryPoint* findAndCheckEntryPoint(const std::string& name, int stage);

slang::IModule* moduleInterface() const {
return static_cast<slang::IModule*>(interface());
Expand Down

0 comments on commit 11e1eca

Please sign in to comment.