From 638e5fb000d4e242a91e8b653da4a72daec0efda Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 28 Aug 2024 09:23:08 -0700 Subject: Make tuple types work in autodiff. (#4923) --- source/slang/slang-ir.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'source/slang/slang-ir.cpp') diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp index 0b0a42617..6a76ccce3 100644 --- a/source/slang/slang-ir.cpp +++ b/source/slang/slang-ir.cpp @@ -5108,6 +5108,11 @@ namespace Slang { type = getVectorType(matrixType->getElementType(), matrixType->getColumnCount()); } + else if (auto tupleType = as(base->getDataType())) + { + type = (IRType*)tupleType->getOperand(getIntVal(index)); + return emitGetTupleElement(type, base, index); + } SLANG_RELEASE_ASSERT(type); return emitElementExtract(type, base, index); @@ -5211,6 +5216,11 @@ namespace Slang // HLSL support things like float.x, in which case we just return the base pointer. return basePtr; } + else if (const auto tupleType = as(valueType)) + { + SLANG_ASSERT(as(index)); + type = (IRType*)tupleType->getOperand(getIntVal(index)); + } SLANG_RELEASE_ASSERT(type); auto inst = createInst( this, @@ -5281,7 +5291,7 @@ namespace Slang return emitUpdateElement(base, getIntValue(getIntType(), index), newElement); } - IRInst* IRBuilder::emitUpdateElement(IRInst* base, const List& accessChain, IRInst* newElement) + IRInst* IRBuilder::emitUpdateElement(IRInst* base, ArrayView accessChain, IRInst* newElement) { List args; args.add(base); -- cgit v1.2.3