diff options
| author | Yong He <yonghe@outlook.com> | 2023-11-06 14:40:38 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-06 14:40:38 -0800 |
| commit | 46529df2c4f73a4655bdd79d48004f29374a99a8 (patch) | |
| tree | 801e69e70a47ce702c055df68ada41a38158367b /source/slang/slang-emit-spirv.cpp | |
| parent | da9e0adb5cf2b1bed6075a3afe93cfdcceabe904 (diff) | |
Fix ICE when lowering an associatedtype declref from an derived interface. (#3312)
* Fix ICE when lowering an associatedtype declref from an derived interface.
* Fixes.
* Fix test.
* Fix GLSL/SPIRV image subscript swizzle store regression.
* Fix.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-emit-spirv.cpp')
| -rw-r--r-- | source/slang/slang-emit-spirv.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/source/slang/slang-emit-spirv.cpp b/source/slang/slang-emit-spirv.cpp index f26340969..19c46f373 100644 --- a/source/slang/slang-emit-spirv.cpp +++ b/source/slang/slang-emit-spirv.cpp @@ -3827,17 +3827,31 @@ struct SPIRVEmitContext SpvInst* emitSwizzleSet(SpvInstParent* parent, IRSwizzleSet* inst) { + if (inst->getElementCount() == 1) + { + auto index = inst->getElementIndex(0); + if (auto intLit = as<IRIntLit>(index)) + return emitOpCompositeInsert(parent, inst, inst->getFullType(), inst->getSource(), inst->getBase(), makeArray(SpvLiteralInteger::from32((uint32_t)intLit->value.intVal))); + } auto resultVectorType = as<IRVectorType>(inst->getDataType()); List<SpvLiteralInteger> shuffleIndices; shuffleIndices.setCount((Index)getIntVal(resultVectorType->getElementCount())); for (Index i = 0; i < shuffleIndices.getCount(); i++) shuffleIndices[i] = SpvLiteralInteger::from32((int32_t)i); + for (UInt i = 0; i < inst->getElementCount(); i++) { auto destIndex = (int32_t)getIntVal(inst->getElementIndex(i)); SLANG_ASSERT(destIndex < shuffleIndices.getCount()); shuffleIndices[destIndex] = SpvLiteralInteger::from32((int32_t)(i + shuffleIndices.getCount())); } + auto source = inst->getSource(); + if (!as<IRVectorType>(source->getDataType())) + { + IRBuilder builder(inst); + builder.setInsertBefore(inst); + source = builder.emitMakeVectorFromScalar(resultVectorType, source); + } return emitOpVectorShuffle(parent, inst, inst->getFullType(), inst->getBase(), inst->getSource(), shuffleIndices.getArrayView()); } |
