Adjust input attachment index when indexing into array of input descriptors Bug: b/131171141 Test: dEQP-VK.renderpass* Change-Id: I22a443edeee705b24ccc3a838fbab5f333f5dd87 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/29730 Reviewed-by: Nicolas Capens <nicolascapens@google.com> Reviewed-by: Ben Clayton <bclayton@google.com> Tested-by: Chris Forbes <chrisforbes@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
diff --git a/src/Pipeline/SpirvShader.cpp b/src/Pipeline/SpirvShader.cpp index 77f3d7d..670b7a0 100644 --- a/src/Pipeline/SpirvShader.cpp +++ b/src/Pipeline/SpirvShader.cpp
@@ -714,7 +714,7 @@ if (opcode == spv::OpAccessChain || opcode == spv::OpInBoundsAccessChain) { Decorations dd{}; - ApplyDecorationsForAccessChain(&dd, pointerId, insn.wordCount() - 4, insn.wordPointer(4)); + ApplyDecorationsForAccessChain(&dd, &descriptorDecorations[resultId], pointerId, insn.wordCount() - 4, insn.wordPointer(4)); // Note: offset is the one thing that does *not* propagate, as the access chain accounts for it. dd.HasOffset = false; decorations[resultId].Apply(dd); @@ -1343,7 +1343,7 @@ } } - void SpirvShader::ApplyDecorationsForAccessChain(Decorations *d, Object::ID baseId, uint32_t numIndexes, uint32_t const *indexIds) const + void SpirvShader::ApplyDecorationsForAccessChain(Decorations *d, DescriptorDecorations *dd, Object::ID baseId, uint32_t numIndexes, uint32_t const *indexIds) const { ApplyDecorationsForId(d, baseId); auto &baseObject = getObject(baseId); @@ -1365,6 +1365,12 @@ } case spv::OpTypeArray: case spv::OpTypeRuntimeArray: + if (dd->InputAttachmentIndex >= 0) + { + dd->InputAttachmentIndex += GetConstantInt(indexIds[i]); + } + typeId = type.element; + break; case spv::OpTypeVector: typeId = type.element; break;
diff --git a/src/Pipeline/SpirvShader.hpp b/src/Pipeline/SpirvShader.hpp index 995a47a..d40bd27 100644 --- a/src/Pipeline/SpirvShader.hpp +++ b/src/Pipeline/SpirvShader.hpp
@@ -656,7 +656,7 @@ uint32_t ComputeTypeSize(InsnIterator insn); void ApplyDecorationsForId(Decorations *d, TypeOrObjectID id) const; void ApplyDecorationsForIdMember(Decorations *d, Type::ID id, uint32_t member) const; - void ApplyDecorationsForAccessChain(Decorations *d, Object::ID baseId, uint32_t numIndexes, uint32_t const *indexIds) const; + void ApplyDecorationsForAccessChain(Decorations *d, DescriptorDecorations *dd, Object::ID baseId, uint32_t numIndexes, uint32_t const *indexIds) const; // Creates an Object for the instruction's result in 'defs'. void DefineResult(const InsnIterator &insn);