vendredi 23 novembre 2018

How update multiply descriptorSets at once

I have multiply render targets from my swapchain and create a descriptorSet per target. The idea ist to create one commandBuffer per renderTarget und bind the equivalent descriptor. Now I want to update the descriptorSets with one single call of updateDescriptorSets and used:

std::vector<vk::WriteDescriptorSet> writes;

for( UINT32 index = 0; index < descriptorSets.size(); ++index )
{
    writes.push_back( 
        vk::WriteDescriptorSet( descriptorSets[index], 0, 0, 1, 
                                vk::DescriptorType::eStorageImage,
                                &vk::DescriptorImageInfo( vk::Sampler(), imageViews[index], vk::ImageLayout::eGeneral ),
                                nullptr,
                                nullptr ) );
}

device.updateDescriptorSets( writes.size(), writes.data(), 0, nullptr );

With this approach only the last renderTarget in the queue presents the wanted result. The others produce just black screens. But when i call updateDescriptorSets multiply times all works like expected:

std::vector<vk::WriteDescriptorSet> writes;

for( UINT32 index = 0; index < descriptorSets.size(); ++index )
{
    writes.push_back( 
        vk::WriteDescriptorSet( descriptorSets[index], 0, 0, 1, 
                                vk::DescriptorType::eStorageImage,
                                &vk::DescriptorImageInfo( vk::Sampler(), imageViews[index], vk::ImageLayout::eGeneral ),
                                nullptr,
                                nullptr ) );
   device.updateDescriptorSets( writes.size(), writes.data(), 0, nullptr );
   writes.clear();
}

I thought that i can update multiply descriptorSets at once. So it is not possible or what else could be my error.

PS: I use the c++ Header frome the vulkan SDK

Aucun commentaire:

Enregistrer un commentaire