Merge pull request #12545 from lioncash/hash

VideoCommon: Collapse hash specialization namespaces
This commit is contained in:
Admiral H. Curtiss 2024-01-31 20:04:15 +01:00 committed by GitHub
commit 2509164ce4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 11 additions and 20 deletions

View File

@ -79,14 +79,12 @@ struct PortableVertexDeclaration
static_assert(std::is_trivially_copyable_v<PortableVertexDeclaration>,
"Make sure we can memset-initialize");
namespace std
{
template <>
struct hash<PortableVertexDeclaration>
struct std::hash<PortableVertexDeclaration>
{
// Implementation from Wikipedia.
template <typename T>
u32 Fletcher32(const T& data) const
static u32 Fletcher32(const T& data)
{
static_assert(sizeof(T) % sizeof(u16) == 0);
@ -114,9 +112,11 @@ struct hash<PortableVertexDeclaration>
sum2 = (sum2 & 0xffff) + (sum2 >> 16);
return (sum2 << 16 | sum1);
}
size_t operator()(const PortableVertexDeclaration& decl) const { return Fletcher32(decl); }
size_t operator()(const PortableVertexDeclaration& decl) const noexcept
{
return Fletcher32(decl);
}
};
} // namespace std
// The implementation of this class is specific for GL/DX, so NativeVertexFormat.cpp
// is in the respective backend, not here in VideoCommon.

View File

@ -220,17 +220,14 @@ struct SamplerState
TM1 tm1;
};
namespace std
{
template <>
struct hash<SamplerState>
struct std::hash<SamplerState>
{
std::size_t operator()(SamplerState const& state) const noexcept
std::size_t operator()(const SamplerState& state) const noexcept
{
return std::hash<u64>{}(state.Hex());
}
};
} // namespace std
namespace RenderState
{

View File

@ -79,10 +79,8 @@ struct TextureConfig
AbstractTextureType type = AbstractTextureType::Texture_2DArray;
};
namespace std
{
template <>
struct hash<TextureConfig>
struct std::hash<TextureConfig>
{
using argument_type = TextureConfig;
using result_type = size_t;
@ -95,4 +93,3 @@ struct hash<TextureConfig>
return std::hash<u64>{}(id);
}
};
} // namespace std

View File

@ -46,14 +46,11 @@ private:
}
};
namespace std
{
template <>
struct hash<VertexLoaderUID>
struct std::hash<VertexLoaderUID>
{
size_t operator()(const VertexLoaderUID& uid) const { return uid.GetHash(); }
size_t operator()(const VertexLoaderUID& uid) const noexcept { return uid.GetHash(); }
};
} // namespace std
class VertexLoaderBase
{