mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-12 22:56:09 +00:00
Use TypedInteger for BindGroupIndex
Bug: dawn:442 Change-Id: I889a943cbaf2d349c31a15fdf126d66964bdd0a7 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23247 Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: Stephen White <senorblanco@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
e5d94c31a0
commit
250f26229b
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "common/Platform.h"
|
||||
#include "common/TypedInteger.h"
|
||||
#include "common/ityp_bitset.h"
|
||||
|
||||
#include <bitset>
|
||||
#include <functional>
|
||||
@@ -87,4 +88,14 @@ size_t Hash(const std::bitset<N>& value) {
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace std {
|
||||
template <typename Index, size_t N>
|
||||
class hash<ityp::bitset<Index, N>> {
|
||||
public:
|
||||
size_t operator()(const ityp::bitset<Index, N>& value) const {
|
||||
return Hash(static_cast<const std::bitset<N>&>(value));
|
||||
}
|
||||
};
|
||||
} // namespace std
|
||||
|
||||
#endif // COMMON_HASHUTILS_H_
|
||||
|
||||
@@ -62,12 +62,14 @@ using TypedInteger = T;
|
||||
|
||||
namespace detail {
|
||||
template <typename Tag, typename T>
|
||||
class TypedIntegerImpl {
|
||||
class alignas(T) TypedIntegerImpl {
|
||||
static_assert(std::is_integral<T>::value, "TypedInteger must be integral");
|
||||
T mValue;
|
||||
|
||||
public:
|
||||
constexpr TypedIntegerImpl() : mValue(0) {
|
||||
static_assert(alignof(TypedIntegerImpl) == alignof(T), "");
|
||||
static_assert(sizeof(TypedIntegerImpl) == sizeof(T), "");
|
||||
}
|
||||
|
||||
// Construction from non-narrowing integral types.
|
||||
|
||||
@@ -58,6 +58,14 @@ namespace ityp {
|
||||
using Base::none;
|
||||
using Base::size;
|
||||
|
||||
bool operator==(const bitset& other) const noexcept {
|
||||
return Base::operator==(static_cast<const Base&>(other));
|
||||
}
|
||||
|
||||
bool operator!=(const bitset& other) const noexcept {
|
||||
return Base::operator!=(static_cast<const Base&>(other));
|
||||
}
|
||||
|
||||
bitset& operator&=(const bitset& other) noexcept {
|
||||
return static_cast<bitset&>(Base::operator&=(static_cast<const Base&>(other)));
|
||||
}
|
||||
@@ -117,6 +125,8 @@ namespace ityp {
|
||||
friend BitSetIterator<N, Index> IterateBitSet(const bitset& bitset) {
|
||||
return BitSetIterator<N, Index>(static_cast<const Base&>(bitset));
|
||||
}
|
||||
|
||||
friend class std::hash<bitset>;
|
||||
};
|
||||
|
||||
} // namespace ityp
|
||||
|
||||
Reference in New Issue
Block a user