Skip to content

Commit

Permalink
format code
Browse files Browse the repository at this point in the history
  • Loading branch information
slangbot committed Nov 5, 2024
1 parent c26ffab commit 4b5eeeb
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 17 deletions.
30 changes: 22 additions & 8 deletions source/slang-wasm/slang-wasm-bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_<slang::wgsl::TypeLayoutReflection>("TypeLayoutReflection")
.function("getDescriptorSetDescriptorRangeType", &slang::wgsl::TypeLayoutReflection::getDescriptorSetDescriptorRangeType);

.function(
"getDescriptorSetDescriptorRangeType",
&slang::wgsl::TypeLayoutReflection::getDescriptorSetDescriptorRangeType);

class_<slang::wgsl::VariableLayoutReflection>("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_<slang::wgsl::ProgramLayout>("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_<slang::BindingType>("BindingType")
.value("Unknown", slang::BindingType::Unknown)
.value("Texture", slang::BindingType::Texture)
Expand Down
4 changes: 3 additions & 1 deletion source/slang-wasm/slang-wasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
6 changes: 4 additions & 2 deletions source/slang-wasm/slang-wasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class TypeLayoutReflection
{
private:
slang::TypeLayoutReflection* m_interface;

public:
TypeLayoutReflection(slang::TypeLayoutReflection* interface)
: m_interface(interface)
Expand All @@ -70,6 +71,7 @@ class VariableLayoutReflection
{
private:
slang::VariableLayoutReflection* m_internal;

public:
VariableLayoutReflection(slang::VariableLayoutReflection* interface)
: m_internal(interface)
Expand All @@ -81,20 +83,20 @@ class VariableLayoutReflection
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);

Expand Down
11 changes: 5 additions & 6 deletions source/slang/slang-emit-wgsl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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("(");
Expand All @@ -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(")");
Expand All @@ -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;

Expand Down

0 comments on commit 4b5eeeb

Please sign in to comment.