Add decorations to structs with buffer references

The containsPhysicalStorageBufferOrArray function now handles struct
types correctly, checking their contents recursively for buffer
reference types. As a result, OpVariables containing structs that have
members that are buffer references now have the appropriate
AliasedPointer or RestrictPointer decoration as per the spec.

Fixes #3188
This commit is contained in:
Arcady Goldmints-Orlov 2023-05-18 16:18:42 -06:00 committed by arcady-lunarg
parent d1517d64cf
commit 9caca7a17b
3 changed files with 77 additions and 50 deletions

View file

@ -1373,7 +1373,7 @@ bool Builder::containsType(Id typeId, spv::Op typeOp, unsigned int width) const
}
// return true if the type is a pointer to PhysicalStorageBufferEXT or an
// array of such pointers. These require restrict/aliased decorations.
// contains such a pointer. These require restrict/aliased decorations.
bool Builder::containsPhysicalStorageBufferOrArray(Id typeId) const
{
const Instruction& instr = *module.getInstruction(typeId);
@ -1385,6 +1385,12 @@ bool Builder::containsPhysicalStorageBufferOrArray(Id typeId) const
return getTypeStorageClass(typeId) == StorageClassPhysicalStorageBufferEXT;
case OpTypeArray:
return containsPhysicalStorageBufferOrArray(getContainedTypeId(typeId));
case OpTypeStruct:
for (int m = 0; m < instr.getNumOperands(); ++m) {
if (containsPhysicalStorageBufferOrArray(instr.getIdOperand(m)))
return true;
}
return false;
default:
return false;
}