Fixes for Vulkan descriptor types iterations
This commit is contained in:
@@ -115,7 +115,7 @@ void DescriptorSetLayoutVulkan::Compile()
|
||||
|
||||
// Check for maxDescriptorSetStorageBuffersDynamic
|
||||
if (LayoutTypes[VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC] > limits.maxDescriptorSetUniformBuffersDynamic)
|
||||
{
|
||||
{
|
||||
// TODO: Downgrade to non-dynamic?
|
||||
}
|
||||
ASSERT(LayoutTypes[VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC]
|
||||
@@ -172,7 +172,7 @@ DescriptorPoolVulkan::DescriptorPoolVulkan(GPUDeviceVulkan* device)
|
||||
, Layout(layout)
|
||||
#endif
|
||||
{
|
||||
Array<VkDescriptorPoolSize, FixedAllocation<VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT>> types;
|
||||
Array<VkDescriptorPoolSize, FixedAllocation<VULKAN_DESCRIPTOR_TYPE_END + 1>> types;
|
||||
|
||||
#if VULKAN_USE_DESCRIPTOR_POOL_MANAGER
|
||||
// Max number of descriptor sets layout allocations
|
||||
@@ -180,10 +180,10 @@ DescriptorPoolVulkan::DescriptorPoolVulkan(GPUDeviceVulkan* device)
|
||||
|
||||
// Descriptor sets number required to allocate the max number of descriptor sets layout.
|
||||
// When we're hashing pools with types usage ID the descriptor pool can be used for different layouts so the initial layout does not make much sense.
|
||||
// In the latter case we'll be probably overallocating the descriptor types but given the relatively small number of max allocations this should not have
|
||||
// In the latter case we'll be probably over-allocating the descriptor types but given the relatively small number of max allocations this should not have
|
||||
// a serious impact.
|
||||
MaxDescriptorSets = MaxSetsAllocations * (VULKAN_HASH_POOLS_WITH_TYPES_USAGE_ID ? 1 : Layout.GetLayouts().Count());
|
||||
for (uint32 typeIndex = VK_DESCRIPTOR_TYPE_SAMPLER; typeIndex < VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT + 1; ++typeIndex)
|
||||
for (uint32 typeIndex = VULKAN_DESCRIPTOR_TYPE_BEGIN; typeIndex <= VULKAN_DESCRIPTOR_TYPE_END; typeIndex++)
|
||||
{
|
||||
const VkDescriptorType descriptorType = (VkDescriptorType)typeIndex;
|
||||
const uint32 typesUsed = Layout.GetTypesUsed(descriptorType);
|
||||
@@ -258,7 +258,7 @@ DescriptorPoolVulkan::~DescriptorPoolVulkan()
|
||||
void DescriptorPoolVulkan::TrackAddUsage(const DescriptorSetLayoutVulkan& layout)
|
||||
{
|
||||
// Check and increment our current type usage
|
||||
for (uint32 typeIndex = VK_DESCRIPTOR_TYPE_SAMPLER; typeIndex < VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT + 1; typeIndex++)
|
||||
for (uint32 typeIndex = VULKAN_DESCRIPTOR_TYPE_BEGIN; typeIndex <= VULKAN_DESCRIPTOR_TYPE_END; typeIndex++)
|
||||
{
|
||||
#if VULKAN_USE_DESCRIPTOR_POOL_MANAGER
|
||||
ASSERT(Layout.GetTypesUsed((VkDescriptorType)typeIndex) == layout.GetTypesUsed((VkDescriptorType)typeIndex));
|
||||
@@ -275,7 +275,7 @@ void DescriptorPoolVulkan::TrackAddUsage(const DescriptorSetLayoutVulkan& layout
|
||||
void DescriptorPoolVulkan::TrackRemoveUsage(const DescriptorSetLayoutVulkan& layout)
|
||||
{
|
||||
// Check and increment our current type usage
|
||||
for (uint32 typeIndex = VK_DESCRIPTOR_TYPE_SAMPLER; typeIndex < VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT + 1; typeIndex++)
|
||||
for (uint32 typeIndex = VULKAN_DESCRIPTOR_TYPE_BEGIN; typeIndex <= VULKAN_DESCRIPTOR_TYPE_END; typeIndex++)
|
||||
{
|
||||
#if VULKAN_USE_DESCRIPTOR_POOL_MANAGER
|
||||
ASSERT(Layout.GetTypesUsed((VkDescriptorType)typeIndex) == layout.GetTypesUsed((VkDescriptorType)typeIndex));
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
|
||||
#if GRAPHICS_API_VULKAN
|
||||
|
||||
#define VULKAN_DESCRIPTOR_TYPE_BEGIN VK_DESCRIPTOR_TYPE_SAMPLER
|
||||
#define VULKAN_DESCRIPTOR_TYPE_END VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT
|
||||
|
||||
class GPUDeviceVulkan;
|
||||
class CmdBufferVulkan;
|
||||
class GPUContextVulkan;
|
||||
@@ -110,7 +113,7 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
uint32 LayoutTypes[VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT];
|
||||
uint32 LayoutTypes[VULKAN_DESCRIPTOR_TYPE_END];
|
||||
Array<SetLayout> SetLayouts;
|
||||
|
||||
uint32 _hash = 0;
|
||||
@@ -259,9 +262,9 @@ private:
|
||||
#if VULKAN_USE_DESCRIPTOR_POOL_MANAGER
|
||||
const DescriptorSetLayoutVulkan& Layout;
|
||||
#else
|
||||
int32 MaxAllocatedTypes[VK_DESCRIPTOR_TYPE_RANGE_SIZE];
|
||||
int32 NumAllocatedTypes[VK_DESCRIPTOR_TYPE_RANGE_SIZE];
|
||||
int32 PeakAllocatedTypes[VK_DESCRIPTOR_TYPE_RANGE_SIZE];
|
||||
int32 MaxAllocatedTypes[VULKAN_DESCRIPTOR_TYPE_END];
|
||||
int32 NumAllocatedTypes[VULKAN_DESCRIPTOR_TYPE_END];
|
||||
int32 PeakAllocatedTypes[VULKAN_DESCRIPTOR_TYPE_END];
|
||||
#endif
|
||||
|
||||
public:
|
||||
@@ -291,7 +294,7 @@ public:
|
||||
#if VULKAN_USE_DESCRIPTOR_POOL_MANAGER
|
||||
return MaxDescriptorSets > NumAllocatedDescriptorSets + layout.GetLayouts().Count();
|
||||
#else
|
||||
for (uint32 typeIndex = VK_DESCRIPTOR_TYPE_BEGIN_RANGE; typeIndex < VK_DESCRIPTOR_TYPE_END_RANGE; typeIndex++)
|
||||
for (uint32 typeIndex = VULKAN_DESCRIPTOR_TYPE_BEGIN; typeIndex <= VULKAN_DESCRIPTOR_TYPE_END; typeIndex++)
|
||||
{
|
||||
if (NumAllocatedTypes[typeIndex] + (int32)layout.GetTypesUsed((VkDescriptorType)typeIndex) > MaxAllocatedTypes[typeIndex])
|
||||
{
|
||||
|
||||
@@ -286,11 +286,11 @@ bool GPUPipelineStateVulkan::Init(const Description& desc)
|
||||
|
||||
// Dynamic
|
||||
RenderToolsVulkan::ZeroStruct(_descDynamic, VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO);
|
||||
_dynamicStates.Push(VK_DYNAMIC_STATE_VIEWPORT);
|
||||
_dynamicStates.Push(VK_DYNAMIC_STATE_SCISSOR);
|
||||
_dynamicStates.Push(VK_DYNAMIC_STATE_STENCIL_REFERENCE);
|
||||
_descDynamic.dynamicStateCount = _dynamicStates.Count();
|
||||
_descDynamic.pDynamicStates = _dynamicStates.Get();
|
||||
_descDynamic.pDynamicStates = _dynamicStates;
|
||||
_dynamicStates[_descDynamic.dynamicStateCount++] = VK_DYNAMIC_STATE_VIEWPORT;
|
||||
_dynamicStates[_descDynamic.dynamicStateCount++] = VK_DYNAMIC_STATE_SCISSOR;
|
||||
_dynamicStates[_descDynamic.dynamicStateCount++] = VK_DYNAMIC_STATE_STENCIL_REFERENCE;
|
||||
static_assert(ARRAY_COUNT(_dynamicStates) <= 3, "Invalid dynamic states array.");
|
||||
_desc.pDynamicState = &_descDynamic;
|
||||
|
||||
// Multisample
|
||||
|
||||
@@ -131,7 +131,7 @@ private:
|
||||
VkPipelineTessellationStateCreateInfo _descTessellation;
|
||||
VkPipelineViewportStateCreateInfo _descViewport;
|
||||
VkPipelineDynamicStateCreateInfo _descDynamic;
|
||||
Array<VkDynamicState> _dynamicStates;
|
||||
VkDynamicState _dynamicStates[3];
|
||||
VkPipelineMultisampleStateCreateInfo _descMultisample;
|
||||
VkPipelineDepthStencilStateCreateInfo _descDepthStencil;
|
||||
VkPipelineRasterizationStateCreateInfo _descRasterization;
|
||||
|
||||
Reference in New Issue
Block a user