Skip to content

Commit 11e1eca

Browse files
authored
Add 'findAndCheckEntryPoint' to wasm binding (shader-slang#5337)
1 parent fa3287f commit 11e1eca

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

source/slang-wasm/slang-wasm-bindings.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ EMSCRIPTEN_BINDINGS(slang)
4646
.function(
4747
"findEntryPointByName",
4848
&slang::wgsl::Module::findEntryPointByName,
49+
return_value_policy::take_ownership())
50+
.function(
51+
"findAndCheckEntryPoint",
52+
&slang::wgsl::Module::findAndCheckEntryPoint,
4953
return_value_policy::take_ownership());
5054

5155
value_object<slang::wgsl::Error>("Error")

source/slang-wasm/slang-wasm.cpp

+25
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,31 @@ EntryPoint* Module::findEntryPointByName(const std::string& name)
103103
return new EntryPoint(entryPoint);
104104
}
105105

106+
107+
EntryPoint* Module::findAndCheckEntryPoint(const std::string& name, int stage)
108+
{
109+
Slang::ComPtr<IEntryPoint> entryPoint;
110+
{
111+
Slang::ComPtr<slang::IBlob> diagnosticsBlob;
112+
SlangResult result = moduleInterface()->findAndCheckEntryPoint(
113+
name.c_str(), (SlangStage)stage, entryPoint.writeRef(), diagnosticsBlob.writeRef());
114+
if (!SLANG_SUCCEEDED(result))
115+
{
116+
g_error.type = std::string("USER");
117+
g_error.result = result;
118+
119+
if (diagnosticsBlob->getBufferSize())
120+
{
121+
char* diagnostics = (char*)diagnosticsBlob->getBufferPointer();
122+
g_error.message = std::string(diagnostics);
123+
}
124+
return nullptr;
125+
}
126+
}
127+
128+
return new EntryPoint(entryPoint);
129+
}
130+
106131
ComponentType* Session::createCompositeComponentType(
107132
const std::vector<ComponentType*>& components)
108133
{

source/slang-wasm/slang-wasm.h

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class Module : public ComponentType
6060
Module(slang::IModule* interface) : ComponentType(interface) {}
6161

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

6465
slang::IModule* moduleInterface() const {
6566
return static_cast<slang::IModule*>(interface());

0 commit comments

Comments
 (0)