Common/CommonFuncs: Remove now-unneccessary ArraySize function

Since C++17, non-member std::size() is present in the standard library
which also operates on regular C arrays. Given that, we can just replace
usages of ArraySize with that where applicable.

In many cases, we can just change the actual C array ArraySize() was
called on into a std::array and just use its .size() member function
instead.

In some other cases, we can collapse the loops they were used in, into a
ranged-for loop, eliminating the need for en explicit bounds query.
This commit is contained in:
Lioncash
2019-06-01 07:55:09 -04:00
parent a4837a5c5d
commit a9663669dc
26 changed files with 280 additions and 229 deletions

View File

@ -2,11 +2,14 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "VideoBackends/Vulkan/VKPipeline.h"
#include <array>
#include "Common/Assert.h"
#include "Common/MsgHandler.h"
#include "VideoBackends/Vulkan/ObjectCache.h"
#include "VideoBackends/Vulkan/VKPipeline.h"
#include "VideoBackends/Vulkan/VKShader.h"
#include "VideoBackends/Vulkan/VKTexture.h"
#include "VideoBackends/Vulkan/VertexFormat.h"
@ -346,13 +349,15 @@ std::unique_ptr<VKPipeline> VKPipeline::Create(const AbstractPipelineConfig& con
};
// Set viewport and scissor dynamic state so we can change it elsewhere.
static const VkDynamicState dynamic_states[] = {VK_DYNAMIC_STATE_VIEWPORT,
VK_DYNAMIC_STATE_SCISSOR};
static const std::array<VkDynamicState, 2> dynamic_states{
VK_DYNAMIC_STATE_VIEWPORT,
VK_DYNAMIC_STATE_SCISSOR,
};
static const VkPipelineDynamicStateCreateInfo dynamic_state = {
VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO, nullptr,
0, // VkPipelineDynamicStateCreateFlags flags
static_cast<u32>(ArraySize(dynamic_states)), // uint32_t dynamicStateCount
dynamic_states // const VkDynamicState* pDynamicStates
0, // VkPipelineDynamicStateCreateFlags flags
static_cast<u32>(dynamic_states.size()), // uint32_t dynamicStateCount
dynamic_states.data() // const VkDynamicState* pDynamicStates
};
// Combine to full pipeline info structure.