MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / HaveSameLayoutDecorations

Function HaveSameLayoutDecorations

source/val/validate_memory.cpp:104–120  ·  view source on GitHub ↗

Returns true if all decorations that affect the data layout of the struct (like Offset), are the same for the two types. |type1| and |type2| must be OpTypeStruct instructions.

Source from the content-addressed store, hash-verified

102// (like Offset), are the same for the two types. |type1| and |type2| must be
103// OpTypeStruct instructions.
104bool HaveSameLayoutDecorations(ValidationState_t& _, const Instruction* type1,
105 const Instruction* type2) {
106 assert(type1->opcode() == spv::Op::OpTypeStruct &&
107 "type1 must be an OpTypeStruct instruction.");
108 assert(type2->opcode() == spv::Op::OpTypeStruct &&
109 "type2 must be an OpTypeStruct instruction.");
110 const std::set<Decoration>& type1_decorations = _.id_decorations(type1->id());
111 const std::set<Decoration>& type2_decorations = _.id_decorations(type2->id());
112
113 // TODO: Will have to add other check for arrays an matricies if we want to
114 // handle them.
115 if (HasConflictingMemberOffsets(type1_decorations, type2_decorations)) {
116 return false;
117 }
118
119 return true;
120}
121
122bool HasConflictingMemberOffsets(
123 const std::set<Decoration>& type1_decorations,

Callers 1

Calls 3

opcodeMethod · 0.45
idMethod · 0.45

Tested by

no test coverage detected