Returns capabilities that enable an opcode. An empty result is interpreted as no prohibition of use of the opcode. If the result is non-empty, then the opcode may only be used if at least one of the capabilities is specified by the module.
| 53 | // the opcode may only be used if at least one of the capabilities is specified |
| 54 | // by the module. |
| 55 | CapabilitySet EnablingCapabilitiesForOp(const ValidationState_t& state, |
| 56 | spv::Op opcode) { |
| 57 | // Exceptions for SPV_AMD_shader_ballot |
| 58 | switch (opcode) { |
| 59 | // Normally these would require Group capability |
| 60 | case spv::Op::OpGroupIAddNonUniformAMD: |
| 61 | case spv::Op::OpGroupFAddNonUniformAMD: |
| 62 | case spv::Op::OpGroupFMinNonUniformAMD: |
| 63 | case spv::Op::OpGroupUMinNonUniformAMD: |
| 64 | case spv::Op::OpGroupSMinNonUniformAMD: |
| 65 | case spv::Op::OpGroupFMaxNonUniformAMD: |
| 66 | case spv::Op::OpGroupUMaxNonUniformAMD: |
| 67 | case spv::Op::OpGroupSMaxNonUniformAMD: |
| 68 | if (state.HasExtension(kSPV_AMD_shader_ballot)) return CapabilitySet(); |
| 69 | break; |
| 70 | default: |
| 71 | break; |
| 72 | } |
| 73 | // Look it up in the grammar |
| 74 | const spvtools::InstructionDesc* opcode_desc = nullptr; |
| 75 | if (SPV_SUCCESS == |
| 76 | LookupOpcodeForEnv(state.context()->target_env, opcode, &opcode_desc)) { |
| 77 | return state.grammar().filterCapsAgainstTargetEnv( |
| 78 | opcode_desc->capabilities()); |
| 79 | } |
| 80 | return CapabilitySet(); |
| 81 | } |
| 82 | |
| 83 | // Returns SPV_SUCCESS if, for the given operand, the target environment |
| 84 | // satsifies minimum version requirements, or if the module declares an |
no test coverage detected