mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 05:47:56 -07:00
VideoCommon/ShaderGenCommon: Remove use of a union within ShaderUid
This is only ever used to retrieve a raw view of the given UID data structure, however it's already valid C++ to retrieve a char/unsigned char view of an object for bytewise inspection. u8 maps to unsigned char on all platforms we support, so we can just do this directly with a reinterpret cast, simplifying the overall interface.
This commit is contained in:
parent
149a97e396
commit
954246d10e
@ -69,18 +69,18 @@ public:
|
|||||||
|
|
||||||
bool operator==(const ShaderUid& obj) const
|
bool operator==(const ShaderUid& obj) const
|
||||||
{
|
{
|
||||||
return memcmp(this->values, obj.values, data.NumValues() * sizeof(*values)) == 0;
|
return memcmp(&data, &obj.data, data.NumValues() * sizeof(data)) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!=(const ShaderUid& obj) const
|
bool operator!=(const ShaderUid& obj) const
|
||||||
{
|
{
|
||||||
return memcmp(this->values, obj.values, data.NumValues() * sizeof(*values)) != 0;
|
return memcmp(&data, &obj.data, data.NumValues() * sizeof(data)) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// determines the storage order inside STL containers
|
// determines the storage order inside STL containers
|
||||||
bool operator<(const ShaderUid& obj) const
|
bool operator<(const ShaderUid& obj) const
|
||||||
{
|
{
|
||||||
return memcmp(this->values, obj.values, data.NumValues() * sizeof(*values)) < 0;
|
return memcmp(&data, &obj.data, data.NumValues() * sizeof(data)) < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a pointer to an internally stored object of the uid_data type.
|
// Returns a pointer to an internally stored object of the uid_data type.
|
||||||
@ -90,17 +90,13 @@ public:
|
|||||||
const uid_data* GetUidData() const { return &data; }
|
const uid_data* GetUidData() const { return &data; }
|
||||||
|
|
||||||
// Returns the raw bytes that make up the shader UID.
|
// Returns the raw bytes that make up the shader UID.
|
||||||
const u8* GetUidDataRaw() const { return &values[0]; }
|
const u8* GetUidDataRaw() const { return reinterpret_cast<const u8*>(&data); }
|
||||||
|
|
||||||
// Returns the size of the underlying UID data structure in bytes.
|
// Returns the size of the underlying UID data structure in bytes.
|
||||||
size_t GetUidDataSize() const { return sizeof(values); }
|
size_t GetUidDataSize() const { return sizeof(data); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
union
|
uid_data data{};
|
||||||
{
|
|
||||||
uid_data data{};
|
|
||||||
u8 values[sizeof(uid_data)];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ShaderCode : public ShaderGeneratorInterface
|
class ShaderCode : public ShaderGeneratorInterface
|
||||||
|
Loading…
Reference in New Issue
Block a user