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>
class SpirvID
{
public:
SpirvID()
: id(0)
{}
SpirvID(uint32_t id)
: id(id)
{}
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; }
SpirvID() = default;
inline SpirvID(uint32_t id);
inline bool operator==(const SpirvID<T> &rhs) const;
inline bool operator!=(const SpirvID<T> &rhs) const;
inline bool operator<(const SpirvID<T> &rhs) const;
// value returns the numerical value of the identifier.
uint32_t value() const { return id; }
inline uint32_t value() const;
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.
template<typename T>
using HandleMap = std::unordered_map<SpirvID<T>, T>;
} // namespace sw
namespace std {
// std::hash implementation for sw::SpirvID<T>
template<typename T>
struct hash<sw::SpirvID<T> >
......
......@@ -29,25 +29,63 @@ template<typename T>
class ID
{
public:
inline ID()
: id(0)
{}
inline ID(int id)
: id(id)
{}
inline bool operator==(const ID<T> &rhs) const { return id == rhs.id; }
inline bool operator!=(const ID<T> &rhs) const { return id != rhs.id; }
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++); }
ID() = default;
inline ID(int 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;
inline ID operator++();
inline ID operator++(int);
// value returns the numerical value of the identifier.
inline int value() const { return id; }
inline int value() const;
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 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