mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 22:29:39 -06:00
Merge pull request #11550 from iwubcode/set_common_samplers_count
VideoCommon: add constant value for maximum number of pixel samplers
This commit is contained in:
@ -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},
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user