mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 13:20:27 -06:00
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:
@ -2,16 +2,17 @@
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "VideoBackends/D3D/D3DBase.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/DynamicLibrary.h"
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Common/MsgHandler.h"
|
||||
#include "Common/StringUtil.h"
|
||||
#include "Core/Config/GraphicsSettings.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "VideoBackends/D3D/D3DBase.h"
|
||||
#include "VideoBackends/D3D/D3DState.h"
|
||||
#include "VideoBackends/D3D/DXTexture.h"
|
||||
#include "VideoBackends/D3DCommon/Common.h"
|
||||
@ -30,8 +31,11 @@ D3D_FEATURE_LEVEL feature_level;
|
||||
|
||||
static ComPtr<ID3D11Debug> s_debug;
|
||||
|
||||
static constexpr D3D_FEATURE_LEVEL s_supported_feature_levels[] = {
|
||||
D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_1, D3D_FEATURE_LEVEL_10_0};
|
||||
constexpr std::array<D3D_FEATURE_LEVEL, 3> s_supported_feature_levels{
|
||||
D3D_FEATURE_LEVEL_11_0,
|
||||
D3D_FEATURE_LEVEL_10_1,
|
||||
D3D_FEATURE_LEVEL_10_0,
|
||||
};
|
||||
|
||||
bool Create(u32 adapter_index, bool enable_debug_layer)
|
||||
{
|
||||
@ -72,8 +76,8 @@ bool Create(u32 adapter_index, bool enable_debug_layer)
|
||||
if (enable_debug_layer)
|
||||
{
|
||||
hr = d3d11_create_device(adapter.Get(), D3D_DRIVER_TYPE_UNKNOWN, nullptr,
|
||||
D3D11_CREATE_DEVICE_DEBUG, s_supported_feature_levels,
|
||||
static_cast<UINT>(ArraySize(s_supported_feature_levels)),
|
||||
D3D11_CREATE_DEVICE_DEBUG, s_supported_feature_levels.data(),
|
||||
static_cast<UINT>(s_supported_feature_levels.size()),
|
||||
D3D11_SDK_VERSION, &device, &feature_level, &context);
|
||||
|
||||
// Debugbreak on D3D error
|
||||
@ -102,8 +106,8 @@ bool Create(u32 adapter_index, bool enable_debug_layer)
|
||||
if (!enable_debug_layer || FAILED(hr))
|
||||
{
|
||||
hr = d3d11_create_device(adapter.Get(), D3D_DRIVER_TYPE_UNKNOWN, nullptr, 0,
|
||||
s_supported_feature_levels,
|
||||
static_cast<UINT>(ArraySize(s_supported_feature_levels)),
|
||||
s_supported_feature_levels.data(),
|
||||
static_cast<UINT>(s_supported_feature_levels.size()),
|
||||
D3D11_SDK_VERSION, &device, &feature_level, &context);
|
||||
}
|
||||
|
||||
@ -184,8 +188,8 @@ std::vector<u32> GetAAModes(u32 adapter_index)
|
||||
}
|
||||
|
||||
HRESULT hr = d3d11_create_device(nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr, 0,
|
||||
s_supported_feature_levels,
|
||||
static_cast<UINT>(ArraySize(s_supported_feature_levels)),
|
||||
s_supported_feature_levels.data(),
|
||||
static_cast<UINT>(s_supported_feature_levels.size()),
|
||||
D3D11_SDK_VERSION, &temp_device, nullptr, nullptr);
|
||||
if (FAILED(hr))
|
||||
return {};
|
||||
|
@ -3,7 +3,7 @@
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "VideoBackends/D3D/PerfQuery.h"
|
||||
#include "Common/CommonFuncs.h"
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "VideoBackends/D3D/D3DBase.h"
|
||||
@ -63,7 +63,7 @@ void PerfQuery::DisableQuery(PerfQueryGroup type)
|
||||
void PerfQuery::ResetQuery()
|
||||
{
|
||||
m_query_count = 0;
|
||||
std::fill_n(m_results, ArraySize(m_results), 0);
|
||||
std::fill(std::begin(m_results), std::end(m_results), 0);
|
||||
}
|
||||
|
||||
u32 PerfQuery::GetQueryResult(PerfQueryType type)
|
||||
|
@ -2,7 +2,10 @@
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "VideoBackends/D3D12/DXContext.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <dxgi1_2.h>
|
||||
#include <queue>
|
||||
#include <vector>
|
||||
@ -11,7 +14,6 @@
|
||||
#include "Common/DynamicLibrary.h"
|
||||
#include "Common/StringUtil.h"
|
||||
#include "VideoBackends/D3D12/Common.h"
|
||||
#include "VideoBackends/D3D12/DXContext.h"
|
||||
#include "VideoBackends/D3D12/DescriptorHeapManager.h"
|
||||
#include "VideoBackends/D3D12/StreamBuffer.h"
|
||||
#include "VideoCommon/VideoConfig.h"
|
||||
@ -183,14 +185,15 @@ bool DXContext::CreateDevice(u32 adapter_index, bool enable_debug_layer)
|
||||
info_queue->SetBreakOnSeverity(D3D12_MESSAGE_SEVERITY_WARNING, TRUE);
|
||||
|
||||
D3D12_INFO_QUEUE_FILTER filter = {};
|
||||
D3D12_MESSAGE_ID id_list[] = {
|
||||
std::array<D3D12_MESSAGE_ID, 5> id_list{
|
||||
D3D12_MESSAGE_ID_CLEARRENDERTARGETVIEW_MISMATCHINGCLEARVALUE,
|
||||
D3D12_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_MISMATCHINGCLEARVALUE,
|
||||
D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_RENDERTARGETVIEW_NOT_SET,
|
||||
D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_TYPE_MISMATCH,
|
||||
D3D12_MESSAGE_ID_DRAW_EMPTY_SCISSOR_RECTANGLE};
|
||||
filter.DenyList.NumIDs = static_cast<UINT>(ArraySize(id_list));
|
||||
filter.DenyList.pIDList = id_list;
|
||||
D3D12_MESSAGE_ID_DRAW_EMPTY_SCISSOR_RECTANGLE,
|
||||
};
|
||||
filter.DenyList.NumIDs = static_cast<UINT>(id_list.size());
|
||||
filter.DenyList.pIDList = id_list.data();
|
||||
info_queue->PushStorageFilter(&filter);
|
||||
}
|
||||
}
|
||||
@ -470,8 +473,9 @@ void DXContext::ExecuteCommandList(bool wait_for_completion)
|
||||
// Close and queue command list.
|
||||
HRESULT hr = res.command_list->Close();
|
||||
CHECK(SUCCEEDED(hr), "Close command list");
|
||||
ID3D12CommandList* const execute_lists[] = {res.command_list.Get()};
|
||||
m_command_queue->ExecuteCommandLists(static_cast<UINT>(ArraySize(execute_lists)), execute_lists);
|
||||
const std::array<ID3D12CommandList*, 1> execute_lists{res.command_list.Get()};
|
||||
m_command_queue->ExecuteCommandLists(static_cast<UINT>(execute_lists.size()),
|
||||
execute_lists.data());
|
||||
|
||||
// Update fence when GPU has completed.
|
||||
hr = m_command_queue->Signal(m_fence.Get(), m_current_fence_value);
|
||||
|
@ -3,16 +3,17 @@
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "VideoBackends/D3D12/Common.h"
|
||||
#include "VideoBackends/D3D12/DescriptorAllocator.h"
|
||||
#include "VideoBackends/D3D12/DescriptorHeapManager.h"
|
||||
#include "VideoBackends/D3D12/StreamBuffer.h"
|
||||
|
||||
#include <array>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
|
||||
struct IDXGIFactory2;
|
||||
|
||||
namespace DX12
|
||||
|
@ -93,7 +93,7 @@ void PerfQuery::ResetQuery()
|
||||
m_query_resolve_pos = 0;
|
||||
m_query_readback_pos = 0;
|
||||
m_query_next_pos = 0;
|
||||
std::fill_n(m_results, ArraySize(m_results), 0);
|
||||
std::fill(std::begin(m_results), std::end(m_results), 0);
|
||||
for (auto& entry : m_query_buffer)
|
||||
{
|
||||
entry.fence_value = 0;
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "Common/CommonFuncs.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/GL/GLExtensions/GLExtensions.h"
|
||||
|
||||
@ -54,7 +53,7 @@ void PerfQuery::FlushResults()
|
||||
void PerfQuery::ResetQuery()
|
||||
{
|
||||
m_query_count = 0;
|
||||
std::fill_n(m_results, ArraySize(m_results), 0);
|
||||
std::fill(std::begin(m_results), std::end(m_results), 0);
|
||||
}
|
||||
|
||||
u32 PerfQuery::GetQueryResult(PerfQueryType type)
|
||||
|
@ -2,14 +2,14 @@
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <algorithm>
|
||||
#include "VideoBackends/Vulkan/CommandBufferManager.h"
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
|
||||
#include "Common/Assert.h"
|
||||
#include "Common/CommonFuncs.h"
|
||||
#include "Common/MsgHandler.h"
|
||||
|
||||
#include "VideoBackends/Vulkan/CommandBufferManager.h"
|
||||
#include "VideoBackends/Vulkan/VulkanContext.h"
|
||||
|
||||
namespace Vulkan
|
||||
@ -94,18 +94,22 @@ bool CommandBufferManager::CreateCommandBuffers()
|
||||
}
|
||||
|
||||
// TODO: A better way to choose the number of descriptors.
|
||||
VkDescriptorPoolSize pool_sizes[] = {{VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 500000},
|
||||
{VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 500000},
|
||||
{VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 16},
|
||||
{VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, 16384},
|
||||
{VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 16384}};
|
||||
const std::array<VkDescriptorPoolSize, 5> pool_sizes{{
|
||||
{VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 500000},
|
||||
{VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 500000},
|
||||
{VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 16},
|
||||
{VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, 16384},
|
||||
{VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 16384},
|
||||
}};
|
||||
|
||||
VkDescriptorPoolCreateInfo pool_create_info = {VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
|
||||
nullptr,
|
||||
0,
|
||||
100000, // tweak this
|
||||
static_cast<u32>(ArraySize(pool_sizes)),
|
||||
pool_sizes};
|
||||
const VkDescriptorPoolCreateInfo pool_create_info = {
|
||||
VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
|
||||
nullptr,
|
||||
0,
|
||||
100000, // tweak this
|
||||
static_cast<u32>(pool_sizes.size()),
|
||||
pool_sizes.data(),
|
||||
};
|
||||
|
||||
res = vkCreateDescriptorPool(device, &pool_create_info, nullptr, &resources.descriptor_pool);
|
||||
if (res != VK_SUCCESS)
|
||||
|
@ -5,9 +5,8 @@
|
||||
#include "VideoBackends/Vulkan/ObjectCache.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
#include <array>
|
||||
#include <type_traits>
|
||||
#include <xxhash.h>
|
||||
|
||||
#include "Common/Assert.h"
|
||||
#include "Common/CommonFuncs.h"
|
||||
@ -110,27 +109,31 @@ bool ObjectCache::CreateDescriptorSetLayouts()
|
||||
{
|
||||
// The geometry shader buffer must be last in this binding set, as we don't include it
|
||||
// if geometry shaders are not supported by the device. See the decrement below.
|
||||
static const VkDescriptorSetLayoutBinding standard_ubo_bindings[] = {
|
||||
static const std::array<VkDescriptorSetLayoutBinding, 3> standard_ubo_bindings{{
|
||||
{UBO_DESCRIPTOR_SET_BINDING_PS, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 1,
|
||||
VK_SHADER_STAGE_FRAGMENT_BIT},
|
||||
{UBO_DESCRIPTOR_SET_BINDING_VS, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 1,
|
||||
VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT},
|
||||
{UBO_DESCRIPTOR_SET_BINDING_GS, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 1,
|
||||
VK_SHADER_STAGE_GEOMETRY_BIT}};
|
||||
VK_SHADER_STAGE_GEOMETRY_BIT},
|
||||
}};
|
||||
|
||||
static const VkDescriptorSetLayoutBinding standard_sampler_bindings[] = {
|
||||
static const std::array<VkDescriptorSetLayoutBinding, 1> standard_sampler_bindings{{
|
||||
{0, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, static_cast<u32>(NUM_PIXEL_SHADER_SAMPLERS),
|
||||
VK_SHADER_STAGE_FRAGMENT_BIT}};
|
||||
VK_SHADER_STAGE_FRAGMENT_BIT},
|
||||
}};
|
||||
|
||||
static const VkDescriptorSetLayoutBinding standard_ssbo_bindings[] = {
|
||||
{0, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_FRAGMENT_BIT}};
|
||||
static const std::array<VkDescriptorSetLayoutBinding, 1> standard_ssbo_bindings{{
|
||||
{0, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_FRAGMENT_BIT},
|
||||
}};
|
||||
|
||||
static const VkDescriptorSetLayoutBinding utility_ubo_bindings[] = {
|
||||
0, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 1,
|
||||
VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_GEOMETRY_BIT | VK_SHADER_STAGE_FRAGMENT_BIT};
|
||||
static const std::array<VkDescriptorSetLayoutBinding, 1> utility_ubo_bindings{{
|
||||
{0, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 1,
|
||||
VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_GEOMETRY_BIT | VK_SHADER_STAGE_FRAGMENT_BIT},
|
||||
}};
|
||||
|
||||
// Utility samplers aren't dynamically indexed.
|
||||
static const VkDescriptorSetLayoutBinding utility_sampler_bindings[] = {
|
||||
static const std::array<VkDescriptorSetLayoutBinding, 9> utility_sampler_bindings{{
|
||||
{0, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT},
|
||||
{1, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT},
|
||||
{2, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT},
|
||||
@ -140,36 +143,37 @@ bool ObjectCache::CreateDescriptorSetLayouts()
|
||||
{6, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT},
|
||||
{7, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT},
|
||||
{8, VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, 1, VK_SHADER_STAGE_FRAGMENT_BIT},
|
||||
};
|
||||
}};
|
||||
|
||||
static const VkDescriptorSetLayoutBinding compute_set_bindings[] = {
|
||||
static const std::array<VkDescriptorSetLayoutBinding, 6> compute_set_bindings{{
|
||||
{0, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 1, VK_SHADER_STAGE_COMPUTE_BIT},
|
||||
{1, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_COMPUTE_BIT},
|
||||
{2, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_COMPUTE_BIT},
|
||||
{3, VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, 1, VK_SHADER_STAGE_COMPUTE_BIT},
|
||||
{4, VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, 1, VK_SHADER_STAGE_COMPUTE_BIT},
|
||||
{5, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 1, VK_SHADER_STAGE_COMPUTE_BIT},
|
||||
};
|
||||
}};
|
||||
|
||||
VkDescriptorSetLayoutCreateInfo create_infos[NUM_DESCRIPTOR_SET_LAYOUTS] = {
|
||||
std::array<VkDescriptorSetLayoutCreateInfo, NUM_DESCRIPTOR_SET_LAYOUTS> create_infos{{
|
||||
{VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, nullptr, 0,
|
||||
static_cast<u32>(ArraySize(standard_ubo_bindings)), standard_ubo_bindings},
|
||||
static_cast<u32>(standard_ubo_bindings.size()), standard_ubo_bindings.data()},
|
||||
{VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, nullptr, 0,
|
||||
static_cast<u32>(ArraySize(standard_sampler_bindings)), standard_sampler_bindings},
|
||||
static_cast<u32>(standard_sampler_bindings.size()), standard_sampler_bindings.data()},
|
||||
{VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, nullptr, 0,
|
||||
static_cast<u32>(ArraySize(standard_ssbo_bindings)), standard_ssbo_bindings},
|
||||
static_cast<u32>(standard_ssbo_bindings.size()), standard_ssbo_bindings.data()},
|
||||
{VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, nullptr, 0,
|
||||
static_cast<u32>(ArraySize(utility_ubo_bindings)), utility_ubo_bindings},
|
||||
static_cast<u32>(utility_ubo_bindings.size()), utility_ubo_bindings.data()},
|
||||
{VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, nullptr, 0,
|
||||
static_cast<u32>(ArraySize(utility_sampler_bindings)), utility_sampler_bindings},
|
||||
static_cast<u32>(utility_sampler_bindings.size()), utility_sampler_bindings.data()},
|
||||
{VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, nullptr, 0,
|
||||
static_cast<u32>(ArraySize(compute_set_bindings)), compute_set_bindings}};
|
||||
static_cast<u32>(compute_set_bindings.size()), compute_set_bindings.data()},
|
||||
}};
|
||||
|
||||
// Don't set the GS bit if geometry shaders aren't available.
|
||||
if (!g_ActiveConfig.backend_info.bSupportsGeometryShaders)
|
||||
create_infos[DESCRIPTOR_SET_LAYOUT_STANDARD_UNIFORM_BUFFERS].bindingCount--;
|
||||
|
||||
for (size_t i = 0; i < NUM_DESCRIPTOR_SET_LAYOUTS; i++)
|
||||
for (size_t i = 0; i < create_infos.size(); i++)
|
||||
{
|
||||
VkResult res = vkCreateDescriptorSetLayout(g_vulkan_context->GetDevice(), &create_infos[i],
|
||||
nullptr, &m_descriptor_set_layouts[i]);
|
||||
@ -194,41 +198,44 @@ void ObjectCache::DestroyDescriptorSetLayouts()
|
||||
|
||||
bool ObjectCache::CreatePipelineLayouts()
|
||||
{
|
||||
VkResult res;
|
||||
|
||||
// Descriptor sets for each pipeline layout.
|
||||
// In the standard set, the SSBO must be the last descriptor, as we do not include it
|
||||
// when fragment stores and atomics are not supported by the device.
|
||||
const VkDescriptorSetLayout standard_sets[] = {
|
||||
const std::array<VkDescriptorSetLayout, 3> standard_sets{
|
||||
m_descriptor_set_layouts[DESCRIPTOR_SET_LAYOUT_STANDARD_UNIFORM_BUFFERS],
|
||||
m_descriptor_set_layouts[DESCRIPTOR_SET_LAYOUT_STANDARD_SAMPLERS],
|
||||
m_descriptor_set_layouts[DESCRIPTOR_SET_LAYOUT_STANDARD_SHADER_STORAGE_BUFFERS]};
|
||||
const VkDescriptorSetLayout utility_sets[] = {
|
||||
m_descriptor_set_layouts[DESCRIPTOR_SET_LAYOUT_STANDARD_SHADER_STORAGE_BUFFERS],
|
||||
};
|
||||
const std::array<VkDescriptorSetLayout, 2> utility_sets{
|
||||
m_descriptor_set_layouts[DESCRIPTOR_SET_LAYOUT_UTILITY_UNIFORM_BUFFER],
|
||||
m_descriptor_set_layouts[DESCRIPTOR_SET_LAYOUT_UTILITY_SAMPLERS]};
|
||||
const VkDescriptorSetLayout compute_sets[] = {
|
||||
m_descriptor_set_layouts[DESCRIPTOR_SET_LAYOUT_COMPUTE]};
|
||||
m_descriptor_set_layouts[DESCRIPTOR_SET_LAYOUT_UTILITY_SAMPLERS],
|
||||
};
|
||||
const std::array<VkDescriptorSetLayout, 1> compute_sets{
|
||||
m_descriptor_set_layouts[DESCRIPTOR_SET_LAYOUT_COMPUTE],
|
||||
};
|
||||
|
||||
// Info for each pipeline layout
|
||||
VkPipelineLayoutCreateInfo pipeline_layout_info[NUM_PIPELINE_LAYOUTS] = {
|
||||
std::array<VkPipelineLayoutCreateInfo, NUM_PIPELINE_LAYOUTS> pipeline_layout_info{{
|
||||
// Standard
|
||||
{VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, nullptr, 0,
|
||||
static_cast<u32>(ArraySize(standard_sets)), standard_sets, 0, nullptr},
|
||||
static_cast<u32>(standard_sets.size()), standard_sets.data(), 0, nullptr},
|
||||
|
||||
// Utility
|
||||
{VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, nullptr, 0,
|
||||
static_cast<u32>(ArraySize(utility_sets)), utility_sets, 0, nullptr},
|
||||
static_cast<u32>(utility_sets.size()), utility_sets.data(), 0, nullptr},
|
||||
|
||||
// Compute
|
||||
{VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, nullptr, 0,
|
||||
static_cast<u32>(ArraySize(compute_sets)), compute_sets, 0, nullptr}};
|
||||
static_cast<u32>(compute_sets.size()), compute_sets.data(), 0, nullptr},
|
||||
}};
|
||||
|
||||
// If bounding box is unsupported, don't bother with the SSBO descriptor set.
|
||||
if (!g_ActiveConfig.backend_info.bSupportsBBox)
|
||||
pipeline_layout_info[PIPELINE_LAYOUT_STANDARD].setLayoutCount--;
|
||||
|
||||
for (size_t i = 0; i < NUM_PIPELINE_LAYOUTS; i++)
|
||||
for (size_t i = 0; i < pipeline_layout_info.size(); i++)
|
||||
{
|
||||
VkResult res;
|
||||
if ((res = vkCreatePipelineLayout(g_vulkan_context->GetDevice(), &pipeline_layout_info[i],
|
||||
nullptr, &m_pipeline_layouts[i])) != VK_SUCCESS)
|
||||
{
|
||||
|
@ -81,7 +81,7 @@ void PerfQuery::ResetQuery()
|
||||
m_query_count = 0;
|
||||
m_query_readback_pos = 0;
|
||||
m_query_next_pos = 0;
|
||||
std::fill_n(m_results, ArraySize(m_results), 0);
|
||||
std::fill(std::begin(m_results), std::end(m_results), 0);
|
||||
|
||||
// Reset entire query pool, ensuring all queries are ready to write to.
|
||||
StateTracker::GetInstance()->EndRenderPass();
|
||||
|
@ -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.
|
||||
|
Reference in New Issue
Block a user