Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 35 additions & 9 deletions source/RenderGraph/RunnablePasses/PipelineHolder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,26 @@
result = hashCombine( result, pphdr::getDescriptorsHash( pass.getOutputs(), index ) );
return result;
}

static bool hasPagedBuffers( std::map< uint32_t, Attachment const * > const & attaches )
{
return std::any_of( attaches.begin(), attaches.end()
, []( std::map< uint32_t, Attachment const * >::value_type const & lookup )
{
bool result = lookup.second->isBuffer();
if ( result )
result = lookup.second->buffer().data->buffer.data->maxPages > 1u;
return result;
} );
}

static bool hasPagedBuffers( crg::FramePass const & pass )
{
return pphdr::hasPagedBuffers( pass.getUniforms() )
|| pphdr::hasPagedBuffers( pass.getInputs() )
|| pphdr::hasPagedBuffers( pass.getInouts() )
|| pphdr::hasPagedBuffers( pass.getOutputs() );
}
}

PipelineHolder::PipelineHolder( FramePass const & pass
Expand Down Expand Up @@ -216,18 +236,21 @@
{
m_descriptorBindings.clear();

for ( auto & descriptorSet : m_descriptorSets )
if ( m_descriptorSetPool )
{
if ( descriptorSet.set )
bool hasPagedBuffers = pphdr::hasPagedBuffers( m_pass );
for ( auto & descriptorSet : m_descriptorSets )
{
crgUnregisterObject( m_context, descriptorSet.set );
descriptorSet.writes.clear();
descriptorSet.set = {};
if ( descriptorSet.set )
{
crgUnregisterObject( m_context, descriptorSet.set );
if ( hasPagedBuffers )

Check failure on line 247 in source/RenderGraph/RunnablePasses/PipelineHolder.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this code to not nest more than 3 if|for|do|while|switch statements.

See more on https://sonarcloud.io/project/issues?id=DragonJoker_RenderGraph&issues=AZ4BPjc3yQTgrk_1-ey3&open=AZ4BPjc3yQTgrk_1-ey3&pullRequest=154
m_context.vkFreeDescriptorSets( m_context.device, m_descriptorSetPool, 1u, &descriptorSet.set );
descriptorSet.writes.clear();
descriptorSet.set = {};
}
}
}

if ( m_descriptorSetPool )
{
crgUnregisterObject( m_context, m_descriptorSetPool );
m_context.vkDestroyDescriptorPool( m_context.device
, m_descriptorSetPool
Expand Down Expand Up @@ -538,12 +561,15 @@
if ( m_context.vkCreateDescriptorPool )
{
assert( m_descriptorSetLayout );
VkDescriptorPoolCreateFlags flags{};
if ( pphdr::hasPagedBuffers( m_pass ) )
flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT;
// x2 to account for descriptor set changes (the deallocation is deferred)
auto maxSets = uint32_t( m_descriptorSets.size() * 2u );
auto sizes = getBindingsSizes( m_descriptorBindings, maxSets );
VkDescriptorPoolCreateInfo createInfo{ VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO
, nullptr
, 0u
, flags
, maxSets
, uint32_t( sizes.size() )
, sizes.data() };
Expand Down
Loading