SPV: Handle stride decorations for arrays of arrays, and using multiple type instances when strides are used.
This commit is contained in:
parent
4998789d4e
commit
c9e0a42b92
5 changed files with 277 additions and 249 deletions
|
|
@ -281,18 +281,23 @@ Id Builder::makeMatrixType(Id component, int cols, int rows)
|
|||
return type->getResultId();
|
||||
}
|
||||
|
||||
Id Builder::makeArrayType(Id element, unsigned size)
|
||||
// TODO: performance: track arrays per stride
|
||||
// If a stride is supplied (non-zero) make an array.
|
||||
// If no stride (0), reuse previous array types.
|
||||
Id Builder::makeArrayType(Id element, unsigned size, int stride)
|
||||
{
|
||||
// First, we need a constant instruction for the size
|
||||
Id sizeId = makeUintConstant(size);
|
||||
|
||||
// try to find existing type
|
||||
Instruction* type;
|
||||
for (int t = 0; t < (int)groupedTypes[OpTypeArray].size(); ++t) {
|
||||
type = groupedTypes[OpTypeArray][t];
|
||||
if (type->getIdOperand(0) == element &&
|
||||
type->getIdOperand(1) == sizeId)
|
||||
return type->getResultId();
|
||||
if (stride == 0) {
|
||||
// try to find existing type
|
||||
for (int t = 0; t < (int)groupedTypes[OpTypeArray].size(); ++t) {
|
||||
type = groupedTypes[OpTypeArray][t];
|
||||
if (type->getIdOperand(0) == element &&
|
||||
type->getIdOperand(1) == sizeId)
|
||||
return type->getResultId();
|
||||
}
|
||||
}
|
||||
|
||||
// not found, make it
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue