Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deal with "missing" descriptor sets in ShaderSet::assignDescriptor #878

Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions include/vsg/utils/ShaderSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ namespace vsg
inline ref_ptr<PipelineLayout> createPipelineLayout(const std::set<std::string>& defines) { return createPipelineLayout(defines, descriptorSetRange()); }

/// create pipeline layout for specified range {minimum_set, maxiumum_set+1> of descriptor sets that are enabled by specified defines or required by default.
///
/// Note: the underlying Vulkan call vkCreatePipelineLayout assumes that the array of
/// descriptor sets starts with set 0. Therefore the minimum_set argument should be 0 unless
/// you really know what you're doing.
virtual ref_ptr<PipelineLayout> createPipelineLayout(const std::set<std::string>& defines, std::pair<uint32_t, uint32_t> range) const;

int compare(const Object& rhs) const override;
Expand Down
18 changes: 11 additions & 7 deletions src/vsg/utils/GraphicsPipelineConfigurator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,21 @@ bool DescriptorConfigurator::assignUniform(const std::string& name, const Buffer

bool DescriptorConfigurator::assignDescriptor(uint32_t set, uint32_t binding, VkDescriptorType descriptorType, uint32_t descriptorCount, VkShaderStageFlags stageFlags, ref_ptr<Descriptor> descriptor)
{
if (set >= descriptorSets.size()) descriptorSets.resize(set + 1);

auto& ds = descriptorSets[set];
if (!ds)
if (auto currentSize = descriptorSets.size(); set >= currentSize)
{
ds = vsg::DescriptorSet::create();
ds->setLayout = DescriptorSetLayout::create();
descriptorSets.resize(set + 1);
for (auto i = currentSize; i <= set; i++)
{
if (!descriptorSets[i])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The descriptorSets[i] will always be null in this case so this check can be removed,

{
descriptorSets[i] = vsg::DescriptorSet::create();
descriptorSets[i]->setLayout = DescriptorSetLayout::create();
}
}
}

auto& ds = descriptorSets[set];
ds->descriptors.push_back(descriptor);

auto& descriptorBindings = ds->setLayout->bindings;
descriptorBindings.push_back(VkDescriptorSetLayoutBinding{binding, descriptorType, descriptorCount, stageFlags, nullptr});

Expand Down
Loading