summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/GeometryShaderGen.cpp
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2019-05-30 01:05:06 -0400
committerLioncash <mathew1800@gmail.com>2019-05-30 06:41:54 -0400
commit149a97e396fd1ac22df8ad9d47d4a23e3ef46d25 (patch)
treedc17796f80c8d773c909a9abcd46c3e819dd14da /Source/Core/VideoCommon/GeometryShaderGen.cpp
parent80d8173d29749b13ccdf84e75641e179ea34768b (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/GeometryShaderGen.cpp')
-rw-r--r--Source/Core/VideoCommon/GeometryShaderGen.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/Source/Core/VideoCommon/GeometryShaderGen.cpp b/Source/Core/VideoCommon/GeometryShaderGen.cpp
index e6fa3d3913..90446ca40d 100644
--- a/Source/Core/VideoCommon/GeometryShaderGen.cpp
+++ b/Source/Core/VideoCommon/GeometryShaderGen.cpp
@@ -5,7 +5,6 @@
#include "VideoCommon/GeometryShaderGen.h"
#include <cmath>
-#include <cstring>
#include "Common/CommonTypes.h"
#include "VideoCommon/DriverDetails.h"
@@ -27,10 +26,9 @@ bool geometry_shader_uid_data::IsPassthrough() const
GeometryShaderUid GetGeometryShaderUid(PrimitiveType primitive_type)
{
- ShaderUid<geometry_shader_uid_data> out;
- geometry_shader_uid_data* uid_data = out.GetUidData<geometry_shader_uid_data>();
- memset(uid_data, 0, sizeof(geometry_shader_uid_data));
+ GeometryShaderUid out;
+ geometry_shader_uid_data* const uid_data = out.GetUidData();
uid_data->primitive_type = static_cast<u32>(primitive_type);
uid_data->numTexGens = xfmem.numTexGen.numTexGens;
@@ -364,7 +362,6 @@ static void EndPrimitive(ShaderCode& out, const ShaderHostConfig& host_config,
void EnumerateGeometryShaderUids(const std::function<void(const GeometryShaderUid&)>& callback)
{
GeometryShaderUid uid;
- std::memset(&uid, 0, sizeof(uid));
const std::array<PrimitiveType, 3> primitive_lut = {
{g_ActiveConfig.backend_info.bSupportsPrimitiveRestart ? PrimitiveType::TriangleStrip :
@@ -372,7 +369,7 @@ void EnumerateGeometryShaderUids(const std::function<void(const GeometryShaderUi
PrimitiveType::Lines, PrimitiveType::Points}};
for (PrimitiveType primitive : primitive_lut)
{
- auto* guid = uid.GetUidData<geometry_shader_uid_data>();
+ geometry_shader_uid_data* const guid = uid.GetUidData();
guid->primitive_type = static_cast<u32>(primitive);
for (u32 texgens = 0; texgens <= 8; texgens++)