| 40 | } |
| 41 | |
| 42 | spv_result_t ValidateConvertFToU(ValidationState_t& _, const Instruction* inst, |
| 43 | uint32_t operand_index = 2) { |
| 44 | const spv::Op opcode = inst->opcode(); |
| 45 | const uint32_t result_type = inst->type_id(); |
| 46 | if (!_.IsUnsignedIntScalarType(result_type) && |
| 47 | !_.IsUnsignedIntVectorType(result_type) && |
| 48 | !_.IsUnsignedIntCooperativeMatrixType(result_type) && |
| 49 | !_.IsUnsignedIntCooperativeVectorNVType(result_type)) |
| 50 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 51 | << "Expected unsigned int scalar or vector type as Result Type: " |
| 52 | << spvOpcodeString(opcode); |
| 53 | |
| 54 | const uint32_t input_type = _.GetOperandTypeId(inst, operand_index); |
| 55 | if (!input_type || |
| 56 | (!_.IsFloatScalarType(input_type) && !_.IsFloatVectorType(input_type) && |
| 57 | !_.IsFloatCooperativeMatrixType(input_type) && |
| 58 | !_.IsFloatCooperativeVectorNVType(input_type))) |
| 59 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 60 | << "Expected input to be float scalar or vector: " |
| 61 | << spvOpcodeString(opcode); |
| 62 | |
| 63 | if (_.IsCooperativeVectorNVType(result_type) || |
| 64 | _.IsCooperativeVectorNVType(input_type)) { |
| 65 | spv_result_t ret = |
| 66 | _.CooperativeVectorDimensionsMatch(inst, result_type, input_type); |
| 67 | if (ret != SPV_SUCCESS) return ret; |
| 68 | } else if (_.IsCooperativeMatrixType(result_type) || |
| 69 | _.IsCooperativeMatrixType(input_type)) { |
| 70 | spv_result_t ret = |
| 71 | _.CooperativeMatrixShapesMatch(inst, result_type, input_type, true); |
| 72 | if (ret != SPV_SUCCESS) return ret; |
| 73 | } else { |
| 74 | if (_.GetDimension(result_type) != _.GetDimension(input_type)) |
| 75 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 76 | << "Expected input to have the same dimension as Result Type: " |
| 77 | << spvOpcodeString(opcode); |
| 78 | } |
| 79 | |
| 80 | if (auto error = ValidateShaderBitWidth(_, inst)) return error; |
| 81 | |
| 82 | return SPV_SUCCESS; |
| 83 | } |
| 84 | |
| 85 | spv_result_t ValidateConvertFToS(ValidationState_t& _, const Instruction* inst, |
| 86 | uint32_t operand_index = 2) { |
no test coverage detected