diff options
| author | Scott Mansell <phiren@gmail.com> | 2023-02-13 16:05:51 +1300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-13 16:05:51 +1300 |
| commit | f37113204fe8e930c4e33e5e0149fbe0309fe425 (patch) | |
| tree | 9974c89131a5e1092f6551034926d9de0c32413e /Source/Core/VideoBackends/Vulkan | |
| parent | 2c24d07837b9ab94219de592adf34a35a2dc897e (diff) | |
| parent | af313f84198d2eb52690b406164eebcb1866d251 (diff) | |
Merge pull request #11550 from iwubcode/set_common_samplers_count
VideoCommon: add constant value for maximum number of pixel samplers
Diffstat (limited to 'Source/Core/VideoBackends/Vulkan')
6 files changed, 18 insertions, 10 deletions
diff --git a/Source/Core/VideoBackends/Vulkan/CommandBufferManager.cpp b/Source/Core/VideoBackends/Vulkan/CommandBufferManager.cpp index 8c9f744216..80bbd7e5b5 100644 --- a/Source/Core/VideoBackends/Vulkan/CommandBufferManager.cpp +++ b/Source/Core/VideoBackends/Vulkan/CommandBufferManager.cpp @@ -11,6 +11,7 @@ #include "Common/Thread.h" #include "VideoBackends/Vulkan/VulkanContext.h" +#include "VideoCommon/Constants.h" namespace Vulkan { @@ -148,14 +149,17 @@ VkDescriptorPool CommandBufferManager::CreateDescriptorPool(u32 max_descriptor_s /* * Worst case descriptor counts according to the descriptor layout created in ObjectCache.cpp: * UNIFORM_BUFFER_DYNAMIC: 3 - * COMBINED_IMAGE_SAMPLER: 18 + * COMBINED_IMAGE_SAMPLER: NUM_UTILITY_PIXEL_SAMPLERS + NUM_COMPUTE_SHADER_SAMPLERS + + * VideoCommon::MAX_PIXEL_SHADER_SAMPLERS * STORAGE_BUFFER: 2 * UNIFORM_TEXEL_BUFFER: 3 * STORAGE_IMAGE: 1 */ const std::array<VkDescriptorPoolSize, 5> pool_sizes{{ {VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, max_descriptor_sets * 3}, - {VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, max_descriptor_sets * 18}, + {VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, + max_descriptor_sets * (VideoCommon::MAX_PIXEL_SHADER_SAMPLERS + NUM_COMPUTE_SHADER_SAMPLERS + + NUM_UTILITY_PIXEL_SAMPLERS)}, {VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, max_descriptor_sets * 2}, {VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, max_descriptor_sets * 3}, {VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, max_descriptor_sets * 1}, diff --git a/Source/Core/VideoBackends/Vulkan/Constants.h b/Source/Core/VideoBackends/Vulkan/Constants.h index f166f9b9b4..255cfe4929 100644 --- a/Source/Core/VideoBackends/Vulkan/Constants.h +++ b/Source/Core/VideoBackends/Vulkan/Constants.h @@ -78,8 +78,8 @@ enum UNIFORM_BUFFER_DESCRIPTOR_SET_BINDING constexpr u32 MAX_VERTEX_ATTRIBUTES = 16; // Number of pixel shader texture slots -constexpr u32 NUM_PIXEL_SHADER_SAMPLERS = 8; constexpr u32 NUM_COMPUTE_SHADER_SAMPLERS = 2; +constexpr u32 NUM_UTILITY_PIXEL_SAMPLERS = 8; // Number of texel buffer binding points. constexpr u32 NUM_COMPUTE_TEXEL_BUFFERS = 2; diff --git a/Source/Core/VideoBackends/Vulkan/ObjectCache.cpp b/Source/Core/VideoBackends/Vulkan/ObjectCache.cpp index 57dbe6f5e3..68683790e7 100644 --- a/Source/Core/VideoBackends/Vulkan/ObjectCache.cpp +++ b/Source/Core/VideoBackends/Vulkan/ObjectCache.cpp @@ -21,6 +21,7 @@ #include "VideoBackends/Vulkan/VKTexture.h" #include "VideoBackends/Vulkan/VKVertexFormat.h" #include "VideoBackends/Vulkan/VulkanContext.h" +#include "VideoCommon/Constants.h" #include "VideoCommon/VideoCommon.h" namespace Vulkan @@ -119,8 +120,8 @@ bool ObjectCache::CreateDescriptorSetLayouts() }}; 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}, + {0, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, + static_cast<u32>(VideoCommon::MAX_PIXEL_SHADER_SAMPLERS), VK_SHADER_STAGE_FRAGMENT_BIT}, }}; // The dynamic veretex loader's vertex buffer must be last here, for similar reasons diff --git a/Source/Core/VideoBackends/Vulkan/StateTracker.cpp b/Source/Core/VideoBackends/Vulkan/StateTracker.cpp index 8cee69cfa9..edf57ae3b1 100644 --- a/Source/Core/VideoBackends/Vulkan/StateTracker.cpp +++ b/Source/Core/VideoBackends/Vulkan/StateTracker.cpp @@ -13,6 +13,7 @@ #include "VideoBackends/Vulkan/VKTexture.h" #include "VideoBackends/Vulkan/VKVertexFormat.h" #include "VideoBackends/Vulkan/VulkanContext.h" +#include "VideoCommon/Constants.h" namespace Vulkan { @@ -65,7 +66,7 @@ bool StateTracker::Initialize() VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); // Initialize all samplers to point by default - for (size_t i = 0; i < NUM_PIXEL_SHADER_SAMPLERS; i++) + for (size_t i = 0; i < VideoCommon::MAX_PIXEL_SHADER_SAMPLERS; i++) { m_bindings.samplers[i].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; m_bindings.samplers[i].imageView = m_dummy_texture->GetView(); @@ -498,7 +499,7 @@ void StateTracker::UpdateGXDescriptorSet() m_gx_descriptor_sets[1], 0, 0, - static_cast<u32>(NUM_PIXEL_SHADER_SAMPLERS), + static_cast<u32>(VideoCommon::MAX_PIXEL_SHADER_SAMPLERS), VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, m_bindings.samplers.data(), nullptr, @@ -602,7 +603,7 @@ void StateTracker::UpdateUtilityDescriptorSet() m_utility_descriptor_sets[1], 0, 0, - NUM_PIXEL_SHADER_SAMPLERS, + NUM_UTILITY_PIXEL_SAMPLERS, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, m_bindings.samplers.data(), nullptr, diff --git a/Source/Core/VideoBackends/Vulkan/StateTracker.h b/Source/Core/VideoBackends/Vulkan/StateTracker.h index d90496631c..1113cfc994 100644 --- a/Source/Core/VideoBackends/Vulkan/StateTracker.h +++ b/Source/Core/VideoBackends/Vulkan/StateTracker.h @@ -9,6 +9,7 @@ #include "Common/CommonTypes.h" #include "VideoBackends/Vulkan/Constants.h" +#include "VideoCommon/Constants.h" namespace Vulkan { @@ -141,7 +142,7 @@ private: std::array<u32, NUM_UBO_DESCRIPTOR_SET_BINDINGS> gx_ubo_offsets; VkDescriptorBufferInfo utility_ubo_binding; u32 utility_ubo_offset; - std::array<VkDescriptorImageInfo, NUM_PIXEL_SHADER_SAMPLERS> samplers; + std::array<VkDescriptorImageInfo, VideoCommon::MAX_PIXEL_SHADER_SAMPLERS> samplers; std::array<VkBufferView, NUM_COMPUTE_TEXEL_BUFFERS> texel_buffers; VkDescriptorBufferInfo ssbo; VkDescriptorBufferInfo gx_uber_vertex_ssbo; diff --git a/Source/Core/VideoBackends/Vulkan/VKGfx.h b/Source/Core/VideoBackends/Vulkan/VKGfx.h index bc254874fd..97ddcbf585 100644 --- a/Source/Core/VideoBackends/Vulkan/VKGfx.h +++ b/Source/Core/VideoBackends/Vulkan/VKGfx.h @@ -10,6 +10,7 @@ #include "Common/CommonTypes.h" #include "VideoBackends/Vulkan/Constants.h" #include "VideoCommon/AbstractGfx.h" +#include "VideoCommon/Constants.h" namespace Vulkan { @@ -96,6 +97,6 @@ private: float m_backbuffer_scale; // Keep a copy of sampler states to avoid cache lookups every draw - std::array<SamplerState, NUM_PIXEL_SHADER_SAMPLERS> m_sampler_states = {}; + std::array<SamplerState, VideoCommon::MAX_PIXEL_SHADER_SAMPLERS> m_sampler_states = {}; }; } // namespace Vulkan |
