summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorarya <64514807+arya3d@users.noreply.github.com>2024-12-24 09:34:59 -0800
committerGitHub <noreply@github.com>2024-12-24 09:34:59 -0800
commit1b5679f9556b65c65146123ce98ca4f62fe71d72 (patch)
treee3b4bd02b7a7279d8ff3fcdcdcc9578f6ef3122c /source
parente15c2802434058096bc0ced0ac23b39226a17334 (diff)
Reflection API Wasm Bindings Part1 (#5936)
* add a lot of missing classes, functios and enums * typescript defintion generation * formatting * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Diffstat (limited to 'source')
-rw-r--r--source/slang-wasm/CMakeLists.txt5
-rw-r--r--source/slang-wasm/slang-wasm-bindings.cpp158
-rw-r--r--source/slang-wasm/slang-wasm.cpp199
-rw-r--r--source/slang-wasm/slang-wasm.h127
4 files changed, 469 insertions, 20 deletions
diff --git a/source/slang-wasm/CMakeLists.txt b/source/slang-wasm/CMakeLists.txt
index 2f3e6e8d3..c6c5601e9 100644
--- a/source/slang-wasm/CMakeLists.txt
+++ b/source/slang-wasm/CMakeLists.txt
@@ -22,5 +22,8 @@ if(EMSCRIPTEN)
INCLUDE_DIRECTORIES_PUBLIC ${slang_SOURCE_DIR}/include .
)
# To generate binding code
- target_link_options(slang-wasm PUBLIC "--bind")
+ target_link_options(
+ slang-wasm
+ PUBLIC "--bind" "--emit-tsd" "interface.d.ts" "-s" "EXPORT_ES6=1"
+ )
endif()
diff --git a/source/slang-wasm/slang-wasm-bindings.cpp b/source/slang-wasm/slang-wasm-bindings.cpp
index 43a516ccc..0871665b9 100644
--- a/source/slang-wasm/slang-wasm-bindings.cpp
+++ b/source/slang-wasm/slang-wasm-bindings.cpp
@@ -45,6 +45,36 @@ EMSCRIPTEN_BINDINGS(slang)
"getDescriptorSetDescriptorRangeType",
&slang::wgsl::TypeLayoutReflection::getDescriptorSetDescriptorRangeType);
+ enum_<slang::Modifier::ID>("ModifierID")
+ .value("Shared", slang::Modifier::ID::Shared)
+ .value("NoDiff", slang::Modifier::ID::NoDiff)
+ .value("Static", slang::Modifier::ID::Static)
+ .value("Const", slang::Modifier::ID::Const)
+ .value("Export", slang::Modifier::ID::Export)
+ .value("Extern", slang::Modifier::ID::Extern)
+ .value("Differentiable", slang::Modifier::ID::Differentiable)
+ .value("Mutating", slang::Modifier::ID::Mutating)
+ .value("In", slang::Modifier::ID::In)
+ .value("Out", slang::Modifier::ID::Out)
+ .value("InOut", slang::Modifier::ID::InOut);
+
+ class_<slang::Modifier>("Modifier");
+
+ class_<slang::wgsl::VariableReflection>("VariableReflection")
+ .function("getName", &slang::wgsl::VariableReflection::getName)
+ .function(
+ "findModifier",
+ &slang::wgsl::VariableReflection::findModifier,
+ allow_raw_pointers())
+ .function("getType", &slang::wgsl::VariableReflection::getType, allow_raw_pointers())
+ .function("getUserAttributeCount", &slang::wgsl::VariableReflection::getUserAttributeCount)
+ .function(
+ "getUserAttributeByIndex",
+ &slang::wgsl::VariableReflection::getUserAttributeByIndex,
+ allow_raw_pointers())
+ .function("hasDefaultValue", &slang::wgsl::VariableReflection::hasDefaultValue);
+
+
class_<slang::wgsl::VariableLayoutReflection>("VariableLayoutReflection")
.function("getName", &slang::wgsl::VariableLayoutReflection::getName)
.function(
@@ -53,6 +83,130 @@ EMSCRIPTEN_BINDINGS(slang)
allow_raw_pointers())
.function("getBindingIndex", &slang::wgsl::VariableLayoutReflection::getBindingIndex);
+ class_<slang::wgsl::GenericReflection>("GenericReflection")
+ .function("getName", &slang::wgsl::GenericReflection::getName)
+ .function("getTypeParameterCount", &slang::wgsl::GenericReflection::getTypeParameterCount)
+ .function("getValueParameterCount", &slang::wgsl::GenericReflection::getValueParameterCount)
+ .function("getInnerKind", &slang::wgsl::GenericReflection::getInnerKind)
+ .function("asDecl", &slang::wgsl::GenericReflection::asDecl, allow_raw_pointers())
+ // .function(
+ // "getTypeParameterConstraintCount",
+ // &slang::wgsl::GenericReflection::getTypeParameterConstraintCount,
+ // allow_raw_pointers())
+ .function(
+ "getTypeParameter",
+ &slang::wgsl::GenericReflection::getTypeParameter,
+ allow_raw_pointers())
+ .function(
+ "getValueParameter",
+ &slang::wgsl::GenericReflection::getValueParameter,
+ allow_raw_pointers())
+ .function(
+ "getInnerDecl",
+ &slang::wgsl::GenericReflection::getInnerDecl,
+ allow_raw_pointers())
+ .function(
+ "getOuterGenericContainer",
+ &slang::wgsl::GenericReflection::getOuterGenericContainer,
+ allow_raw_pointers());
+
+ enum_<SlangDeclKind>("SlangDeclKind")
+ .value(
+ "SLANG_DECL_KIND_UNSUPPORTED_FOR_REFLECTION",
+ SlangDeclKind::SLANG_DECL_KIND_UNSUPPORTED_FOR_REFLECTION)
+ .value("SLANG_DECL_KIND_STRUCT", SlangDeclKind::SLANG_DECL_KIND_STRUCT)
+ .value("SLANG_DECL_KIND_FUNC", SlangDeclKind::SLANG_DECL_KIND_FUNC)
+ .value("SLANG_DECL_KIND_MODULE", SlangDeclKind::SLANG_DECL_KIND_MODULE)
+ .value("SLANG_DECL_KIND_GENERIC", SlangDeclKind::SLANG_DECL_KIND_GENERIC)
+ .value("SLANG_DECL_KIND_VARIABLE", SlangDeclKind::SLANG_DECL_KIND_VARIABLE)
+ .value("SLANG_DECL_KIND_NAMESPACE", SlangDeclKind::SLANG_DECL_KIND_NAMESPACE);
+
+ class_<slang::wgsl::DeclReflection>("DeclReflection")
+ .function("getName", &slang::wgsl::DeclReflection::getName)
+ .function("getChildrenCount", &slang::wgsl::DeclReflection::getChildrenCount)
+ .function("getKind", &slang::wgsl::DeclReflection::getKind)
+ .function("getChild", &slang::wgsl::DeclReflection::getChild, allow_raw_pointers())
+ .function("getType", &slang::wgsl::DeclReflection::getType, allow_raw_pointers())
+ .function("asVariable", &slang::wgsl::DeclReflection::asVariable, allow_raw_pointers())
+ .function("asFunction", &slang::wgsl::DeclReflection::asFunction, allow_raw_pointers())
+ .function("asGeneric", &slang::wgsl::DeclReflection::asGeneric, allow_raw_pointers())
+ .function("getParent", &slang::wgsl::DeclReflection::getParent, allow_raw_pointers());
+
+ enum_<slang::DeclReflection::Kind>("DeclReflectionKind")
+ .value("Unsupported", slang::DeclReflection::Kind::Unsupported)
+ .value("Struct", slang::DeclReflection::Kind::Struct)
+ .value("Func", slang::DeclReflection::Kind::Func)
+ .value("Module", slang::DeclReflection::Kind::Module)
+ .value("Generic", slang::DeclReflection::Kind::Generic)
+ .value("Variable", slang::DeclReflection::Kind::Variable)
+ .value("Namespace", slang::DeclReflection::Kind::Namespace);
+
+ enum_<slang::TypeReflection::ScalarType>("ScalarType")
+ .value("None", slang::TypeReflection::ScalarType::None)
+ .value("Void", slang::TypeReflection::ScalarType::Void)
+ .value("Bool", slang::TypeReflection::ScalarType::Bool)
+ .value("Int32", slang::TypeReflection::ScalarType::Int32)
+ .value("UInt32", slang::TypeReflection::ScalarType::UInt32)
+ .value("Int64", slang::TypeReflection::ScalarType::Int64)
+ .value("UInt64", slang::TypeReflection::ScalarType::UInt64)
+ .value("Float16", slang::TypeReflection::ScalarType::Float16)
+ .value("Float32", slang::TypeReflection::ScalarType::Float32)
+ .value("Float64", slang::TypeReflection::ScalarType::Float64)
+ .value("Int8", slang::TypeReflection::ScalarType::Int8)
+ .value("UInt8", slang::TypeReflection::ScalarType::UInt8)
+ .value("Int16", slang::TypeReflection::ScalarType::Int16)
+ .value("UInt16", slang::TypeReflection::ScalarType::UInt16);
+
+ class_<slang::wgsl::TypeReflection>("TypeReflection")
+ .function("getScalarType", &slang::wgsl::TypeReflection::getScalarType)
+ .function("getKind", &slang::wgsl::TypeReflection::getKind);
+
+ enum_<slang::TypeReflection::Kind>("TypeReflectionKind")
+ .value("None", slang::TypeReflection::Kind::None)
+ .value("Struct", slang::TypeReflection::Kind::Struct)
+ .value("Array", slang::TypeReflection::Kind::Array)
+ .value("Matrix", slang::TypeReflection::Kind::Matrix)
+ .value("Vector", slang::TypeReflection::Kind::Vector)
+ .value("Scalar", slang::TypeReflection::Kind::Scalar)
+ .value("ConstantBuffer", slang::TypeReflection::Kind::ConstantBuffer)
+ .value("Resource", slang::TypeReflection::Kind::Resource)
+ .value("SamplerState", slang::TypeReflection::Kind::SamplerState)
+ .value("TextureBuffer", slang::TypeReflection::Kind::TextureBuffer)
+ .value("ShaderStorageBuffer", slang::TypeReflection::Kind::ShaderStorageBuffer)
+ .value("ParameterBlock", slang::TypeReflection::Kind::ParameterBlock)
+ .value("GenericTypeParameter", slang::TypeReflection::Kind::GenericTypeParameter)
+ .value("Interface", slang::TypeReflection::Kind::Interface)
+ .value("OutputStream", slang::TypeReflection::Kind::OutputStream)
+ .value("Specialized", slang::TypeReflection::Kind::Specialized)
+ .value("Feedback", slang::TypeReflection::Kind::Feedback)
+ .value("Pointer", slang::TypeReflection::Kind::Pointer)
+ .value("DynamicResource", slang::TypeReflection::Kind::DynamicResource);
+
+
+ class_<slang::wgsl::UserAttribute>("UserAttribute")
+ .function("getName", &slang::wgsl::UserAttribute::getName)
+ .function("getArgumentCount", &slang::wgsl::UserAttribute::getArgumentCount)
+ .function(
+ "getArgumentType",
+ &slang::wgsl::UserAttribute::getArgumentType,
+ allow_raw_pointers())
+ .function(
+ "getArgumentValueString",
+ &slang::wgsl::UserAttribute::getArgumentValueString,
+ allow_raw_pointers())
+ .function(
+ "getArgumentValueFloat",
+ &slang::wgsl::UserAttribute::getArgumentValueFloat,
+ allow_raw_pointers());
+
+ class_<slang::wgsl::FunctionReflection>("FunctionReflection")
+ .function("getName", &slang::wgsl::FunctionReflection::getName)
+ .function("getUserAttributeCount", &slang::wgsl::FunctionReflection::getUserAttributeCount)
+ .function(
+ "getUserAttributeByIndex",
+ &slang::wgsl::FunctionReflection::getUserAttributeByIndex,
+ allow_raw_pointers());
+
class_<slang::wgsl::EntryPointReflection>("EntryPointReflection")
.function(
"getComputeThreadGroupSize",
@@ -77,6 +231,10 @@ EMSCRIPTEN_BINDINGS(slang)
.function(
"findEntryPointByName",
&slang::wgsl::ProgramLayout::findEntryPointByName,
+ allow_raw_pointers())
+ .function(
+ "findFunctionByName",
+ &slang::wgsl::ProgramLayout::findFunctionByName,
allow_raw_pointers());
enum_<slang::BindingType>("BindingType")
diff --git a/source/slang-wasm/slang-wasm.cpp b/source/slang-wasm/slang-wasm.cpp
index a1ce2920d..9c705e5ad 100644
--- a/source/slang-wasm/slang-wasm.cpp
+++ b/source/slang-wasm/slang-wasm.cpp
@@ -5,7 +5,6 @@
#include "../slang/slang-language-server.h"
#include <slang.h>
-#include <string>
#include <vector>
using namespace slang;
@@ -144,7 +143,6 @@ emscripten::val Module::findEntryPointByName(const std::string& name)
return emscripten::val(EntryPoint(entryPoint.get(), m_session));
}
-
emscripten::val Module::findAndCheckEntryPoint(const std::string& name, int stage)
{
Slang::ComPtr<IEntryPoint> entryPoint;
@@ -409,12 +407,12 @@ emscripten::val ComponentType::loadStrings()
return emscripten::val::array(result);
}
-ProgramLayout* ComponentType::getLayout(unsigned int targetIndex)
+ProgramLayout* ComponentType::getLayout(uint32_t targetIndex)
{
return (slang::wgsl::ProgramLayout*)interface()->getLayout(targetIndex);
}
-unsigned int ProgramLayout::getParameterCount()
+uint32_t ProgramLayout::getParameterCount()
{
return interface()->getParameterCount();
}
@@ -432,7 +430,7 @@ emscripten::val ProgramLayout::toJsonObject()
return parsedObject;
}
-VariableLayoutReflection* ProgramLayout::getParameterByIndex(unsigned int index)
+VariableLayoutReflection* ProgramLayout::getParameterByIndex(uint32_t index)
{
return (slang::wgsl::VariableLayoutReflection*)(interface()->getParameterByIndex(index));
}
@@ -442,6 +440,11 @@ TypeLayoutReflection* ProgramLayout::getGlobalParamsTypeLayout()
return (slang::wgsl::TypeLayoutReflection*)(interface()->getGlobalParamsTypeLayout());
}
+FunctionReflection* ProgramLayout::findFunctionByName(std::string name)
+{
+ return (slang::wgsl::FunctionReflection*)(interface()->findFunctionByName(name.c_str()));
+}
+
EntryPointReflection* ProgramLayout::findEntryPointByName(std::string name)
{
return (slang::wgsl::EntryPointReflection*)(interface()->findEntryPointByName(name.c_str()));
@@ -455,27 +458,203 @@ EntryPointReflection::ThreadGroupSize EntryPointReflection::getComputeThreadGrou
}
BindingType TypeLayoutReflection::getDescriptorSetDescriptorRangeType(
- unsigned int setIndex,
- unsigned int rangeIndex)
+ uint32_t setIndex,
+ uint32_t rangeIndex)
{
return interface()->getDescriptorSetDescriptorRangeType(setIndex, rangeIndex);
}
+std::string DeclReflection::getName()
+{
+ return interface()->getName();
+}
+
+
+slang::DeclReflection::Kind DeclReflection::getKind()
+{
+ return interface()->getKind();
+}
+
+uint32_t DeclReflection::getChildrenCount()
+{
+ return interface()->getChildrenCount();
+};
+
+slang::wgsl::DeclReflection* DeclReflection::getChild(uint32_t index)
+{
+ return (slang::wgsl::DeclReflection*)interface()->getChild(index);
+}
+
+slang::wgsl::TypeReflection* DeclReflection::getType()
+{
+ return (slang::wgsl::TypeReflection*)interface()->getType();
+}
+slang::wgsl::VariableReflection* DeclReflection::asVariable()
+{
+ return (slang::wgsl::VariableReflection*)interface()->asVariable();
+}
+slang::wgsl::FunctionReflection* DeclReflection::asFunction()
+{
+ return (slang::wgsl::FunctionReflection*)interface()->asFunction();
+}
+slang::wgsl::GenericReflection* DeclReflection::asGeneric()
+{
+ return (slang::wgsl::GenericReflection*)interface()->asGeneric();
+}
+slang::wgsl::DeclReflection* DeclReflection::getParent()
+{
+ return (slang::wgsl::DeclReflection*)interface()->getParent();
+}
+
+
+std::string GenericReflection::getName()
+{
+ return interface()->getName();
+}
+
+slang::wgsl::DeclReflection* GenericReflection::asDecl()
+{
+ return (slang::wgsl::DeclReflection*)interface()->asDecl();
+}
+
+uint32_t GenericReflection::getTypeParameterCount()
+{
+ return interface()->getTypeParameterCount();
+}
+slang::wgsl::VariableReflection* GenericReflection::getTypeParameter(unsigned index)
+{
+ return (slang::wgsl::VariableReflection*)interface()->getTypeParameter(index);
+}
+uint32_t GenericReflection::getValueParameterCount()
+{
+ return interface()->getValueParameterCount();
+}
+slang::wgsl::VariableReflection* GenericReflection::getValueParameter(unsigned index)
+{
+ return (slang::wgsl::VariableReflection*)interface()->getValueParameter(index);
+}
+
+slang::wgsl::DeclReflection* GenericReflection::getInnerDecl()
+{
+ return (slang::wgsl::DeclReflection*)interface()->getInnerDecl();
+}
+
+SlangDeclKind GenericReflection::getInnerKind()
+{
+ return interface()->getInnerKind();
+}
+
+slang::wgsl::GenericReflection* GenericReflection::getOuterGenericContainer()
+{
+ return (slang::wgsl::GenericReflection*)interface()->getOuterGenericContainer();
+}
+
std::string VariableLayoutReflection::getName()
{
return interface()->getName();
}
-TypeLayoutReflection* VariableLayoutReflection::getTypeLayout()
+slang::wgsl::TypeLayoutReflection* VariableLayoutReflection::getTypeLayout()
{
return (slang::wgsl::TypeLayoutReflection*)(interface()->getTypeLayout());
}
-unsigned int VariableLayoutReflection::getBindingIndex()
+uint32_t VariableLayoutReflection::getBindingIndex()
{
return interface()->getBindingIndex();
}
+std::string VariableReflection::getName()
+{
+ return interface()->getName();
+}
+
+uint32_t VariableReflection::getUserAttributeCount()
+{
+ return interface()->getUserAttributeCount();
+}
+
+slang::wgsl::UserAttribute* VariableReflection::getUserAttributeByIndex(uint32_t index)
+{
+ return (slang::wgsl::UserAttribute*)interface()->getUserAttributeByIndex(index);
+}
+
+bool VariableReflection::hasDefaultValue()
+{
+ return interface()->hasDefaultValue();
+}
+
+slang::wgsl::TypeReflection* VariableReflection::getType()
+{
+ return (slang::wgsl::TypeReflection*)interface()->getType();
+}
+
+Modifier* VariableReflection::findModifier(Modifier::ID id)
+{
+ return interface()->findModifier(id);
+}
+
+slang::wgsl::VariableReflection* TypeReflection::getFieldByIndex(uint32_t index)
+{
+ return (slang::wgsl::VariableReflection*)interface()->getFieldByIndex(index);
+}
+
+slang::TypeReflection::ScalarType TypeReflection::getScalarType()
+{
+ return interface()->getScalarType();
+}
+
+slang::TypeReflection::Kind TypeReflection::getKind()
+{
+ return interface()->getKind();
+}
+
+
+std::string UserAttribute::getName()
+{
+ return interface()->getName();
+}
+
+float UserAttribute::getArgumentValueFloat(uint32_t index)
+{
+ float value;
+ interface()->getArgumentValueFloat(index, &value);
+ return value;
+}
+
+std::string UserAttribute::getArgumentValueString(uint32_t index)
+{
+ size_t len = 0;
+ const char* out = interface()->getArgumentValueString(index, &len);
+ return std::string(out, len);
+}
+
+
+slang::wgsl::TypeReflection* UserAttribute::getArgumentType(uint32_t index)
+{
+ return (slang::wgsl::TypeReflection*)interface()->getArgumentType(index);
+}
+
+
+uint32_t UserAttribute::getArgumentCount()
+{
+ return interface()->getArgumentCount();
+}
+
+std::string FunctionReflection::getName()
+{
+ return interface()->getName();
+}
+
+uint32_t FunctionReflection::getUserAttributeCount()
+{
+ return interface()->getUserAttributeCount();
+}
+
+slang::wgsl::UserAttribute* FunctionReflection::getUserAttributeByIndex(uint32_t index)
+{
+ return (slang::wgsl::UserAttribute*)interface()->getUserAttributeByIndex(index);
+}
namespace lsp
{
@@ -666,8 +845,10 @@ std::optional<lsp::CompletionItem> LanguageServer::completionResolve(lsp::Comple
editItem.documentation.kind = coreArgs.documentation.kind;
editItem.documentation.value = coreArgs.documentation.value;
editItem.data = coreArgs.data;
+
for (auto character : coreArgs.commitCharacters)
editItem.commitCharacters.add(character);
+
auto coreResult = m_core->completionResolve(coreArgs, editItem);
if (coreResult.isNull)
return std::nullopt;
diff --git a/source/slang-wasm/slang-wasm.h b/source/slang-wasm/slang-wasm.h
index f6b14117a..352b5b3c4 100644
--- a/source/slang-wasm/slang-wasm.h
+++ b/source/slang-wasm/slang-wasm.h
@@ -1,9 +1,14 @@
#pragma once
+#include <emscripten.h>
#include <emscripten/val.h>
+#include <optional>
#include <slang-com-ptr.h>
#include <slang.h>
+#include <stdint.h>
+#include <string>
#include <unordered_map>
+#include <vector>
/**
The web assembly binding here is designed to make javascript code as simple and native as possible.
@@ -34,6 +39,14 @@ namespace slang
namespace wgsl
{
+class TypeLayoutReflection;
+class TypeReflection;
+class VariableLayoutReflection;
+class VariableReflection;
+class FunctionReflection;
+class GenericReflection;
+
+
class Error
{
public:
@@ -51,11 +64,94 @@ Error getLastError();
// in the form of [{name: STRING, value: INT}, ...].
emscripten::val getCompileTargets();
-class TypeLayoutReflection
+class DeclReflection
+{
+public:
+ std::string getName();
+ slang::DeclReflection::Kind getKind();
+ uint32_t getChildrenCount();
+ slang::wgsl::DeclReflection* getChild(uint32_t index);
+ slang::wgsl::TypeReflection* getType();
+ slang::wgsl::VariableReflection* asVariable();
+ slang::wgsl::FunctionReflection* asFunction();
+ slang::wgsl::GenericReflection* asGeneric();
+ slang::wgsl::DeclReflection* getParent();
+
+ slang::DeclReflection* interface() const { return (slang::DeclReflection*)this; };
+};
+
+class GenericReflection
+{
+
+public:
+ std::string getName();
+ slang::wgsl::DeclReflection* asDecl();
+ uint32_t getTypeParameterCount();
+ slang::wgsl::VariableReflection* getTypeParameter(unsigned index);
+ uint32_t getValueParameterCount();
+ slang::wgsl::VariableReflection* getValueParameter(unsigned index);
+ // uint32_t getTypeParameterConstraintCount(VariableReflection* typeParam);
+ // slang::wgsl::TypeReflection* getTypeParameterConstraintType(
+ // VariableReflection* typeParam,
+ // unsigned index);
+ slang::wgsl::DeclReflection* getInnerDecl();
+ SlangDeclKind getInnerKind();
+ slang::wgsl::GenericReflection* getOuterGenericContainer();
+ // TypeReflection* getConcreteType(slang::wgsl::VariableReflection* typeParam);
+ // int64_t getConcreteIntVal(slang::wgsl::VariableReflection* valueParam);
+ // GenericReflection* applySpecializations(slang::wgsl::GenericReflection* generic);
+
+ slang::GenericReflection* interface() const { return (slang::GenericReflection*)this; };
+};
+
+class TypeReflection
+{
+
+public:
+ slang::TypeReflection::ScalarType getScalarType();
+ slang::TypeReflection::Kind getKind();
+ uint32_t getFieldCount();
+ slang::wgsl::VariableReflection* getFieldByIndex(uint32_t index);
+
+ slang::TypeReflection* interface() const { return (slang::TypeReflection*)this; };
+};
+
+
+class UserAttribute
+{
+
+public:
+ std::string getName();
+ uint32_t getArgumentCount();
+ float getArgumentValueFloat(uint32_t index);
+ std::string getArgumentValueString(uint32_t index);
+ slang::wgsl::TypeReflection* getArgumentType(uint32_t index);
+ slang::UserAttribute* interface() const { return (slang::UserAttribute*)this; };
+};
+
+
+class VariableReflection
{
public:
- BindingType getDescriptorSetDescriptorRangeType(unsigned int setIndex, unsigned int rangeIndex);
+ std::string getName();
+ slang::wgsl::TypeReflection* getType();
+ Modifier* findModifier(Modifier::ID id);
+ uint32_t getUserAttributeCount();
+ slang::wgsl::UserAttribute* getUserAttributeByIndex(uint32_t index);
+ // slang::wgsl::UserAttribute* findUserAttributeByName(SlangSession* globalSession, std::string
+ // name);
+ bool hasDefaultValue();
+ // slang::wgsl::GenericReflection* getGenericContainer();
+ // slang::wgsl::VariableReflection* applySpecializations(slang::wgsl::GenericReflection*
+ // generic);
+ slang::VariableReflection* interface() const { return (slang::VariableReflection*)this; }
+};
+
+class TypeLayoutReflection
+{
+public:
+ BindingType getDescriptorSetDescriptorRangeType(uint32_t setIndex, uint32_t rangeIndex);
slang::TypeLayoutReflection* interface() const { return (slang::TypeLayoutReflection*)this; }
};
@@ -64,7 +160,7 @@ class VariableLayoutReflection
public:
std::string getName();
slang::wgsl::TypeLayoutReflection* getTypeLayout();
- unsigned int getBindingIndex();
+ uint32_t getBindingIndex();
slang::VariableLayoutReflection* interface() const
{
@@ -78,25 +174,36 @@ class EntryPointReflection
public:
struct ThreadGroupSize
{
- unsigned int x;
- unsigned int y;
- unsigned int z;
+ uint32_t x;
+ uint32_t y;
+ uint32_t z;
};
ThreadGroupSize getComputeThreadGroupSize();
- slang::EntryPointReflection* interface() const { return (slang::EntryPointReflection*)this; }
+ slang::EntryPointReflection* interface() const { return (slang::EntryPointReflection*)this; };
+};
+class FunctionReflection
+{
+
+public:
+ std::string getName();
+ uint32_t getUserAttributeCount();
+ slang::wgsl::UserAttribute* getUserAttributeByIndex(uint32_t index);
+ slang::FunctionReflection* interface() const { return (slang::FunctionReflection*)this; };
};
class ProgramLayout
{
public:
- unsigned int getParameterCount();
- slang::wgsl::VariableLayoutReflection* getParameterByIndex(unsigned int index);
+ uint32_t getParameterCount();
+ slang::wgsl::VariableLayoutReflection* getParameterByIndex(uint32_t index);
slang::wgsl::TypeLayoutReflection* getGlobalParamsTypeLayout();
slang::wgsl::EntryPointReflection* findEntryPointByName(std::string name);
+ slang::wgsl::FunctionReflection* findFunctionByName(std::string name);
+
slang::ProgramLayout* interface() const { return (slang::ProgramLayout*)this; }
emscripten::val toJsonObject();
@@ -127,7 +234,7 @@ public:
// Returns UInt8Array or null.
emscripten::val getTargetCodeBlob(int targetIndex);
- slang::wgsl::ProgramLayout* getLayout(unsigned int targetIndex);
+ slang::wgsl::ProgramLayout* getLayout(uint32_t targetIndex);
slang::IComponentType* interface() const { return m_interface; }