Commit 58bee563 by Chris Forbes

Fix WalkAccessChain to actually walk type tree properly

This was completely broken -- we weren't walking down the type tree at all. Bug: b/124388146 Change-Id: I359d121403c3413e74427fadf57fd4c3d52f7661 Reviewed-on: https://swiftshader-review.googlesource.com/c/25088Tested-by: 's avatarChris Forbes <chrisforbes@google.com> Reviewed-by: 's avatarBen Clayton <bclayton@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent 64be7c76
......@@ -511,9 +511,11 @@ namespace sw
int memberIndex = GetConstantInt(indexIds[i]);
int offsetIntoStruct = 0;
for (auto j = 0; j < memberIndex; j++) {
offsetIntoStruct += getType(type.definition.word(2 + memberIndex)).sizeInComponents;
auto memberType = type.definition.word(2u + j);
offsetIntoStruct += getType(memberType).sizeInComponents;
}
constantOffset += offsetIntoStruct;
typeId = type.definition.word(2u + memberIndex);
break;
}
......@@ -521,15 +523,21 @@ namespace sw
case spv::OpTypeMatrix:
case spv::OpTypeArray:
{
auto stride = getType(type.definition.word(2)).sizeInComponents;
auto elementType = type.definition.word(2);
auto stride = getType(elementType).sizeInComponents;
auto & obj = getObject(indexIds[i]);
if (obj.kind == Object::Kind::Constant)
constantOffset += stride * GetConstantInt(indexIds[i]);
else
dynamicOffset += Int4(stride) * As<Int4>(routine->getIntermediate(indexIds[i])[0]);
typeId = elementType;
break;
}
case spv::OpTypePointer:
typeId = type.definition.word(3);
break;
default:
UNIMPLEMENTED("Unexpected type in WalkAccessChain");
}
......
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