| 144 | } |
| 145 | |
| 146 | spv_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 | |
| 182 | spv_result_t ValidateVectorInsertDyanmic(ValidationState_t& _, |
| 183 | const Instruction* inst) { |
no test coverage detected