Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #11246 from tellowkrinkle/PVDMemset
VideoCommon: Zero PortableVertexDeclarations on initialization
  • Loading branch information
AdmiralCurtiss committed Nov 6, 2022
2 parents c75b53c + d9ed9ae commit 1348337
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Source/Core/VideoCommon/NativeVertexFormat.h
Expand Up @@ -63,6 +63,9 @@ struct PortableVertexDeclaration
std::array<AttributeFormat, 8> texcoords;
AttributeFormat posmtx;

// Make sure we initialize padding to 0 since padding is included in the == memcmp
PortableVertexDeclaration() { memset(this, 0, sizeof(*this)); }

inline bool operator<(const PortableVertexDeclaration& b) const
{
return memcmp(this, &b, sizeof(PortableVertexDeclaration)) < 0;
Expand All @@ -73,6 +76,9 @@ struct PortableVertexDeclaration
}
};

static_assert(std::is_trivially_copyable_v<PortableVertexDeclaration>,
"Make sure we can memset-initialize");

namespace std
{
template <>
Expand Down

0 comments on commit 1348337

Please sign in to comment.