diff options
| author | Lioncash <mathew1800@gmail.com> | 2019-05-30 01:05:06 -0400 |
|---|---|---|
| committer | Lioncash <mathew1800@gmail.com> | 2019-05-30 06:41:54 -0400 |
| commit | 149a97e396fd1ac22df8ad9d47d4a23e3ef46d25 (patch) | |
| tree | dc17796f80c8d773c909a9abcd46c3e819dd14da /Source/Core/VideoCommon/UberShaderVertex.cpp | |
| parent | 80d8173d29749b13ccdf84e75641e179ea34768b (diff) | |
VideoCommon: Remove unnecessary memset on ShaderUid instances.
Zero-initialization zeroes out all members and padding bits, so this is
safe to do. While we're at it, also add static assertions that enforce
the necessary requirements of a UID type explicitly within the ShaderUid
class.
This way, we can remove several memset calls around the shader
generation code that makes sure the underlying UID data is zeroed out.
Now our ShaderUid class enforces this for us, so we don't need to care about
it at the usage sites.
Diffstat (limited to 'Source/Core/VideoCommon/UberShaderVertex.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/UberShaderVertex.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Source/Core/VideoCommon/UberShaderVertex.cpp b/Source/Core/VideoCommon/UberShaderVertex.cpp index 4032e0df40..5fb30aaf03 100644 --- a/Source/Core/VideoCommon/UberShaderVertex.cpp +++ b/Source/Core/VideoCommon/UberShaderVertex.cpp @@ -15,9 +15,10 @@ namespace UberShader VertexShaderUid GetVertexShaderUid() { VertexShaderUid out; - vertex_ubershader_uid_data* uid_data = out.GetUidData<vertex_ubershader_uid_data>(); - memset(uid_data, 0, sizeof(*uid_data)); + + vertex_ubershader_uid_data* const uid_data = out.GetUidData(); uid_data->num_texgens = xfmem.numTexGen.numTexGens; + return out; } @@ -487,11 +488,10 @@ void GenVertexShaderTexGens(APIType ApiType, u32 numTexgen, ShaderCode& out) void EnumerateVertexShaderUids(const std::function<void(const VertexShaderUid&)>& callback) { VertexShaderUid uid; - std::memset(&uid, 0, sizeof(uid)); for (u32 texgens = 0; texgens <= 8; texgens++) { - auto* vuid = uid.GetUidData<UberShader::vertex_ubershader_uid_data>(); + vertex_ubershader_uid_data* const vuid = uid.GetUidData(); vuid->num_texgens = texgens; callback(uid); } |
