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

Function EnablingCapabilitiesForOp

source/val/validate_instruction.cpp:55–81  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

53// the opcode may only be used if at least one of the capabilities is specified
54// by the module.
55CapabilitySet 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

Callers 1

CapabilityCheckFunction · 0.85

Calls 5

LookupOpcodeForEnvFunction · 0.85
HasExtensionMethod · 0.45
contextMethod · 0.45
capabilitiesMethod · 0.45

Tested by

no test coverage detected