From 1eb3aaa5484a05037d51899ff35d9c553962373e Mon Sep 17 00:00:00 2001 From: TellowKrinkle Date: Wed, 3 Aug 2022 01:13:55 -0500 Subject: [PATCH] VideoCommon: Use std::array in PortableVertexDeclaration --- Source/Core/VideoBackends/Metal/MTLObjectCache.mm | 3 ++- Source/Core/VideoBackends/Metal/MTLVertexFormat.mm | 2 +- Source/Core/VideoCommon/ConstantManager.h | 6 +++--- Source/Core/VideoCommon/NativeVertexFormat.h | 6 +++--- Source/Core/VideoCommon/VertexShaderManager.cpp | 4 ++-- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Source/Core/VideoBackends/Metal/MTLObjectCache.mm b/Source/Core/VideoBackends/Metal/MTLObjectCache.mm index 49a9f4b1fb..9b1fa92fb1 100644 --- a/Source/Core/VideoBackends/Metal/MTLObjectCache.mm +++ b/Source/Core/VideoBackends/Metal/MTLObjectCache.mm @@ -289,7 +289,8 @@ public: } }; template - static void CopyAll(std::array& output, const AttributeFormat (&input)[N]) + static void CopyAll(std::array& output, + const std::array& input) { for (size_t i = 0; i < N; ++i) output[i] = VertexAttribute(input[i]); diff --git a/Source/Core/VideoBackends/Metal/MTLVertexFormat.mm b/Source/Core/VideoBackends/Metal/MTLVertexFormat.mm index 6453c5189a..d9407402e2 100644 --- a/Source/Core/VideoBackends/Metal/MTLVertexFormat.mm +++ b/Source/Core/VideoBackends/Metal/MTLVertexFormat.mm @@ -125,7 +125,7 @@ static void SetAttribute(MTLVertexDescriptor* desc, u32 attribute, const Attribu template static void SetAttributes(MTLVertexDescriptor* desc, u32 attribute, - const AttributeFormat (&format)[N]) + const std::array& format) { for (size_t i = 0; i < N; ++i) SetAttribute(desc, attribute + i, format[i]); diff --git a/Source/Core/VideoCommon/ConstantManager.h b/Source/Core/VideoCommon/ConstantManager.h index b9ca0264ef..c3427ba37f 100644 --- a/Source/Core/VideoCommon/ConstantManager.h +++ b/Source/Core/VideoCommon/ConstantManager.h @@ -95,11 +95,11 @@ struct VertexShaderConstants float4 cached_binormal; // For UberShader vertex loader u32 vertex_stride; - u32 vertex_offset_normals[3]; + std::array vertex_offset_normals; u32 vertex_offset_position; u32 vertex_offset_posmtx; - u32 vertex_offset_colors[2]; - u32 vertex_offset_texcoords[8]; + std::array vertex_offset_colors; + std::array vertex_offset_texcoords; }; struct GeometryShaderConstants diff --git a/Source/Core/VideoCommon/NativeVertexFormat.h b/Source/Core/VideoCommon/NativeVertexFormat.h index 55e1a40178..89f3a06db5 100644 --- a/Source/Core/VideoCommon/NativeVertexFormat.h +++ b/Source/Core/VideoCommon/NativeVertexFormat.h @@ -58,9 +58,9 @@ struct PortableVertexDeclaration int stride; AttributeFormat position; - AttributeFormat normals[3]; - AttributeFormat colors[2]; - AttributeFormat texcoords[8]; + std::array normals; + std::array colors; + std::array texcoords; AttributeFormat posmtx; inline bool operator<(const PortableVertexDeclaration& b) const diff --git a/Source/Core/VideoCommon/VertexShaderManager.cpp b/Source/Core/VideoCommon/VertexShaderManager.cpp index 78bf54da66..b74c820271 100644 --- a/Source/Core/VideoCommon/VertexShaderManager.cpp +++ b/Source/Core/VideoCommon/VertexShaderManager.cpp @@ -626,8 +626,8 @@ static void UpdateOffset(bool* dirty, bool include_components, u32* old_value, } template -static void UpdateOffsets(bool* dirty, bool include_components, u32 (*old_value)[N], - const AttributeFormat (&attribute)[N]) +static void UpdateOffsets(bool* dirty, bool include_components, std::array* old_value, + const std::array& attribute) { for (size_t i = 0; i < N; i++) UpdateOffset(dirty, include_components, &(*old_value)[i], attribute[i]);