Add support for arrays to interface and size analyses
Only missing piece here was the array size, which is available since
we support integer constants now.
Bug: b/120799499
Change-Id: I8c42aa2ced86e8358be1ffbfaa14ca87b58cc138
Reviewed-on: https://swiftshader-review.googlesource.com/c/23449
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
diff --git a/src/Pipeline/SpirvShader.cpp b/src/Pipeline/SpirvShader.cpp
index 0fa1279..fffafdf 100644
--- a/src/Pipeline/SpirvShader.cpp
+++ b/src/Pipeline/SpirvShader.cpp
@@ -245,10 +245,11 @@
return defs[insn.word(2)].sizeInComponents * insn.word(3);
case spv::OpTypeArray:
- // This should be the element count * element size. Array sizes come from constant ids,
- // which we haven't yet implemented.
- UNIMPLEMENTED("Need constant support to get array size");
- return 1;
+ {
+ // Element count * element size. Array sizes come from constant ids.
+ auto arraySize = GetConstantInt(insn.word(3));
+ return defs[insn.word(2)].sizeInComponents * arraySize;
+ }
case spv::OpTypeStruct:
{
@@ -346,7 +347,15 @@
}
return d.Location;
}
- // TODO: array
+ case spv::OpTypeArray:
+ {
+ auto arraySize = GetConstantInt(obj.definition.word(3));
+ for (auto i = 0u; i < arraySize; i++)
+ {
+ d.Location = PopulateInterfaceInner(iface, obj.definition.word(2), d);
+ }
+ return d.Location;
+ }
default:
// Intentionally partial; most opcodes do not participate in type hierarchies
return 0;