Commit 19b43a60 by Ben Clayton

IDs: Move inline impls below class.

Addresses comments on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/38891/1/src/Vulkan/Debug/ID.hpp#34 Bug: b/145351270 Change-Id: If1aabf0b2d2ac7e992bfd59a19eeeba57cb7f84e Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/39248Tested-by: 's avatarBen Clayton <bclayton@google.com> Reviewed-by: 's avatarAntonio Maiorano <amaiorano@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent 5beaef93
...@@ -29,29 +29,56 @@ template<typename T> ...@@ -29,29 +29,56 @@ template<typename T>
class SpirvID class SpirvID
{ {
public: public:
SpirvID() SpirvID() = default;
: id(0) inline SpirvID(uint32_t id);
{} inline bool operator==(const SpirvID<T> &rhs) const;
SpirvID(uint32_t id) inline bool operator!=(const SpirvID<T> &rhs) const;
: id(id) inline bool operator<(const SpirvID<T> &rhs) const;
{}
bool operator==(const SpirvID<T> &rhs) const { return id == rhs.id; }
bool operator!=(const SpirvID<T> &rhs) const { return id != rhs.id; }
bool operator<(const SpirvID<T> &rhs) const { return id < rhs.id; }
// value returns the numerical value of the identifier. // value returns the numerical value of the identifier.
uint32_t value() const { return id; } inline uint32_t value() const;
private: private:
uint32_t id; uint32_t id = 0;
}; };
template<typename T>
SpirvID<T>::SpirvID(uint32_t id)
: id(id)
{}
template<typename T>
bool SpirvID<T>::operator==(const SpirvID<T> &rhs) const
{
return id == rhs.id;
}
template<typename T>
bool SpirvID<T>::operator!=(const SpirvID<T> &rhs) const
{
return id != rhs.id;
}
template<typename T>
bool SpirvID<T>::operator<(const SpirvID<T> &rhs) const
{
return id < rhs.id;
}
template<typename T>
uint32_t SpirvID<T>::value() const
{
return id;
}
// HandleMap<T> is an unordered map of SpirvID<T> to T. // HandleMap<T> is an unordered map of SpirvID<T> to T.
template<typename T> template<typename T>
using HandleMap = std::unordered_map<SpirvID<T>, T>; using HandleMap = std::unordered_map<SpirvID<T>, T>;
} // namespace sw } // namespace sw
namespace std { namespace std {
// std::hash implementation for sw::SpirvID<T> // std::hash implementation for sw::SpirvID<T>
template<typename T> template<typename T>
struct hash<sw::SpirvID<T> > struct hash<sw::SpirvID<T> >
......
...@@ -29,25 +29,63 @@ template<typename T> ...@@ -29,25 +29,63 @@ template<typename T>
class ID class ID
{ {
public: public:
inline ID() ID() = default;
: id(0)
{} inline ID(int id);
inline ID(int id) inline bool operator==(const ID<T> &rhs) const;
: id(id) inline bool operator!=(const ID<T> &rhs) const;
{} inline bool operator<(const ID<T> &rhs) const;
inline bool operator==(const ID<T> &rhs) const { return id == rhs.id; } inline ID operator++();
inline bool operator!=(const ID<T> &rhs) const { return id != rhs.id; } inline ID operator++(int);
inline bool operator<(const ID<T> &rhs) const { return id < rhs.id; }
inline ID operator++() { return ID(++id); }
inline ID operator++(int) { return ID(id++); }
// value returns the numerical value of the identifier. // value returns the numerical value of the identifier.
inline int value() const { return id; } inline int value() const;
private: private:
int id; int id = 0;
}; };
template<typename T>
ID<T>::ID(int id)
: id(id)
{}
template<typename T>
bool ID<T>::operator==(const ID<T> &rhs) const
{
return id == rhs.id;
}
template<typename T>
bool ID<T>::operator!=(const ID<T> &rhs) const
{
return id != rhs.id;
}
template<typename T>
bool ID<T>::operator<(const ID<T> &rhs) const
{
return id < rhs.id;
}
template<typename T>
ID<T> ID<T>::operator++()
{
return ID(++id);
}
template<typename T>
ID<T> ID<T>::operator++(int)
{
return ID(id++);
}
template<typename T>
int ID<T>::value() const
{
return id;
}
} // namespace dbg } // namespace dbg
} // namespace vk } // namespace vk
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment