summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorSai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com>2024-11-13 19:50:52 -0500
committerGitHub <noreply@github.com>2024-11-13 16:50:52 -0800
commit5cb960a72449dad36594e8ad2bfa899f5aaa11be (patch)
tree5ee550e8a50ccc2833b8e6fdf139a5b6da3294c2 /source
parentf7149b94847a91f9f1f364e79f1be750aaf90191 (diff)
Fix WGSL emit for '&' and add bindings for thread group size (#5557)
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source')
-rw-r--r--source/slang-wasm/slang-wasm-bindings.cpp14
-rw-r--r--source/slang-wasm/slang-wasm.cpp12
-rw-r--r--source/slang-wasm/slang-wasm.h16
-rw-r--r--source/slang/slang-emit-wgsl.cpp1
4 files changed, 43 insertions, 0 deletions
diff --git a/source/slang-wasm/slang-wasm-bindings.cpp b/source/slang-wasm/slang-wasm-bindings.cpp
index 8c8257795..43a516ccc 100644
--- a/source/slang-wasm/slang-wasm-bindings.cpp
+++ b/source/slang-wasm/slang-wasm-bindings.cpp
@@ -53,6 +53,16 @@ EMSCRIPTEN_BINDINGS(slang)
allow_raw_pointers())
.function("getBindingIndex", &slang::wgsl::VariableLayoutReflection::getBindingIndex);
+ class_<slang::wgsl::EntryPointReflection>("EntryPointReflection")
+ .function(
+ "getComputeThreadGroupSize",
+ &slang::wgsl::EntryPointReflection::getComputeThreadGroupSize);
+
+ class_<slang::wgsl::EntryPointReflection::ThreadGroupSize>("ThreadGroupSize")
+ .property("x", &slang::wgsl::EntryPointReflection::ThreadGroupSize::x)
+ .property("y", &slang::wgsl::EntryPointReflection::ThreadGroupSize::y)
+ .property("z", &slang::wgsl::EntryPointReflection::ThreadGroupSize::z);
+
class_<slang::wgsl::ProgramLayout>("ProgramLayout")
.function("toJsonObject", &slang::wgsl::ProgramLayout::toJsonObject)
.function("getParameterCount", &slang::wgsl::ProgramLayout::getParameterCount)
@@ -63,6 +73,10 @@ EMSCRIPTEN_BINDINGS(slang)
.function(
"getGlobalParamsTypeLayout",
&slang::wgsl::ProgramLayout::getGlobalParamsTypeLayout,
+ allow_raw_pointers())
+ .function(
+ "findEntryPointByName",
+ &slang::wgsl::ProgramLayout::findEntryPointByName,
allow_raw_pointers());
enum_<slang::BindingType>("BindingType")
diff --git a/source/slang-wasm/slang-wasm.cpp b/source/slang-wasm/slang-wasm.cpp
index 10fc86029..a1ce2920d 100644
--- a/source/slang-wasm/slang-wasm.cpp
+++ b/source/slang-wasm/slang-wasm.cpp
@@ -442,6 +442,18 @@ TypeLayoutReflection* ProgramLayout::getGlobalParamsTypeLayout()
return (slang::wgsl::TypeLayoutReflection*)(interface()->getGlobalParamsTypeLayout());
}
+EntryPointReflection* ProgramLayout::findEntryPointByName(std::string name)
+{
+ return (slang::wgsl::EntryPointReflection*)(interface()->findEntryPointByName(name.c_str()));
+}
+
+EntryPointReflection::ThreadGroupSize EntryPointReflection::getComputeThreadGroupSize()
+{
+ SlangUInt size[3];
+ interface()->getComputeThreadGroupSize(3, size);
+ return {size[0], size[1], size[2]};
+}
+
BindingType TypeLayoutReflection::getDescriptorSetDescriptorRangeType(
unsigned int setIndex,
unsigned int rangeIndex)
diff --git a/source/slang-wasm/slang-wasm.h b/source/slang-wasm/slang-wasm.h
index 4288aed18..f6b14117a 100644
--- a/source/slang-wasm/slang-wasm.h
+++ b/source/slang-wasm/slang-wasm.h
@@ -72,6 +72,20 @@ public:
}
};
+class EntryPointReflection
+{
+
+public:
+ struct ThreadGroupSize
+ {
+ unsigned int x;
+ unsigned int y;
+ unsigned int z;
+ };
+
+ ThreadGroupSize getComputeThreadGroupSize();
+ slang::EntryPointReflection* interface() const { return (slang::EntryPointReflection*)this; }
+};
class ProgramLayout
{
@@ -81,6 +95,8 @@ public:
slang::wgsl::TypeLayoutReflection* getGlobalParamsTypeLayout();
+ slang::wgsl::EntryPointReflection* findEntryPointByName(std::string name);
+
slang::ProgramLayout* interface() const { return (slang::ProgramLayout*)this; }
emscripten::val toJsonObject();
diff --git a/source/slang/slang-emit-wgsl.cpp b/source/slang/slang-emit-wgsl.cpp
index b5ed7b9d2..fcc4b615f 100644
--- a/source/slang/slang-emit-wgsl.cpp
+++ b/source/slang/slang-emit-wgsl.cpp
@@ -1341,6 +1341,7 @@ bool WGSLSourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inOu
}
case kIROp_BitXor:
case kIROp_BitOr:
+ case kIROp_BitAnd:
{
// Emit bitwise operators with paranthesis to avoid precedence issues
const auto emitOp = getEmitOpForOp(inst->getOp());