#define SPV_CAPABILITY_AS_MASK(capability) \
(spv_capability_mask_t(1) << (capability))
-// Min/max capability IDs. TODO(dekimir): move this into context.
-enum {
- kCapabilitiesMinValue = SpvCapabilityMatrix,
- kCapabilitiesMaxValue = SpvCapabilityPipeStorage
-};
-
// Applies f to every capability present in a mask.
namespace libspirv {
template <typename Functor>
inline void ForEach(spv_capability_mask_t capabilities, Functor f) {
- for (int cap = kCapabilitiesMinValue; cap <= kCapabilitiesMaxValue; ++cap)
- if (spvIsInBitfield(SPV_CAPABILITY_AS_MASK(cap), capabilities))
- f(static_cast<SpvCapability>(cap));
+ for (int c = 0; capabilities; ++c, capabilities >>= 1)
+ if (capabilities & 1) f(static_cast<SpvCapability>(c));
}
} // end namespace libspirv