summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/TextureConfig.h
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2017-10-08 20:15:34 -0400
committerLioncash <mathew1800@gmail.com>2017-10-08 23:55:14 -0400
commitc8af9e5f7b5815c82d5db47c5c67e33dd8dbd8d5 (patch)
treebc3512a69579779eb85d1aa52796e69cf78ec2dd /Source/Core/VideoCommon/TextureConfig.h
parent1a4883ac5afd81ec3c6eb0795968d9ccef8c32f4 (diff)
TextureConfig: Specialize std::hash for TextureConfig
This allows the hashing for TextureConfig instances to automatically be resolved instead of needing to directly specify it all the time.
Diffstat (limited to 'Source/Core/VideoCommon/TextureConfig.h')
-rw-r--r--Source/Core/VideoCommon/TextureConfig.h24
1 files changed, 16 insertions, 8 deletions
diff --git a/Source/Core/VideoCommon/TextureConfig.h b/Source/Core/VideoCommon/TextureConfig.h
index 7a9ac08bcc..86ea88f651 100644
--- a/Source/Core/VideoCommon/TextureConfig.h
+++ b/Source/Core/VideoCommon/TextureConfig.h
@@ -31,14 +31,22 @@ struct TextureConfig
u32 layers = 1;
AbstractTextureFormat format = AbstractTextureFormat::RGBA8;
bool rendertarget = false;
+};
+
+namespace std
+{
+template <>
+struct hash<TextureConfig>
+{
+ using argument_type = TextureConfig;
+ using result_type = size_t;
- struct Hasher : std::hash<u64>
+ result_type operator()(const argument_type& c) const noexcept
{
- size_t operator()(const TextureConfig& c) const
- {
- u64 id = (u64)c.rendertarget << 63 | (u64)c.format << 50 | (u64)c.layers << 48 |
- (u64)c.levels << 32 | (u64)c.height << 16 | (u64)c.width;
- return std::hash<u64>::operator()(id);
- }
- };
+ const u64 id = static_cast<u64>(c.rendertarget) << 63 | static_cast<u64>(c.format) << 50 |
+ static_cast<u64>(c.layers) << 48 | static_cast<u64>(c.levels) << 32 |
+ static_cast<u64>(c.height) << 16 | static_cast<u64>(c.width);
+ return std::hash<u64>{}(id);
+ }
};
+} // namespace std