From ba55036643e06330f2ae98b71d592672b2ebfa82 Mon Sep 17 00:00:00 2001 From: Sai Praveen Bangaru Date: Mon, 4 Nov 2024 17:39:17 -0500 Subject: [PATCH 1/5] Add key reflection endpoints for WASM --- source/slang-wasm/slang-wasm-bindings.cpp | 22 +++++++++ source/slang-wasm/slang-wasm.cpp | 41 +++++++++++++++++ source/slang-wasm/slang-wasm.h | 55 +++++++++++++++++++++++ 3 files changed, 118 insertions(+) diff --git a/source/slang-wasm/slang-wasm-bindings.cpp b/source/slang-wasm/slang-wasm-bindings.cpp index 326ef9ff20..079333e8e1 100644 --- a/source/slang-wasm/slang-wasm-bindings.cpp +++ b/source/slang-wasm/slang-wasm-bindings.cpp @@ -43,11 +43,33 @@ EMSCRIPTEN_BINDINGS(slang) .function("getEntryPointCodeBlob", &slang::wgsl::ComponentType::getEntryPointCodeBlob) .function("getTargetCodeBlob", &slang::wgsl::ComponentType::getTargetCodeBlob) .function("getTargetCode", &slang::wgsl::ComponentType::getTargetCode) + .function("getLayout", &slang::wgsl::ComponentType::getLayout, return_value_policy::take_ownership()) .function( "loadStrings", &slang::wgsl::ComponentType::loadStrings, return_value_policy::take_ownership()); + class_("TypeLayoutReflection") + .function("getDescriptorSetDescriptorRangeType", &slang::wgsl::TypeLayoutReflection::getDescriptorSetDescriptorRangeType); + + class_("VariableLayoutReflection") + .function("getName", &slang::wgsl::VariableLayoutReflection::getName) + .function("getTypeLayout", &slang::wgsl::VariableLayoutReflection::getTypeLayout, return_value_policy::take_ownership()) + .function("getBindingIndex", &slang::wgsl::VariableLayoutReflection::getBindingIndex); + + class_("ProgramLayout") + .function("getParameterCount", &slang::wgsl::ProgramLayout::getParameterCount) + .function("getParameterByIndex", &slang::wgsl::ProgramLayout::getParameterByIndex, return_value_policy::take_ownership()) + .function("getGlobalParamsTypeLayout", &slang::wgsl::ProgramLayout::getGlobalParamsTypeLayout, return_value_policy::take_ownership()); + + enum_("BindingType") + .value("Unknown", slang::BindingType::Unknown) + .value("Texture", slang::BindingType::Texture) + .value("ConstantBuffer", slang::BindingType::ConstantBuffer) + .value("MutableRawBuffer", slang::BindingType::MutableRawBuffer) + .value("MutableTypedBuffer", slang::BindingType::MutableTypedBuffer) + .value("MutableTexture", slang::BindingType::MutableTexture); + class_>("Module") .function( "findEntryPointByName", diff --git a/source/slang-wasm/slang-wasm.cpp b/source/slang-wasm/slang-wasm.cpp index be30f8394a..9d28f76555 100644 --- a/source/slang-wasm/slang-wasm.cpp +++ b/source/slang-wasm/slang-wasm.cpp @@ -386,6 +386,47 @@ HashedString* ComponentType::loadStrings() return hashedStrings; } +ProgramLayout* ComponentType::getLayout(unsigned int targetIndex) +{ + return new ProgramLayout(interface()->getLayout(targetIndex)); +} + +unsigned int ProgramLayout::getParameterCount() +{ + return m_internal->getParameterCount(); +} + +VariableLayoutReflection* ProgramLayout::getParameterByIndex(unsigned int index) +{ + return new VariableLayoutReflection(m_internal->getParameterByIndex(index)); +} + +TypeLayoutReflection* ProgramLayout::getGlobalParamsTypeLayout() +{ + return new TypeLayoutReflection(m_internal->getGlobalParamsTypeLayout()); +} + +BindingType TypeLayoutReflection::getDescriptorSetDescriptorRangeType(unsigned int setIndex, unsigned int rangeIndex) +{ + return m_interface->getDescriptorSetDescriptorRangeType(setIndex, rangeIndex); +} + +std::string VariableLayoutReflection::getName() +{ + return m_internal->getName(); +} + +TypeLayoutReflection* VariableLayoutReflection::getTypeLayout() +{ + return new TypeLayoutReflection(m_internal->getTypeLayout()); +} + +unsigned int VariableLayoutReflection::getBindingIndex() +{ + return m_internal->getBindingIndex(); +} + + namespace lsp { Position translate(Slang::LanguageServerProtocol::Position p) diff --git a/source/slang-wasm/slang-wasm.h b/source/slang-wasm/slang-wasm.h index c829766596..f8df62123f 100644 --- a/source/slang-wasm/slang-wasm.h +++ b/source/slang-wasm/slang-wasm.h @@ -50,6 +50,59 @@ class HashedString CompileTargets* getCompileTargets(); + +class TypeLayoutReflection +{ +private: + slang::TypeLayoutReflection* m_interface; +public: + TypeLayoutReflection(slang::TypeLayoutReflection* interface) + : m_interface(interface) + { + } + + BindingType getDescriptorSetDescriptorRangeType(unsigned int setIndex, unsigned int rangeIndex); + + slang::TypeLayoutReflection* interface() const { return m_interface; } +}; + +class VariableLayoutReflection +{ +private: + slang::VariableLayoutReflection* m_internal; +public: + VariableLayoutReflection(slang::VariableLayoutReflection* interface) + : m_internal(interface) + { + } + + std::string getName(); + slang::wgsl::TypeLayoutReflection* getTypeLayout(); + unsigned int getBindingIndex(); + + slang::VariableLayoutReflection* interface() const { return m_internal; } + +}; + + +class ProgramLayout +{ +private: + slang::ProgramLayout* m_internal; +public: + ProgramLayout(slang::ProgramLayout* interface) + : m_internal(interface) + { + } + + unsigned int getParameterCount(); + slang::wgsl::VariableLayoutReflection* getParameterByIndex(unsigned int index); + + slang::wgsl::TypeLayoutReflection* getGlobalParamsTypeLayout(); + + slang::ProgramLayout* interface() const { return m_internal; } +}; + class ComponentType { public: @@ -65,6 +118,8 @@ class ComponentType std::string getTargetCode(int targetIndex); emscripten::val getTargetCodeBlob(int targetIndex); + slang::wgsl::ProgramLayout* getLayout(unsigned int targetIndex); + slang::IComponentType* interface() const { return m_interface; } HashedString* loadStrings(); From e4c0f44892e1a4dd6aead58384f013a8c8da009c Mon Sep 17 00:00:00 2001 From: Sai Praveen Bangaru Date: Tue, 5 Nov 2024 17:27:23 -0500 Subject: [PATCH 2/5] Fix WGSL output around bit-manipulation operators --- source/slang/slang-emit-c-like.cpp | 7 ++++ source/slang/slang-emit-wgsl.cpp | 67 +++++++++++++++++++++++------- 2 files changed, 59 insertions(+), 15 deletions(-) diff --git a/source/slang/slang-emit-c-like.cpp b/source/slang/slang-emit-c-like.cpp index 8b0794ef27..5d41b75b2a 100644 --- a/source/slang/slang-emit-c-like.cpp +++ b/source/slang/slang-emit-c-like.cpp @@ -668,6 +668,13 @@ bool CLikeSourceEmitter::maybeEmitParens(EmitOpInfo& outerPrec, const EmitOpInfo { needParens = true; } + // a ^ b * c => (a ^ b) * c + else if ( + prec.rightPrecedence == EPrecedence::kEPrecedence_BitXor_Right && + outerPrec.rightPrecedence == EPrecedence::kEPrecedence_Multiplicative_Left) + { + needParens = true; + } if (needParens) { diff --git a/source/slang/slang-emit-wgsl.cpp b/source/slang/slang-emit-wgsl.cpp index 4aca03a61b..4c0aac0553 100644 --- a/source/slang/slang-emit-wgsl.cpp +++ b/source/slang/slang-emit-wgsl.cpp @@ -1076,28 +1076,65 @@ bool WGSLSourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inOu // https://www.w3.org/TR/WGSL/#bit-expr IRInst* const shiftAmount = inst->getOperand(1); IRType* const shiftAmountType = shiftAmount->getDataType(); - if (shiftAmountType->getOp() == kIROp_IntType) - { - // Dawn complains about "mixing '<<' and '|' requires parenthesis", so let's - // add parenthesis. - m_writer->emit("("); + + // Dawn complains about mixing '<<' and '|', '^' and a bunch of other bit operators without + // a paranthesis, so we'll always emit paranthesis around the shift amount. + // - const auto emitOp = getEmitOpForOp(inst->getOp()); - const auto info = getInfo(emitOp); + m_writer->emit("("); + + const auto emitOp = getEmitOpForOp(inst->getOp()); + const auto info = getInfo(emitOp); - const bool needClose = maybeEmitParens(outerPrec, info); - emitOperand(inst->getOperand(0), leftSide(outerPrec, info)); - m_writer->emit(" "); - m_writer->emit(info.op); - m_writer->emit(" "); + const bool needClose = maybeEmitParens(outerPrec, info); + emitOperand(inst->getOperand(0), leftSide(outerPrec, info)); + m_writer->emit(" "); + m_writer->emit(info.op); + m_writer->emit(" "); + + if (shiftAmountType->getOp() == kIROp_IntType) + { m_writer->emit("bitcast("); emitOperand(inst->getOperand(1), rightSide(outerPrec, info)); m_writer->emit(")"); - maybeCloseParens(needClose); - + } + else + { + m_writer->emit("("); + emitOperand(inst->getOperand(1), rightSide(outerPrec, info)); m_writer->emit(")"); - return true; } + + maybeCloseParens(needClose); + + m_writer->emit(")"); + + return true; + } + case kIROp_BitXor: + case kIROp_BitOr: + { + // Emit bitwise operators with paranthesis to avoid precedence issues + const auto emitOp = getEmitOpForOp(inst->getOp()); + const auto info = getInfo(emitOp); + + m_writer->emit("("); + + const bool needClose = maybeEmitParens(outerPrec, info); + emitOperand(inst->getOperand(0), leftSide(outerPrec, info)); + m_writer->emit(" "); + + m_writer->emit(info.op); + + m_writer->emit(" ("); + emitOperand(inst->getOperand(1), rightSide(outerPrec, info)); + m_writer->emit(")"); + + maybeCloseParens(needClose); + + m_writer->emit(")"); + return true; + } break; From 4b5eeebf11f46a9b68daed99df5a4fccda9b53fe Mon Sep 17 00:00:00 2001 From: slangbot <186143334+slangbot@users.noreply.github.com> Date: Tue, 5 Nov 2024 23:02:27 +0000 Subject: [PATCH 3/5] format code --- source/slang-wasm/slang-wasm-bindings.cpp | 30 +++++++++++++++++------ source/slang-wasm/slang-wasm.cpp | 4 ++- source/slang-wasm/slang-wasm.h | 6 +++-- source/slang/slang-emit-wgsl.cpp | 11 ++++----- 4 files changed, 34 insertions(+), 17 deletions(-) diff --git a/source/slang-wasm/slang-wasm-bindings.cpp b/source/slang-wasm/slang-wasm-bindings.cpp index 079333e8e1..c3f174850c 100644 --- a/source/slang-wasm/slang-wasm-bindings.cpp +++ b/source/slang-wasm/slang-wasm-bindings.cpp @@ -43,25 +43,39 @@ EMSCRIPTEN_BINDINGS(slang) .function("getEntryPointCodeBlob", &slang::wgsl::ComponentType::getEntryPointCodeBlob) .function("getTargetCodeBlob", &slang::wgsl::ComponentType::getTargetCodeBlob) .function("getTargetCode", &slang::wgsl::ComponentType::getTargetCode) - .function("getLayout", &slang::wgsl::ComponentType::getLayout, return_value_policy::take_ownership()) + .function( + "getLayout", + &slang::wgsl::ComponentType::getLayout, + return_value_policy::take_ownership()) .function( "loadStrings", &slang::wgsl::ComponentType::loadStrings, return_value_policy::take_ownership()); class_("TypeLayoutReflection") - .function("getDescriptorSetDescriptorRangeType", &slang::wgsl::TypeLayoutReflection::getDescriptorSetDescriptorRangeType); - + .function( + "getDescriptorSetDescriptorRangeType", + &slang::wgsl::TypeLayoutReflection::getDescriptorSetDescriptorRangeType); + class_("VariableLayoutReflection") .function("getName", &slang::wgsl::VariableLayoutReflection::getName) - .function("getTypeLayout", &slang::wgsl::VariableLayoutReflection::getTypeLayout, return_value_policy::take_ownership()) + .function( + "getTypeLayout", + &slang::wgsl::VariableLayoutReflection::getTypeLayout, + return_value_policy::take_ownership()) .function("getBindingIndex", &slang::wgsl::VariableLayoutReflection::getBindingIndex); - + class_("ProgramLayout") .function("getParameterCount", &slang::wgsl::ProgramLayout::getParameterCount) - .function("getParameterByIndex", &slang::wgsl::ProgramLayout::getParameterByIndex, return_value_policy::take_ownership()) - .function("getGlobalParamsTypeLayout", &slang::wgsl::ProgramLayout::getGlobalParamsTypeLayout, return_value_policy::take_ownership()); - + .function( + "getParameterByIndex", + &slang::wgsl::ProgramLayout::getParameterByIndex, + return_value_policy::take_ownership()) + .function( + "getGlobalParamsTypeLayout", + &slang::wgsl::ProgramLayout::getGlobalParamsTypeLayout, + return_value_policy::take_ownership()); + enum_("BindingType") .value("Unknown", slang::BindingType::Unknown) .value("Texture", slang::BindingType::Texture) diff --git a/source/slang-wasm/slang-wasm.cpp b/source/slang-wasm/slang-wasm.cpp index 9d28f76555..5d01b28e25 100644 --- a/source/slang-wasm/slang-wasm.cpp +++ b/source/slang-wasm/slang-wasm.cpp @@ -406,7 +406,9 @@ TypeLayoutReflection* ProgramLayout::getGlobalParamsTypeLayout() return new TypeLayoutReflection(m_internal->getGlobalParamsTypeLayout()); } -BindingType TypeLayoutReflection::getDescriptorSetDescriptorRangeType(unsigned int setIndex, unsigned int rangeIndex) +BindingType TypeLayoutReflection::getDescriptorSetDescriptorRangeType( + unsigned int setIndex, + unsigned int rangeIndex) { return m_interface->getDescriptorSetDescriptorRangeType(setIndex, rangeIndex); } diff --git a/source/slang-wasm/slang-wasm.h b/source/slang-wasm/slang-wasm.h index f8df62123f..96336f6647 100644 --- a/source/slang-wasm/slang-wasm.h +++ b/source/slang-wasm/slang-wasm.h @@ -55,6 +55,7 @@ class TypeLayoutReflection { private: slang::TypeLayoutReflection* m_interface; + public: TypeLayoutReflection(slang::TypeLayoutReflection* interface) : m_interface(interface) @@ -70,6 +71,7 @@ class VariableLayoutReflection { private: slang::VariableLayoutReflection* m_internal; + public: VariableLayoutReflection(slang::VariableLayoutReflection* interface) : m_internal(interface) @@ -81,7 +83,6 @@ class VariableLayoutReflection unsigned int getBindingIndex(); slang::VariableLayoutReflection* interface() const { return m_internal; } - }; @@ -89,12 +90,13 @@ class ProgramLayout { private: slang::ProgramLayout* m_internal; + public: ProgramLayout(slang::ProgramLayout* interface) : m_internal(interface) { } - + unsigned int getParameterCount(); slang::wgsl::VariableLayoutReflection* getParameterByIndex(unsigned int index); diff --git a/source/slang/slang-emit-wgsl.cpp b/source/slang/slang-emit-wgsl.cpp index 7ccb46fa06..9ad70054b0 100644 --- a/source/slang/slang-emit-wgsl.cpp +++ b/source/slang/slang-emit-wgsl.cpp @@ -1255,9 +1255,9 @@ bool WGSLSourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inOu // https://www.w3.org/TR/WGSL/#bit-expr IRInst* const shiftAmount = inst->getOperand(1); IRType* const shiftAmountType = shiftAmount->getDataType(); - - // Dawn complains about mixing '<<' and '|', '^' and a bunch of other bit operators without - // a paranthesis, so we'll always emit paranthesis around the shift amount. + + // Dawn complains about mixing '<<' and '|', '^' and a bunch of other bit operators + // without a paranthesis, so we'll always emit paranthesis around the shift amount. // m_writer->emit("("); @@ -1283,7 +1283,7 @@ bool WGSLSourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inOu emitOperand(inst->getOperand(1), rightSide(outerPrec, info)); m_writer->emit(")"); } - + maybeCloseParens(needClose); m_writer->emit(")"); @@ -1308,12 +1308,11 @@ bool WGSLSourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inOu m_writer->emit(" ("); emitOperand(inst->getOperand(1), rightSide(outerPrec, info)); m_writer->emit(")"); - + maybeCloseParens(needClose); m_writer->emit(")"); return true; - } break; From a882575b88655c2bf21fdaa692a1e383bea15a06 Mon Sep 17 00:00:00 2001 From: Sai Praveen Bangaru Date: Thu, 7 Nov 2024 19:44:13 -0500 Subject: [PATCH 4/5] Fix pointer ownership --- source/slang-wasm/slang-wasm-bindings.cpp | 8 +++---- source/slang-wasm/slang-wasm.cpp | 16 ++++++------- source/slang-wasm/slang-wasm.h | 28 +++-------------------- 3 files changed, 15 insertions(+), 37 deletions(-) diff --git a/source/slang-wasm/slang-wasm-bindings.cpp b/source/slang-wasm/slang-wasm-bindings.cpp index c3f174850c..df765f5563 100644 --- a/source/slang-wasm/slang-wasm-bindings.cpp +++ b/source/slang-wasm/slang-wasm-bindings.cpp @@ -46,7 +46,7 @@ EMSCRIPTEN_BINDINGS(slang) .function( "getLayout", &slang::wgsl::ComponentType::getLayout, - return_value_policy::take_ownership()) + allow_raw_pointers()) .function( "loadStrings", &slang::wgsl::ComponentType::loadStrings, @@ -62,7 +62,7 @@ EMSCRIPTEN_BINDINGS(slang) .function( "getTypeLayout", &slang::wgsl::VariableLayoutReflection::getTypeLayout, - return_value_policy::take_ownership()) + allow_raw_pointers()) .function("getBindingIndex", &slang::wgsl::VariableLayoutReflection::getBindingIndex); class_("ProgramLayout") @@ -70,11 +70,11 @@ EMSCRIPTEN_BINDINGS(slang) .function( "getParameterByIndex", &slang::wgsl::ProgramLayout::getParameterByIndex, - return_value_policy::take_ownership()) + allow_raw_pointers()) .function( "getGlobalParamsTypeLayout", &slang::wgsl::ProgramLayout::getGlobalParamsTypeLayout, - return_value_policy::take_ownership()); + allow_raw_pointers()); enum_("BindingType") .value("Unknown", slang::BindingType::Unknown) diff --git a/source/slang-wasm/slang-wasm.cpp b/source/slang-wasm/slang-wasm.cpp index 5d01b28e25..79eb3e446c 100644 --- a/source/slang-wasm/slang-wasm.cpp +++ b/source/slang-wasm/slang-wasm.cpp @@ -388,44 +388,44 @@ HashedString* ComponentType::loadStrings() ProgramLayout* ComponentType::getLayout(unsigned int targetIndex) { - return new ProgramLayout(interface()->getLayout(targetIndex)); + return (slang::wgsl::ProgramLayout*) interface()->getLayout(targetIndex); } unsigned int ProgramLayout::getParameterCount() { - return m_internal->getParameterCount(); + return interface()->getParameterCount(); } VariableLayoutReflection* ProgramLayout::getParameterByIndex(unsigned int index) { - return new VariableLayoutReflection(m_internal->getParameterByIndex(index)); + return (slang::wgsl::VariableLayoutReflection*) (interface()->getParameterByIndex(index)); } TypeLayoutReflection* ProgramLayout::getGlobalParamsTypeLayout() { - return new TypeLayoutReflection(m_internal->getGlobalParamsTypeLayout()); + return (slang::wgsl::TypeLayoutReflection*) (interface()->getGlobalParamsTypeLayout()); } BindingType TypeLayoutReflection::getDescriptorSetDescriptorRangeType( unsigned int setIndex, unsigned int rangeIndex) { - return m_interface->getDescriptorSetDescriptorRangeType(setIndex, rangeIndex); + return interface()->getDescriptorSetDescriptorRangeType(setIndex, rangeIndex); } std::string VariableLayoutReflection::getName() { - return m_internal->getName(); + return interface()->getName(); } TypeLayoutReflection* VariableLayoutReflection::getTypeLayout() { - return new TypeLayoutReflection(m_internal->getTypeLayout()); + return (slang::wgsl::TypeLayoutReflection*) (interface()->getTypeLayout()); } unsigned int VariableLayoutReflection::getBindingIndex() { - return m_internal->getBindingIndex(); + return interface()->getBindingIndex(); } diff --git a/source/slang-wasm/slang-wasm.h b/source/slang-wasm/slang-wasm.h index 96336f6647..ab206913d9 100644 --- a/source/slang-wasm/slang-wasm.h +++ b/source/slang-wasm/slang-wasm.h @@ -53,56 +53,34 @@ CompileTargets* getCompileTargets(); class TypeLayoutReflection { -private: - slang::TypeLayoutReflection* m_interface; - public: - TypeLayoutReflection(slang::TypeLayoutReflection* interface) - : m_interface(interface) - { - } - BindingType getDescriptorSetDescriptorRangeType(unsigned int setIndex, unsigned int rangeIndex); - slang::TypeLayoutReflection* interface() const { return m_interface; } + slang::TypeLayoutReflection* interface() const { return (slang::TypeLayoutReflection*)this; } }; class VariableLayoutReflection { -private: - slang::VariableLayoutReflection* m_internal; - public: - VariableLayoutReflection(slang::VariableLayoutReflection* interface) - : m_internal(interface) - { - } std::string getName(); slang::wgsl::TypeLayoutReflection* getTypeLayout(); unsigned int getBindingIndex(); - slang::VariableLayoutReflection* interface() const { return m_internal; } + slang::VariableLayoutReflection* interface() const { return (slang::VariableLayoutReflection*)this; } }; class ProgramLayout { -private: - slang::ProgramLayout* m_internal; - public: - ProgramLayout(slang::ProgramLayout* interface) - : m_internal(interface) - { - } unsigned int getParameterCount(); slang::wgsl::VariableLayoutReflection* getParameterByIndex(unsigned int index); slang::wgsl::TypeLayoutReflection* getGlobalParamsTypeLayout(); - slang::ProgramLayout* interface() const { return m_internal; } + slang::ProgramLayout* interface() const { return (slang::ProgramLayout*)this; } }; class ComponentType From c579188a701500d151479b5b9a3ae1f3487607c5 Mon Sep 17 00:00:00 2001 From: Sai Praveen Bangaru Date: Fri, 8 Nov 2024 12:38:46 -0500 Subject: [PATCH 5/5] fix formatting --- source/slang-wasm/slang-wasm-bindings.cpp | 5 +---- source/slang-wasm/slang-wasm.cpp | 8 ++++---- source/slang-wasm/slang-wasm.h | 7 ++++--- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/source/slang-wasm/slang-wasm-bindings.cpp b/source/slang-wasm/slang-wasm-bindings.cpp index df765f5563..e980cd6082 100644 --- a/source/slang-wasm/slang-wasm-bindings.cpp +++ b/source/slang-wasm/slang-wasm-bindings.cpp @@ -43,10 +43,7 @@ EMSCRIPTEN_BINDINGS(slang) .function("getEntryPointCodeBlob", &slang::wgsl::ComponentType::getEntryPointCodeBlob) .function("getTargetCodeBlob", &slang::wgsl::ComponentType::getTargetCodeBlob) .function("getTargetCode", &slang::wgsl::ComponentType::getTargetCode) - .function( - "getLayout", - &slang::wgsl::ComponentType::getLayout, - allow_raw_pointers()) + .function("getLayout", &slang::wgsl::ComponentType::getLayout, allow_raw_pointers()) .function( "loadStrings", &slang::wgsl::ComponentType::loadStrings, diff --git a/source/slang-wasm/slang-wasm.cpp b/source/slang-wasm/slang-wasm.cpp index 79eb3e446c..f73e70ba0f 100644 --- a/source/slang-wasm/slang-wasm.cpp +++ b/source/slang-wasm/slang-wasm.cpp @@ -388,7 +388,7 @@ HashedString* ComponentType::loadStrings() ProgramLayout* ComponentType::getLayout(unsigned int targetIndex) { - return (slang::wgsl::ProgramLayout*) interface()->getLayout(targetIndex); + return (slang::wgsl::ProgramLayout*)interface()->getLayout(targetIndex); } unsigned int ProgramLayout::getParameterCount() @@ -398,12 +398,12 @@ unsigned int ProgramLayout::getParameterCount() VariableLayoutReflection* ProgramLayout::getParameterByIndex(unsigned int index) { - return (slang::wgsl::VariableLayoutReflection*) (interface()->getParameterByIndex(index)); + return (slang::wgsl::VariableLayoutReflection*)(interface()->getParameterByIndex(index)); } TypeLayoutReflection* ProgramLayout::getGlobalParamsTypeLayout() { - return (slang::wgsl::TypeLayoutReflection*) (interface()->getGlobalParamsTypeLayout()); + return (slang::wgsl::TypeLayoutReflection*)(interface()->getGlobalParamsTypeLayout()); } BindingType TypeLayoutReflection::getDescriptorSetDescriptorRangeType( @@ -420,7 +420,7 @@ std::string VariableLayoutReflection::getName() TypeLayoutReflection* VariableLayoutReflection::getTypeLayout() { - return (slang::wgsl::TypeLayoutReflection*) (interface()->getTypeLayout()); + return (slang::wgsl::TypeLayoutReflection*)(interface()->getTypeLayout()); } unsigned int VariableLayoutReflection::getBindingIndex() diff --git a/source/slang-wasm/slang-wasm.h b/source/slang-wasm/slang-wasm.h index ab206913d9..9e1e023a91 100644 --- a/source/slang-wasm/slang-wasm.h +++ b/source/slang-wasm/slang-wasm.h @@ -62,19 +62,20 @@ class TypeLayoutReflection class VariableLayoutReflection { public: - std::string getName(); slang::wgsl::TypeLayoutReflection* getTypeLayout(); unsigned int getBindingIndex(); - slang::VariableLayoutReflection* interface() const { return (slang::VariableLayoutReflection*)this; } + slang::VariableLayoutReflection* interface() const + { + return (slang::VariableLayoutReflection*)this; + } }; class ProgramLayout { public: - unsigned int getParameterCount(); slang::wgsl::VariableLayoutReflection* getParameterByIndex(unsigned int index);