Commit 74d3f371 by Alexis Hetu Committed by Alexis Hétu

Array length fix

When available, the decorations for the array member of the structure used in EmitArrayLength should be used to find the array stride and use it in the length computation. This cl should fix these tests with SwANGLE: dEQP-GLES31.functional.compute.basic.write_multiple_unsized_arr_* Bug: b/148459131 Change-Id: I5722ebc761b81faf75bb9bab7c60f240afa50446 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/41271 Presubmit-Ready: Alexis Hétu <sugoi@google.com> Reviewed-by: 's avatarChris Forbes <chrisforbes@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarAlexis Hétu <sugoi@google.com>
parent 8def9063
......@@ -2327,20 +2327,22 @@ SpirvShader::EmitResult SpirvShader::EmitArrayLength(InsnIterator insn, EmitStat
auto &structPtrTy = getType(getObject(structPtrId).type);
auto &structTy = getType(structPtrTy.element);
auto &arrayTy = getType(structTy.definition.word(2 + arrayFieldIdx));
ASSERT(arrayTy.definition.opcode() == spv::OpTypeRuntimeArray);
auto &arrayElTy = getType(arrayTy.element);
auto arrayId = Type::ID(structTy.definition.word(2 + arrayFieldIdx));
auto &result = state->createIntermediate(resultId, 1);
auto structBase = GetPointerToData(structPtrId, 0, state);
Decorations d = {};
ApplyDecorationsForIdMember(&d, structPtrTy.element, arrayFieldIdx);
ASSERT(d.HasOffset);
Decorations structDecorations = {};
ApplyDecorationsForIdMember(&structDecorations, structPtrTy.element, arrayFieldIdx);
ASSERT(structDecorations.HasOffset);
auto arrayBase = structBase + d.Offset;
auto arrayBase = structBase + structDecorations.Offset;
auto arraySizeInBytes = SIMD::Int(arrayBase.limit()) - arrayBase.offsets();
auto arrayLength = arraySizeInBytes / SIMD::Int(arrayElTy.sizeInComponents * sizeof(float));
Decorations arrayDecorations = {};
ApplyDecorationsForId(&arrayDecorations, arrayId);
ASSERT(arrayDecorations.HasArrayStride);
auto arrayLength = arraySizeInBytes / SIMD::Int(arrayDecorations.ArrayStride);
result.move(0, SIMD::Int(arrayLength));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment