tp::utils::MutableDescriptorSet class

A mutable variant of tp::DescriptorSet. Updating a Vulkan descriptor set after binding it is not allowed by default. This class maintains a state of all its descriptors so they can be set one at a time. By calling tp::utils::MutableDescriporSet::commit, a new descriptor set will be created based on the current state. Any following set calls won't disturb the already created descriptor set.

Constructors, destructors, conversion operators

MutableDescriptorSet(tp::Device* device, const tp::DescriptorSetLayout& layout, const char* debugName = nullptr)

Public functions

auto commit(tp::DescriptorPool& pool) -> tp::DescriptorSetView
Processes the changes to the descriptors, resolving any tp::FutureDescriptor. Returns a view to a tp::DescriptorSet with the current state of the descriptors, allocating a new one from the given pool if needed.
void copyDescriptors(const MutableDescriptorSet& other)
Transfers over the given mutable descriptor set's current state of descriptors. Does not commit.
auto get(uint32_t descriptorIndex) const -> const tp::Descriptor&
Returns the currently set (uncommitted) descriptor that was previously. Can be used to avoid spurious calls to tp::utils::MutableDescriptorSet::set or tp::utils::MutableDescriptorSet::setImmediate.
auto getLastCommittedView() const -> tp::DescriptorSetView
Returns the last allocated descriptor set from the last tp::utils::MutableDescriptorSet::commit call.
auto hasPendingChanges() const -> bool
Returns true if any descriptors have been set since the last tp::utils::MutableDescriptorSet::commit call.
void releaseAndReset()
Releases all descriptor sets and resets the state of the descriptors.
void reset()
Resets the state of the descriptors without releasing any previously allocated descriptor sets.
void set(uint32_t descriptorIndex, tp::Descriptor descriptor)
Sets a resource descriptor to the given index. The change will have no effect except for tp::utils::MutableDescriptorSet::get calls until tp::utils::MutableDescriptorSet::commit gets called.
void set(uint32_t descriptorIndex, tp::FutureDescriptor descriptor)
Sets a resource descriptor to the given index. The change will have no effect until tp::utils::MutableDescriptorSet::commit gets called. This overload is used for binding job-local resources before the tp::Job gets enqueued.
void setImmediate(uint32_t firstDescriptorIndex, tp::ArrayParameter<const tp::Descriptor> descriptors)
Sets resource descriptors starting at the given index, immediately and retroactively updating the last committed descriptor set. This function is intended to be used with a "bindless" descriptor setup.

Function documentation

tp::utils::MutableDescriptorSet::MutableDescriptorSet(tp::Device* device, const tp::DescriptorSetLayout& layout, const char* debugName = nullptr)

Parameters
device The Tephra device used.
layout The layout of this descriptor set.
debugName The debug name of this descriptor set.

tp::DescriptorSetView tp::utils::MutableDescriptorSet::commit(tp::DescriptorPool& pool)

Processes the changes to the descriptors, resolving any tp::FutureDescriptor. Returns a view to a tp::DescriptorSet with the current state of the descriptors, allocating a new one from the given pool if needed.

Parameters
pool The descriptor pool to allocate from.

void tp::utils::MutableDescriptorSet::copyDescriptors(const MutableDescriptorSet& other)

Transfers over the given mutable descriptor set's current state of descriptors. Does not commit.

Parameters
other The mutable descriptor set to transfer the descriptor state from. This set must use the same layout.

const tp::Descriptor& tp::utils::MutableDescriptorSet::get(uint32_t descriptorIndex) const

Returns the currently set (uncommitted) descriptor that was previously. Can be used to avoid spurious calls to tp::utils::MutableDescriptorSet::set or tp::utils::MutableDescriptorSet::setImmediate.

Parameters
descriptorIndex The index of the descriptor in the descriptor set. This is the index it would have in the descriptors array of tp::DescriptorSetSetup.

void tp::utils::MutableDescriptorSet::set(uint32_t descriptorIndex, tp::Descriptor descriptor)

Sets a resource descriptor to the given index. The change will have no effect except for tp::utils::MutableDescriptorSet::get calls until tp::utils::MutableDescriptorSet::commit gets called.

Parameters
descriptorIndex The index of the descriptor in the descriptor set. This is the index it would have in the descriptors array of tp::DescriptorSetSetup.
descriptor The descriptor to be set to this index.

void tp::utils::MutableDescriptorSet::set(uint32_t descriptorIndex, tp::FutureDescriptor descriptor)

Sets a resource descriptor to the given index. The change will have no effect until tp::utils::MutableDescriptorSet::commit gets called. This overload is used for binding job-local resources before the tp::Job gets enqueued.

Parameters
descriptorIndex The index of the descriptor in the descriptor set. This is the index it would have in the descriptors array of tp::DescriptorSetSetup.
descriptor The future descriptor to be set to this index.

void tp::utils::MutableDescriptorSet::setImmediate(uint32_t firstDescriptorIndex, tp::ArrayParameter<const tp::Descriptor> descriptors)

Sets resource descriptors starting at the given index, immediately and retroactively updating the last committed descriptor set. This function is intended to be used with a "bindless" descriptor setup.

Parameters
firstDescriptorIndex The index of the first descriptor to update. This is the index it would have in the descriptors array of tp::DescriptorSetSetup.
descriptors The array of descriptors to be set.