summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-08-28 09:23:08 -0700
committerGitHub <noreply@github.com>2024-08-28 09:23:08 -0700
commit638e5fb000d4e242a91e8b653da4a72daec0efda (patch)
treecfcd15c1fc6bdee624eb33abac3268241b086dec /source/slang/slang-ir.cpp
parent16595a8379e9dbfa1845fd72f3531ff3372da3ef (diff)
Make tuple types work in autodiff. (#4923)
Diffstat (limited to 'source/slang/slang-ir.cpp')
-rw-r--r--source/slang/slang-ir.cpp12
1 files changed, 11 insertions, 1 deletions
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<IRTupleType>(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<IRTupleType>(valueType))
+ {
+ SLANG_ASSERT(as<IRIntLit>(index));
+ type = (IRType*)tupleType->getOperand(getIntVal(index));
+ }
SLANG_RELEASE_ASSERT(type);
auto inst = createInst<IRGetElementPtr>(
this,
@@ -5281,7 +5291,7 @@ namespace Slang
return emitUpdateElement(base, getIntValue(getIntType(), index), newElement);
}
- IRInst* IRBuilder::emitUpdateElement(IRInst* base, const List<IRInst*>& accessChain, IRInst* newElement)
+ IRInst* IRBuilder::emitUpdateElement(IRInst* base, ArrayView<IRInst*> accessChain, IRInst* newElement)
{
List<IRInst*> args;
args.add(base);