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

Function ValidateVectorExtractDynamic

source/val/validate_composites.cpp:146–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

144}
145
146spv_result_t ValidateVectorExtractDynamic(ValidationState_t& _,
147 const Instruction* inst) {
148 const uint32_t result_type = inst->type_id();
149 const spv::Op result_opcode = _.GetIdOpcode(result_type);
150 if (!spvOpcodeIsScalarType(result_opcode)) {
151 return _.diag(SPV_ERROR_INVALID_DATA, inst)
152 << "Expected Result Type to be a scalar type";
153 }
154
155 const uint32_t vector_type = _.GetOperandTypeId(inst, 2);
156 const spv::Op vector_opcode = _.GetIdOpcode(vector_type);
157 if (vector_opcode != spv::Op::OpTypeVector &&
158 vector_opcode != spv::Op::OpTypeVectorIdEXT) {
159 return _.diag(SPV_ERROR_INVALID_DATA, inst)
160 << "Expected Vector type to be OpTypeVector";
161 }
162
163 if (_.GetComponentType(vector_type) != result_type) {
164 return _.diag(SPV_ERROR_INVALID_DATA, inst)
165 << "Expected Vector component type to be equal to Result Type";
166 }
167
168 const auto index = _.FindDef(inst->GetOperandAs<uint32_t>(3));
169 if (!index || index->type_id() == 0 || !_.IsIntScalarType(index->type_id())) {
170 return _.diag(SPV_ERROR_INVALID_DATA, inst)
171 << "Expected Index to be int scalar";
172 }
173
174 if (_.HasCapability(spv::Capability::Shader) &&
175 _.ContainsLimitedUseIntOrFloatType(inst->type_id())) {
176 return _.diag(SPV_ERROR_INVALID_DATA, inst)
177 << "Cannot extract from a vector of 8- or 16-bit types";
178 }
179 return SPV_SUCCESS;
180}
181
182spv_result_t ValidateVectorInsertDyanmic(ValidationState_t& _,
183 const Instruction* inst) {

Callers 1

CompositesPassFunction · 0.85

Calls 10

spvOpcodeIsScalarTypeFunction · 0.85
GetIdOpcodeMethod · 0.80
diagMethod · 0.80
GetOperandTypeIdMethod · 0.80
FindDefMethod · 0.80
IsIntScalarTypeMethod · 0.80
type_idMethod · 0.45
GetComponentTypeMethod · 0.45
HasCapabilityMethod · 0.45

Tested by

no test coverage detected