From 4e2f2771eb2f8991014d957848a6a25aa49c0aaf Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 4 Jun 2020 12:42:17 -0700 Subject: Emit [loop] attribute to output HLSL. --- source/slang/slang-emit-hlsl.cpp | 9 ++++++++- source/slang/slang-ir-insts.h | 1 + source/slang/slang-lower-to-ir.cpp | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/slang/slang-emit-hlsl.cpp b/source/slang/slang-emit-hlsl.cpp index 5ebd7e9fc..b15680f29 100644 --- a/source/slang/slang-emit-hlsl.cpp +++ b/source/slang/slang-emit-hlsl.cpp @@ -673,9 +673,16 @@ void HLSLSourceEmitter::emitVectorTypeNameImpl(IRType* elementType, IRIntegerVal void HLSLSourceEmitter::emitLoopControlDecorationImpl(IRLoopControlDecoration* decl) { - if (decl->getMode() == kIRLoopControl_Unroll) + switch (decl->getMode()) { + case kIRLoopControl_Unroll: m_writer->emit("[unroll]\n"); + break; + case kIRLoopControl_Loop: + m_writer->emit("[loop]\n"); + break; + default: + SLANG_UNREACHABLE("emit loop control decoration"); } } diff --git a/source/slang/slang-ir-insts.h b/source/slang/slang-ir-insts.h index 06a5c1412..0ae05311b 100644 --- a/source/slang/slang-ir-insts.h +++ b/source/slang/slang-ir-insts.h @@ -42,6 +42,7 @@ struct IRHighLevelDeclDecoration : IRDecoration enum IRLoopControl { kIRLoopControl_Unroll, + kIRLoopControl_Loop, }; struct IRLoopControlDecoration : IRDecoration diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp index f369729d2..030c5fc74 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -3281,6 +3281,10 @@ struct StmtLoweringVisitor : StmtVisitor { getBuilder()->addLoopControlDecoration(inst, kIRLoopControl_Unroll); } + else if( stmt->findModifier() ) + { + getBuilder()->addLoopControlDecoration(inst, kIRLoopControl_Loop); + } // TODO: handle other cases here } -- cgit v1.2.3