summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-type-set.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2020-02-14 15:06:35 -0500
committerGitHub <noreply@github.com>2020-02-14 15:06:35 -0500
commit2c097545eaa324a91a035327abad2e8b4fa60469 (patch)
tree95fd3890f2bfb0184ddbc7f1008de30698651473 /source/slang/slang-ir-type-set.cpp
parentdfd3d263704445b6dcebea54dc47193897548822 (diff)
Feature/cuda coverage (#1223)
* Add cubemap support. * Add CUDA fence instrinsics. * Added Gather for CUDA. * Use the CUDA driver API as much as possible. * * Support 1D texture on CPU * WIP on 1D texture on CUDA * Added simplified texture test * Fix test. * Improve texture-simple tests. Co-authored-by: Tim Foley <tfoleyNV@users.noreply.github.com>
Diffstat (limited to 'source/slang/slang-ir-type-set.cpp')
-rw-r--r--source/slang/slang-ir-type-set.cpp92
1 files changed, 60 insertions, 32 deletions
diff --git a/source/slang/slang-ir-type-set.cpp b/source/slang/slang-ir-type-set.cpp
index a4ebf8242..e5271698c 100644
--- a/source/slang/slang-ir-type-set.cpp
+++ b/source/slang/slang-ir-type-set.cpp
@@ -115,50 +115,74 @@ IRInst* IRTypeSet::cloneInst(IRInst* inst)
clone = m_builder.getStringValue(stringLit->getStringSlice());
break;
}
- default:
+ case kIROp_VectorType:
{
- if (IRBasicType::isaImpl(inst->op))
+ auto vecType = static_cast<IRVectorType*>(inst);
+ const Index elementCount = Index(GetIntVal(vecType->getElementCount()));
+
+ if (elementCount <= 1)
{
- clone = m_builder.getType(inst->op);
+ clone = cloneType(vecType->getElementType());
}
- else
+ break;
+ }
+ case kIROp_MatrixType:
+ {
+ auto matType = static_cast<IRMatrixType*>(inst);
+ const Index columnCount = Index(GetIntVal(matType->getColumnCount()));
+ const Index rowCount = Index(GetIntVal(matType->getRowCount()));
+
+ if (columnCount <= 1 && rowCount <= 1)
{
- IRType* irType = dynamicCast<IRType>(inst);
- if (irType)
- {
- auto clonedType = cloneType(inst->getFullType());
- Index operandCount = Index(inst->getOperandCount());
+ clone = cloneType(matType->getElementType());
+ }
+ break;
+ }
+ default: break;
+ }
+
+ if (!clone)
+ {
+ if (IRBasicType::isaImpl(inst->op))
+ {
+ clone = m_builder.getType(inst->op);
+ }
+ else
+ {
+ IRType* irType = dynamicCast<IRType>(inst);
+ if (irType)
+ {
+ auto clonedType = cloneType(inst->getFullType());
+ Index operandCount = Index(inst->getOperandCount());
- List<IRInst*> cloneOperands;
- cloneOperands.setCount(operandCount);
+ List<IRInst*> cloneOperands;
+ cloneOperands.setCount(operandCount);
- for (Index i = 0; i < operandCount; ++i)
- {
- cloneOperands[i] = cloneInst(inst->getOperand(i));
- }
+ for (Index i = 0; i < operandCount; ++i)
+ {
+ cloneOperands[i] = cloneInst(inst->getOperand(i));
+ }
- //clone = m_irBuilder.findOrEmitHoistableInst(cloneType, inst->op, operandCount, cloneOperands.getBuffer());
+ //clone = m_irBuilder.findOrEmitHoistableInst(cloneType, inst->op, operandCount, cloneOperands.getBuffer());
- UInt operandCounts[1] = { UInt(operandCount) };
- IRInst*const* listOperands[1] = { cloneOperands.getBuffer() };
+ UInt operandCounts[1] = { UInt(operandCount) };
+ IRInst*const* listOperands[1] = { cloneOperands.getBuffer() };
- clone = m_builder.findOrAddInst(clonedType, inst->op, 1, operandCounts, listOperands);
- }
- else
+ clone = m_builder.findOrAddInst(clonedType, inst->op, 1, operandCounts, listOperands);
+ }
+ else
+ {
+ // This cloning style only works on insts that are not unique
+ auto clonedType = cloneType(inst->getFullType());
+
+ Index operandCount = Index(inst->getOperandCount());
+ clone = m_builder.emitIntrinsicInst(clonedType, inst->op, operandCount, nullptr);
+ for (Index i = 0; i < operandCount; ++i)
{
- // This cloning style only works on insts that are not unique
- auto clonedType = cloneType(inst->getFullType());
-
- Index operandCount = Index(inst->getOperandCount());
- clone = m_builder.emitIntrinsicInst(clonedType, inst->op, operandCount, nullptr);
- for (Index i = 0; i < operandCount; ++i)
- {
- auto cloneOperand = cloneInst(inst->getOperand(i));
- clone->getOperands()[i].init(clone, cloneOperand);
- }
+ auto cloneOperand = cloneInst(inst->getOperand(i));
+ clone->getOperands()[i].init(clone, cloneOperand);
}
}
- break;
}
}
@@ -226,6 +250,10 @@ void IRTypeSet::getTypes(Kind kind, List<IRType*>& outTypes) const
IRType* IRTypeSet::addVectorType(IRType* inElementType, int colsCount)
{
IRType* elementType = cloneType(inElementType);
+ if (colsCount == 1)
+ {
+ return elementType;
+ }
return m_builder.getVectorType(elementType, m_builder.getIntValue(m_builder.getIntType(), colsCount));
}