Started refactor to lazily compilable shaders.
This commit is contained in:
89
include/util/enum_bitfield_operators.hpp
Normal file
89
include/util/enum_bitfield_operators.hpp
Normal file
@@ -0,0 +1,89 @@
|
||||
#pragma once
|
||||
|
||||
#define DEFINE_ENUM_BITFIELD_OPERATORS(ENUM_TYPE) \
|
||||
[[nodiscard]] constexpr ENUM_TYPE operator|( \
|
||||
const ENUM_TYPE lhs, const ENUM_TYPE rhs \
|
||||
) { \
|
||||
return static_cast<ENUM_TYPE>( \
|
||||
static_cast<std::underlying_type_t<ENUM_TYPE>>(lhs) | \
|
||||
static_cast<std::underlying_type_t<ENUM_TYPE>>(rhs) \
|
||||
); \
|
||||
} \
|
||||
\
|
||||
[[nodiscard]] constexpr ENUM_TYPE operator&( \
|
||||
const ENUM_TYPE lhs, const ENUM_TYPE rhs \
|
||||
) { \
|
||||
return static_cast<ENUM_TYPE>( \
|
||||
static_cast<std::underlying_type_t<ENUM_TYPE>>(lhs) & \
|
||||
static_cast<std::underlying_type_t<ENUM_TYPE>>(rhs) \
|
||||
); \
|
||||
} \
|
||||
\
|
||||
[[nodiscard]] constexpr ENUM_TYPE operator^( \
|
||||
const ENUM_TYPE lhs, const ENUM_TYPE rhs \
|
||||
) { \
|
||||
return static_cast<ENUM_TYPE>( \
|
||||
static_cast<std::underlying_type_t<ENUM_TYPE>>(lhs) ^ \
|
||||
static_cast<std::underlying_type_t<ENUM_TYPE>>(rhs) \
|
||||
); \
|
||||
} \
|
||||
\
|
||||
[[nodiscard]] constexpr ENUM_TYPE operator~(const ENUM_TYPE a) \
|
||||
{ \
|
||||
return static_cast<ENUM_TYPE>( \
|
||||
~static_cast<std::underlying_type_t<ENUM_TYPE>>(a) \
|
||||
); \
|
||||
} \
|
||||
\
|
||||
constexpr ENUM_TYPE operator<<( \
|
||||
ENUM_TYPE& lhs, \
|
||||
int shift \
|
||||
) { \
|
||||
return static_cast<ENUM_TYPE>( \
|
||||
static_cast<std::underlying_type_t<ENUM_TYPE>>(lhs) << shift \
|
||||
); \
|
||||
} \
|
||||
\
|
||||
constexpr ENUM_TYPE operator<<( \
|
||||
ENUM_TYPE& lhs, \
|
||||
int shift \
|
||||
) { \
|
||||
return static_cast<ENUM_TYPE>( \
|
||||
static_cast<std::underlying_type_t<ENUM_TYPE>>(lhs) << shift \
|
||||
); \
|
||||
} \
|
||||
\
|
||||
constexpr ENUM_TYPE& operator|=( \
|
||||
ENUM_TYPE& lhs, \
|
||||
const ENUM_TYPE rhs \
|
||||
) { \
|
||||
return lhs = lhs | rhs; \
|
||||
} \
|
||||
\
|
||||
constexpr ENUM_TYPE& operator&=( \
|
||||
ENUM_TYPE& lhs, \
|
||||
const ENUM_TYPE rhs \
|
||||
) { \
|
||||
return lhs = lhs & rhs; \
|
||||
} \
|
||||
\
|
||||
constexpr ENUM_TYPE& operator^=( \
|
||||
ENUM_TYPE& lhs, \
|
||||
const ENUM_TYPE rhs \
|
||||
) { \
|
||||
return lhs = lhs ^ rhs; \
|
||||
} \
|
||||
\
|
||||
constexpr ENUM_TYPE& operator<<=( \
|
||||
ENUM_TYPE& lhs, \
|
||||
const int shift \
|
||||
) { \
|
||||
return lhs = lhs << shift; \
|
||||
} \
|
||||
\
|
||||
constexpr ENUM_TYPE& operator>>=( \
|
||||
ENUM_TYPE& lhs, \
|
||||
const int shift \
|
||||
) { \
|
||||
return lhs = lhs >> shift; \
|
||||
}
|
||||
Reference in New Issue
Block a user